﻿/* ==========================================
   GLOBAL THEME VARIABLES
   ========================================== */
:root {
    --bg-base: #0f172a; /* slate-900 */
    --bg-surface: #1e293b; /* slate-800 */
    --bg-surface-hover: #334155; /* slate-700 */

    --text-main: #f8fafc; /* slate-50 */
    --text-muted: #94a3b8; /* slate-400 */

    --accent: #3b82f6; /* blue-500 */
    --accent-hover: #2563eb; /* blue-600 */

    --border-color: #334155; /* slate-700 */

    --status-green: #22c55e;
    --status-yellow: #eab308;
    --status-red: #ef4444;
}

/* ==========================================
   RESET & MOBILE OPTIMIZATIONS
   ========================================== */
* {
    box-sizing: border-box;
    /* Removes the ugly blue flash when tapping buttons on mobile */
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    /* 100dvh perfectly matches the dynamic viewport height on mobile browsers */
    height: 100dvh;
    overflow: hidden;
}

/* ==========================================
   SHELL LAYOUT (Header, Main, Footer)
   ========================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Mobile safe-area padding for hardware notches */
    padding: calc(12px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left));
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.room-badge {
    background-color: var(--bg-base);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 1.1rem;
    letter-spacing: 2px;
    border: 1px solid var(--border-color);
    text-transform: uppercase;
}

main {
    flex: 1;
    overflow-y: auto;
    position: relative;
    /* Smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
    /* Safe areas for landscape mode */
    padding: 20px max(20px, env(safe-area-inset-right)) 20px max(20px, env(safe-area-inset-left));
}

.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Mobile safe-area padding for the bottom gesture bar */
    padding: 12px max(20px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 10;
}

.footer-actions {
    display: flex;
    gap: 10px;
}

/* ==========================================
   UNIVERSAL BUTTONS & INPUTS
   ========================================== */
.icon-btn {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* Made slightly taller for better mobile thumb tapping */
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    transition: background 0.2s, transform 0.1s;
}

    .icon-btn:active {
        transform: scale(0.95);
        background: var(--bg-surface-hover);
    }

    .icon-btn svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }

@media (max-width: 400px) {
    .btn-text-hide-mobile {
        display: none;
    }
}

.base-input {
    background: var(--bg-base);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
}

    .base-input:focus {
        outline: none;
        border-color: var(--accent);
    }

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

    .primary-btn:hover {
        background: var(--accent-hover);
    }

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ==========================================
   CONNECTION STATUS INDICATORS
   ========================================== */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.status-dot {
    height: 10px;
    width: 10px;
    background-color: var(--status-red);
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

    .status-dot.connected {
        background-color: var(--status-green);
    }

    .status-dot.reconnecting {
        background-color: var(--status-yellow);
    }

/* ==========================================
   SLIDE-OUT PLAYERS DRAWER
   ========================================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 40;
}

    .drawer-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

.users-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -320px;
    width: 300px;
    max-width: 80vw;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

    .users-drawer.open {
        right: 0;
    }

.drawer-header {
    padding: calc(20px + env(safe-area-inset-top)) 20px 20px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .drawer-header h3 {
        margin: 0;
        font-size: 1.1rem;
    }

.users-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    padding-bottom: env(safe-area-inset-bottom);
}

.user-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface-hover);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* ==========================================
   UNIVERSAL SETTINGS MODAL
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.2s;
}

    .modal-overlay.hidden {
        opacity: 0;
        pointer-events: none;
    }

.modal-content {
    /* Ensures the modal doesn't touch the very edges of mobile screens */
    width: calc(100% - 40px);
    margin: auto;
    max-width: 450px;
    background: var(--bg-surface);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    /* Prevent the keyboard from pushing the modal out of bounds */
    max-height: 85dvh;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .modal-header h3 {
        margin: 0;
        font-size: 1.2rem;
    }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}


/* Header */
header {
    padding: 3rem 1.5rem 2rem;
    text-align: center;
}

    header h1 {
        font-size: 2.5rem;
        font-weight: 800;
        letter-spacing: -1px;
        margin-bottom: 0.5rem;
    }

        header h1 span {
            color: var(--brand-blue);
        }

    header p {
        color: var(--text-secondary);
        font-size: 1.1rem;
        max-width: 550px;
        margin: 0 auto;
        line-height: 1.5;
    }