/**
 * Audio-Only Quran Reading Class System Styles
 * 
 * Design Philosophy:
 * - Islamic-inspired color palette (green, gold, earth tones)
 * - Mobile-first, minimal UI
 * - Clean, accessible components
 * - Calming, focused aesthetic for learning
 */

/* ========================================
   CSS Custom Properties (Design Tokens)
   ======================================== */
:root {
    /* Primary Colors - Islamic Green Palette */
    --primary-50: #f0fdf4;
    --primary-100: #dcfce7;
    --primary-200: #bbf7d0;
    --primary-300: #86efac;
    --primary-400: #4ade80;
    --primary-500: #22c55e;
    --primary-600: #16a34a;
    --primary-700: #15803d;
    --primary-800: #166534;
    --primary-900: #14532d;

    /* Accent Colors - Gold */
    --accent-400: #facc15;
    --accent-500: #eab308;
    --accent-600: #ca8a04;

    /* Neutral Colors */
    --neutral-50: #fafafa;
    --neutral-100: #f5f5f5;
    --neutral-200: #e5e5e5;
    --neutral-300: #d4d4d4;
    --neutral-400: #a3a3a3;
    --neutral-500: #737373;
    --neutral-600: #525252;
    --neutral-700: #404040;
    --neutral-800: #262626;
    --neutral-900: #171717;

    /* Status Colors */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Semantic Colors */
    --bg-primary: #ffffff;
    --bg-secondary: var(--neutral-50);
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --border-color: var(--neutral-200);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Typography */
    --font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
}

/* ========================================
   CSS Reset & Base Styles
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-50) 0%, var(--neutral-50) 100%);
    min-height: 100vh;
}

/* ========================================
   Layout Components
   ======================================== */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: var(--space-4);
}

.card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
}

.hidden {
    display: none !important;
}

/* ========================================
   Header & Branding
   ======================================== */
.header {
    text-align: center;
    padding: var(--space-8) var(--space-4);
}

.logo {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--primary-700);
    margin-bottom: var(--space-2);
}

.logo-arabic {
    font-family: var(--font-arabic);
    font-size: var(--font-size-2xl);
    color: var(--accent-600);
    display: block;
    margin-bottom: var(--space-2);
}

.tagline {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ========================================
   Forms & Inputs
   ======================================== */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-base);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.form-input::placeholder {
    color: var(--neutral-400);
}

/* Role Selection */
.role-selector {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.role-option {
    flex: 1;
    position: relative;
}

.role-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.role-option label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-4);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.role-option input:checked+label {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

.role-option label:hover {
    border-color: var(--primary-400);
}

.role-icon {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-2);
}

.role-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    color: var(--text-primary);
    background: var(--neutral-100);
}

.btn-secondary:hover {
    background: var(--neutral-200);
}

.btn-danger {
    color: #fff;
    background: var(--error);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   Audio Control Buttons
   ======================================== */
.audio-controls {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-6);
}

.audio-btn {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    border: none;
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn-mute {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.audio-btn-mute.muted {
    background: var(--neutral-400);
    box-shadow: none;
}

.audio-btn-mute:hover {
    transform: scale(1.05);
}

.audio-btn-end {
    background: linear-gradient(135deg, var(--error) 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.audio-btn-end:hover {
    transform: scale(1.05);
}

/* ========================================
   Status Indicators
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
}

.status-live {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.status-live::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: var(--radius-full);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.status-connected {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-muted {
    background: rgba(163, 163, 163, 0.2);
    color: var(--neutral-600);
}

/* ========================================
   Student List
   ======================================== */
.student-list {
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
}

.student-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.student-list-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.student-count {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: var(--neutral-100);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

.student-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-2);
}

.student-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.student-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-100);
    color: var(--primary-700);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.student-name {
    font-weight: 500;
    color: var(--text-primary);
}

.student-status {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.allow-speak-btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    background: var(--neutral-200);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.allow-speak-btn:hover {
    background: var(--primary-100);
    color: var(--primary-700);
}

.allow-speak-btn.speaking {
    background: var(--primary-500);
    color: #fff;
}

/* ========================================
   Room/Class Cards
   ======================================== */
.room-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    transition: all var(--transition-fast);
}

.room-card:hover {
    border-color: var(--primary-400);
    box-shadow: var(--shadow-sm);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
}

.room-title {
    font-weight: 600;
    color: var(--text-primary);
}

.room-teacher {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

/* ========================================
   Alerts & Messages
   ======================================== */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========================================
   Loading States
   ======================================== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--neutral-200);
    border-top-color: var(--primary-500);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: var(--space-4);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* ========================================
   Live Class View
   ======================================== */
.live-class-header {
    text-align: center;
    padding: var(--space-4);
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
    color: #fff;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin: calc(var(--space-6) * -1);
    margin-bottom: var(--space-4);
}

.live-class-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.live-class-subtitle {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

/* Audio Visualization */
.audio-visualizer {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    height: 60px;
    padding: var(--space-4);
}

.audio-bar {
    width: 6px;
    background: var(--primary-400);
    border-radius: 3px;
    animation: audioWave 0.5s ease-in-out infinite alternate;
}

.audio-bar:nth-child(1) {
    animation-delay: 0s;
    height: 20px;
}

.audio-bar:nth-child(2) {
    animation-delay: 0.1s;
    height: 35px;
}

.audio-bar:nth-child(3) {
    animation-delay: 0.2s;
    height: 50px;
}

.audio-bar:nth-child(4) {
    animation-delay: 0.3s;
    height: 35px;
}

.audio-bar:nth-child(5) {
    animation-delay: 0.4s;
    height: 20px;
}

@keyframes audioWave {
    from {
        transform: scaleY(0.5);
    }

    to {
        transform: scaleY(1);
    }
}

.audio-visualizer.paused .audio-bar {
    animation: none;
    height: 10px;
    background: var(--neutral-300);
}

/* ========================================
   Navigation & Tabs
   ======================================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-4);
}

.tab {
    flex: 1;
    padding: var(--space-3);
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

.tab:hover {
    color: var(--primary-500);
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--neutral-50);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}

.user-details {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-500);
    color: #fff;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-lg);
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-role {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-transform: capitalize;
}

.logout-btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: var(--error);
    color: #fff;
}

/* ========================================
   Empty States
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-text {
    font-size: var(--font-size-sm);
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (min-width: 768px) {
    .container {
        max-width: 560px;
    }

    .audio-btn {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
}

/* ========================================
   Permission Overlay
   ======================================== */
.permission-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.permission-modal {
    background: var(--bg-primary);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 340px;
    margin: var(--space-4);
}

.permission-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
}

.permission-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.permission-text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-6);
}

/* ========================================
   Google Sign-In Button
   ======================================== */
.btn-google {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    font-weight: 500;
}

.btn-google:hover {
    background: var(--neutral-50);
    border-color: var(--neutral-300);
}

.btn-google svg {
    flex-shrink: 0;
}

/* ========================================
   Divider
   ======================================== */
.divider {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: var(--space-5) 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-transform: lowercase;
}

/* ========================================
   Modal Overlay
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
}

.modal {
    background: var(--bg-primary);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Role Selection Buttons (for Modal)
   ======================================== */
.role-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--neutral-50);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.role-btn:hover {
    border-color: var(--primary-500);
    background: var(--primary-50);
}

.role-btn .role-icon {
    font-size: 2.5rem;
}

.role-btn .role-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.role-btn .role-desc {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}