/* --- Premium Base Styles --- */
:root {
    --glass-bg: rgba(255, 255, 255, 0.82);
    --glass-border: rgba(15, 23, 42, 0.08);
    --glass-blur: blur(18px);
    --shadow-soft: 0 18px 40px -28px rgba(15, 23, 42, 0.45);
    --shadow-hard: 0 30px 70px -34px rgba(15, 23, 42, 0.45);
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: rgba(255, 255, 255, 0.98);
    --border-soft: rgba(15, 23, 42, 0.08);
    --text-soft: #0b1220;
    --text-muted: #5b6472;
    --ring-soft: rgba(37, 99, 235, 0.28);
    --brand: #2563eb;
    --brand-deep: #1e40af;
    --accent: #0ea5e9;
    --font-body: "Manrope", system-ui, sans-serif;
    --font-display: "Space Grotesk", "Manrope", sans-serif;
    --font-mono: "JetBrains Mono", monospace;
}

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent body scroll, handle in containers */
}

body {
    font-family: var(--font-body);
    background: radial-gradient(1200px 800px at 8% -10%, rgba(37, 99, 235, 0.18), transparent 55%),
        radial-gradient(1100px 800px at 110% 0%, rgba(14, 165, 233, 0.18), transparent 60%),
        linear-gradient(165deg, #f8fafc 0%, #eef2ff 45%, #e2e8f0 100%);
    -webkit-tap-highlight-color: transparent;
    color: var(--text-soft);
    font-size: 16px;
    line-height: 1.6;
    letter-spacing: 0.006em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    /* Native App Feel */
    overscroll-behavior: none;
}

h1,
h2,
h3,
h4,
.display-font {
    font-family: var(--font-display);
    letter-spacing: -0.015em;
}

#app {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
}

#view-lobby,
#view-student {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
}

#view-teacher {
    background: linear-gradient(180deg, rgba(248, 250, 252, 1) 0%, rgba(238, 242, 255, 0.95) 100%);
}

header {
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-bottom-color: var(--border-soft);
    box-shadow: 0 12px 28px -26px rgba(15, 23, 42, 0.45);
}

.teacher-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#student-stream,
#tab-questions-content,
#tab-students-content {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(241, 245, 249, 0.95) 100%);
}

.text-gray-900 {
    color: var(--text-soft);
}

.text-gray-800 {
    color: #111827;
}

.text-gray-700 {
    color: #1f2937;
}

.text-gray-600 {
    color: #475569;
}

.text-gray-500 {
    color: var(--text-muted);
}

.text-gray-400 {
    color: #94a3b8;
}

code,
pre,
.font-mono {
    font-family: var(--font-mono);
}

/* Input Reset & Styling */
.input-glass {
    background: rgba(255, 255, 255, 0.8);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-soft);
    box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.03), 0 6px 16px -10px rgba(15, 23, 42, 0.25);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-glass:focus {
    background: var(--surface-strong);
    border-color: rgba(14, 165, 233, 0.5);
    box-shadow: 0 0 0 5px var(--ring-soft), inset 0 2px 4px rgba(15, 23, 42, 0.02);
    outline: none;
}

/* Buttons */
.btn-modern {
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 14px 30px -22px rgba(15, 23, 42, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.45);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
    overflow: hidden;
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
    background-blend-mode: soft-light;
}

.btn-modern:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.btn-modern:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--ring-soft), var(--shadow-soft);
}

.btn-modern:active {
    transform: scale(0.97);
}

.btn-modern::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.btn-modern:hover::after {
    opacity: 1;
}

/* Scrollbar */
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.custom-scrollbar {
    /* Ensure smooth scrolling on iOS */
    -webkit-overflow-scrolling: touch;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.18);
    border-radius: 10px;
}

/* Utilities */
.glass-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.78) 100%);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
}

.message-bubble {
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.9));
    border: 1px solid var(--border-soft);
    box-shadow: 0 12px 32px -24px rgba(15, 23, 42, 0.35);
    transition: transform 0.2s;
    transform-origin: bottom left;
}

.icon-btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 12px 26px -20px rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.icon-btn i {
    font-size: 1rem;
}

.icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-soft);
}

.pulse-delay-1 {
    animation-delay: 0.1s;
}

.pulse-delay-2 {
    animation-delay: 0.2s;
}

/* Responsive Adjustments (Max-width: 768px for mobile) */
@media (max-width: 768px) {
    header {
        padding-top: calc(env(safe-area-inset-top) + 0.5rem);
    }

    .lobby-card {
        padding: 1.5rem;
    }

    #view-teacher main,
    #view-student #student-stream {
        padding-bottom: calc(5rem + env(safe-area-inset-bottom));
    }

    .student-dock {
        display: none;
    }

    .teacher-actions {
        position: static;
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
        padding: 0;
        border-top: none;
    }

    .sticky-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.5);
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 50;
        box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.05);
    }

    .sticky-nav a,
    .sticky-nav button {
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .sticky-nav a:active,
    .sticky-nav button:active {
        transform: scale(0.92);
        opacity: 0.7;
    }

    .no-scrollbar::-webkit-scrollbar {
        display: none;
    }
    .no-scrollbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .header-visualizer {
        height: 24px;
        display: flex;
        align-items: center;
        gap: 3px;
    }
    .v-bar {
        width: 3px;
        height: 8px;
        background: #3b82f6; /* Blue-500 */
        border-radius: 2px;
        transition: height 0.1s ease;
    }
    .v-bar-mini {
        width: 2px;
        height: 6px;
        background: #4f46e5; /* Indigo-600 */
        border-radius: 1px;
        transition: height 0.1s ease;
    }

    /* Deny Button Style */
    .deny-btn {
        background: #f1f5f9; /* Slate-100 */
        color: #64748b; /* Slate-500 */
        transition: background 0.2s ease, color 0.2s ease;
    }
    .deny-btn:hover {
        background: #fee2e2; /* Red-100 */
        color: #ef4444; /* Red-500 */
    }
}

.header-visualizer-desktop {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 32px;
}

@keyframes v-wave {
    0%, 100% { height: 8px; }
    50% { height: 20px; }
}
.v-bar.animating {
    animation: v-wave 0.5s ease-in-out infinite;
}
.v-bar:nth-child(2).animating { animation-delay: 0.1s; }
.v-bar:nth-child(3).animating { animation-delay: 0.2s; }
.v-bar:nth-child(4).animating { animation-delay: 0.3s; }
.v-bar:nth-child(5).animating { animation-delay: 0.4s; }

@keyframes v-wave-mini {
    0%, 100% { height: 6px; }
    50% { height: 16px; }
}
.v-bar-mini.animating {
    animation: v-wave-mini 0.6s ease-in-out infinite;
}
.v-bar-mini:nth-child(2).animating { animation-delay: 0.1s; }
.v-bar-mini:nth-child(3).animating { animation-delay: 0.2s; }
.v-bar-mini:nth-child(4).animating { animation-delay: 0.3s; }
.v-bar-mini:nth-child(5).animating { animation-delay: 0.4s; }
.v-bar-mini:nth-child(6).animating { animation-delay: 0.5s; }
.v-bar-mini:nth-child(7).animating { animation-delay: 0.6s; }

/* Install Banner */
.install-banner {
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.install-banner.hidden {
    display: none;
}

#toast-container>div {
    background: rgba(255, 255, 255, 0.94) !important;
    color: var(--text-soft) !important;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 12px 30px -18px rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.mic-active-ring {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Student approved / speaking ring (GREEN) */
.mic-active-ring-green {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse-ring-green 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* Animations */
.view-transition {
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.view-hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    inset: 0;
    transform: scale(0.98);
    z-index: -1;
}

.view-active {
    opacity: 1;
    pointer-events: auto;
    position: relative;
    transform: scale(1);
    z-index: 10;
}

/* Settings Modal - Mic Level Bars */
.mic-bar {
    height: 100%;
    min-height: 6px;
    max-height: 24px;
    transition: height 0.08s ease-out, background-color 0.15s ease;
}

.mic-bar.active {
    background-color: #22c55e;
}

.mic-bar.high {
    background-color: #f59e0b;
}

/* Select dropdown styling */
#mic-select,
#speaker-select {
    background-image: none;
}

#mic-select:disabled,
#speaker-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
