/* ============================================================
   CLASSROOM LIVE + AI ENGLISH TUTOR  — classroom.css
   copycat / classroom one-way broadcast + English AI tutor
   ============================================================ */

/* ---- Classroom Panel (fixed left-side floating panel — board stays untouched) ---- */
.classroom-drawer {
    position: fixed;
    top: 0;
    left: -400px;
    width: 380px;
    max-width: 92vw;
    height: 100vh;
    background: var(--modal-bg, #1e1e2e);
    border-right: 1px solid var(--border-color, #333);
    box-shadow: 6px 0 32px rgba(0,0,0,0.45);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: left 0.35s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}
.classroom-drawer.open {
    left: 0;
}

/* ---- Role Badge Bar ---- */
.classroom-role-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(16,185,129,0.1));
    border-bottom: 1px solid var(--border-color, #333);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}
.role-badge.teacher {
    background: rgba(99,102,241,0.2);
    color: #818cf8;
    border: 1px solid rgba(99,102,241,0.4);
}
.role-badge.student {
    background: rgba(16,185,129,0.2);
    color: #10b981;
    border: 1px solid rgba(16,185,129,0.4);
}
.room-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ---- Sub-Tab Nav ---- */
.classroom-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 10px 14px 0;
    background: var(--modal-bg, #1e1e2e);
    border-bottom: 1px solid var(--border-color, #333);
}
.classroom-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted-text, #888);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.classroom-tab-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-color, #eee);
}
.classroom-tab-btn.active {
    background: var(--bg-color, #252535);
    color: var(--text-color, #eee);
    border-color: var(--border-color, #333);
}

/* ---- Tab Panel Content ---- */
.classroom-panel {
    display: none;
    padding: 16px 16px;
    gap: 14px;
    flex-direction: column;
    background: var(--bg-color, #252535);
    flex: 1;
    overflow-y: auto;
}
.classroom-panel.active {
    display: flex;
}

/* ---- Voice Panel ---- */
.voice-broadcast-area {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.voice-wave-ring {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(99,102,241,0.15);
    border: 2px solid rgba(99,102,241,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    position: relative;
    flex-shrink: 0;
    transition: background 0.3s;
}
.voice-wave-ring.broadcasting {
    background: rgba(99,102,241,0.3);
    border-color: #818cf8;
    animation: voiceRingPulse 0.8s ease-in-out infinite alternate;
}
@keyframes voiceRingPulse {
    from { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); }
    to   { box-shadow: 0 0 0 18px rgba(99,102,241,0); }
}
.voice-info h4 { font-size: 0.95rem; font-weight: 700; margin: 0 0 4px; }
.voice-info p  { font-size: 0.78rem; color: var(--muted-text, #888); margin: 0; }
.voice-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.student-listening-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.85rem;
    color: #10b981;
}
.sound-bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 22px;
}
.sound-bar {
    width: 4px;
    background: #10b981;
    border-radius: 2px;
    animation: soundBarAnim 0.7s ease-in-out infinite alternate;
}
.sound-bar:nth-child(1) { height: 8px;  animation-delay: 0s;    }
.sound-bar:nth-child(2) { height: 18px; animation-delay: 0.15s; }
.sound-bar:nth-child(3) { height: 12px; animation-delay: 0.3s;  }
.sound-bar:nth-child(4) { height: 20px; animation-delay: 0.1s;  }
.sound-bar:nth-child(5) { height: 6px;  animation-delay: 0.25s; }
@keyframes soundBarAnim {
    from { transform: scaleY(0.4); }
    to   { transform: scaleY(1); }
}

/* ---- Camera Panel ---- */
.camera-broadcast-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
.camera-preview-box {
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    max-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid var(--border-color, #333);
}
.camera-preview-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-preview-placeholder {
    color: #555;
    font-size: 2.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.camera-preview-placeholder span {
    font-size: 0.75rem;
    color: #666;
}
.camera-hud-badge {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
}
.camera-hud-live {
    position: absolute;
    top: 8px; right: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 900;
    letter-spacing: 0.08em;
    animation: livePulse 1s infinite;
}
.camera-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.peer-count-row {
    font-size: 0.75rem;
    color: var(--muted-text, #888);
}

/* ---- Projector Panel ---- */
.projector-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.projector-url-input {
    flex: 1;
    min-width: 200px;
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-color, #eee);
    outline: none;
}
.projector-url-input:focus {
    border-color: #818cf8;
}
.projector-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.projector-preview {
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16/9;
    max-height: 200px;
    border: 1px solid var(--border-color, #333);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 1.2rem;
}
.projector-preview iframe,
.projector-preview video {
    width: 100%;
    height: 100%;
}
.projector-status {
    font-size: 0.75rem;
    color: var(--muted-text, #888);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ---- Student Projector Overlay ---- */
#student-projector-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
#student-projector-overlay.hidden { display: none; }
#student-projector-overlay .proj-label {
    color: #818cf8;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.1em;
}
#student-projector-overlay .proj-close-btn {
    position: absolute;
    top: 16px; right: 20px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.8rem;
}
#student-projector-frame {
    width: min(90vw, 900px);
    aspect-ratio: 16/9;
    border: none;
    border-radius: 8px;
    background: #000;
}
#student-projector-video {
    width: min(90vw, 900px);
    aspect-ratio: 16/9;
    border-radius: 8px;
    background: #000;
}

/* ============================================================
   AI ENGLISH TUTOR PANEL
   ============================================================ */

/* ---- Tutor Panel Drawer ---- */
.tutor-drawer {
    position: fixed;
    top: 0; right: -420px;
    width: 420px;
    max-width: 95vw;
    height: 100vh;
    background: var(--modal-bg, #1e1e2e);
    border-left: 1px solid var(--border-color, #333);
    box-shadow: -8px 0 32px rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}
.tutor-drawer.open { right: 0; }

.tutor-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
    display: none;
}
.tutor-backdrop.visible { display: block; }

/* ---- Classroom Backdrop ---- */
.classroom-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 199;
    display: none;
}
.classroom-backdrop.visible { display: block; }

/* ---- Classroom Header (top of side panel) ---- */
.classroom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(90deg, rgba(99,102,241,0.15), rgba(16,185,129,0.1));
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}
.classroom-header h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.classroom-close-btn {
    background: none;
    border: 1px solid var(--border-color, #333);
    border-radius: 6px;
    color: var(--muted-text, #888);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 0.85rem;
    transition: color 0.15s;
}
.classroom-close-btn:hover { color: #ef4444; }


/* ---- Tutor Header ---- */
.tutor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(90deg, rgba(251,191,36,0.15), rgba(239,68,68,0.1));
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
}
.tutor-header h3 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}
.tutor-close-btn {
    background: none;
    border: 1px solid var(--border-color, #333);
    border-radius: 6px;
    color: var(--muted-text, #888);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 0.85rem;
    transition: color 0.15s;
}
.tutor-close-btn:hover { color: #ef4444; }

/* ---- Tutor Tool Tabs ---- */
.tutor-tool-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    background: var(--bg-color, #252535);
    border-bottom: 1px solid var(--border-color, #333);
    flex-shrink: 0;
    scrollbar-width: none;
}
.tutor-tool-tabs::-webkit-scrollbar { display: none; }
.tutor-tool-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-text, #888);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.tutor-tool-tab:hover { color: var(--text-color, #eee); }
.tutor-tool-tab.active {
    color: #fbbf24;
    border-bottom-color: #fbbf24;
}

/* ---- Tutor Panel Body ---- */
.tutor-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tutor-section { display: none; }
.tutor-section.active { display: flex; flex-direction: column; gap: 12px; }

/* ---- Shared Components ---- */
.tutor-textarea {
    width: 100%;
    min-height: 90px;
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.88rem;
    color: var(--text-color, #eee);
    resize: vertical;
    outline: none;
    line-height: 1.6;
    font-family: inherit;
    box-sizing: border-box;
}
.tutor-textarea:focus { border-color: #fbbf24; }
.tutor-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tutor-btn {
    padding: 8px 16px;
    border-radius: 7px;
    border: none;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}
.tutor-btn:active { transform: scale(0.97); }
.tutor-btn-primary {
    background: #fbbf24;
    color: #1a1a1a;
}
.tutor-btn-primary:hover { opacity: 0.85; }
.tutor-btn-secondary {
    background: var(--input-bg, #1a1a2a);
    color: var(--text-color, #eee);
    border: 1px solid var(--border-color, #333);
}
.tutor-btn-secondary:hover { background: rgba(255,255,255,0.05); }
.tutor-btn-danger {
    background: #ef4444;
    color: #fff;
}

/* ---- Result Cards ---- */
.tutor-result-card {
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 10px;
    padding: 14px;
    font-size: 0.85rem;
    line-height: 1.7;
}
.tutor-result-card .result-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-text, #888);
    margin-bottom: 6px;
}

/* ---- Grammar / Spelling Error Highlights ---- */
.spell-error {
    background: rgba(239,68,68,0.18);
    border-bottom: 2px wavy #ef4444;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}
.grammar-error {
    background: rgba(251,191,36,0.15);
    border-bottom: 2px wavy #fbbf24;
    border-radius: 2px;
    cursor: pointer;
}
.error-popover {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #1e1e2e;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.78rem;
    min-width: 200px;
    max-width: 280px;
    z-index: 300;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    line-height: 1.5;
    color: var(--text-color, #eee);
}
.error-popover .pop-fix {
    color: #22c55e;
    font-weight: 700;
    margin-top: 4px;
    font-size: 0.82rem;
}

/* ---- Highlighted Check Output ---- */
.grammar-output-area {
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.88rem;
    line-height: 1.8;
    min-height: 70px;
    color: var(--text-color, #eee);
    word-break: break-word;
}
.grammar-issues-list { display: flex; flex-direction: column; gap: 6px; }
.grammar-issue-item {
    background: rgba(251,191,36,0.08);
    border-left: 3px solid #fbbf24;
    border-radius: 0 6px 6px 0;
    padding: 8px 10px;
    font-size: 0.8rem;
    line-height: 1.5;
}
.grammar-issue-item .issue-rule {
    font-weight: 700;
    color: #fbbf24;
    font-size: 0.75rem;
    margin-bottom: 2px;
}
.grammar-issue-item .issue-fix {
    color: #22c55e;
}

/* ---- Reading Helper ---- */
.reading-text-area {
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 14px;
    font-size: 1rem;
    line-height: 2;
    min-height: 100px;
    color: var(--text-color, #eee);
    word-break: break-word;
}
.reading-word {
    display: inline-block;
    cursor: pointer;
    border-radius: 3px;
    padding: 1px 2px;
    transition: background 0.1s;
}
.reading-word:hover { background: rgba(251,191,36,0.15); }
.reading-word.active-word {
    background: #fbbf24;
    color: #1a1a1a;
    border-radius: 3px;
}
.reading-controls { display: flex; gap: 8px; align-items: center; }
.reading-speed-label { font-size: 0.75rem; color: var(--muted-text, #888); }

/* ---- Pronunciation Coach ---- */
.pronun-word-display {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(251,191,36,0.1));
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}
.pronun-word-big {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin: 0 0 4px;
}
.pronun-phonetic {
    font-size: 0.85rem;
    color: #818cf8;
    font-style: italic;
}
.pronun-score-bar {
    height: 10px;
    background: var(--border-color, #333);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 10px;
}
.pronun-score-fill {
    height: 100%;
    border-radius: 5px;
    background: linear-gradient(90deg, #ef4444, #fbbf24, #22c55e);
    transition: width 0.6s ease;
}
.pronun-score-label {
    font-size: 1.5rem;
    font-weight: 900;
    text-align: center;
    margin-top: 6px;
}
.pronun-feedback {
    font-size: 0.82rem;
    color: var(--muted-text, #888);
    text-align: center;
    margin-top: 4px;
}

/* ---- Word of the Day ---- */
.wotd-card {
    background: linear-gradient(135deg, rgba(251,191,36,0.12), rgba(239,68,68,0.08));
    border: 1px solid rgba(251,191,36,0.25);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.wotd-word {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #fbbf24;
}
.wotd-pos {
    font-size: 0.75rem;
    color: var(--muted-text, #888);
    font-style: italic;
}
.wotd-definition {
    font-size: 0.88rem;
    line-height: 1.6;
}
.wotd-example {
    font-size: 0.82rem;
    color: var(--muted-text, #888);
    border-left: 3px solid #fbbf24;
    padding-left: 10px;
    font-style: italic;
    margin-top: 4px;
}

/* ---- Exercises ---- */
.exercise-card {
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.exercise-type-badge {
    display: inline-block;
    background: rgba(99,102,241,0.2);
    color: #818cf8;
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    width: fit-content;
}
.exercise-question {
    font-size: 0.9rem;
    line-height: 1.6;
    font-weight: 600;
}
.exercise-input {
    background: var(--modal-bg, #1e1e2e);
    border: 1px solid var(--border-color, #333);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-color, #eee);
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.exercise-input:focus { border-color: #818cf8; }
.exercise-feedback {
    font-size: 0.8rem;
    border-radius: 6px;
    padding: 6px 10px;
    display: none;
}
.exercise-feedback.correct {
    background: rgba(34,197,94,0.15);
    border: 1px solid rgba(34,197,94,0.3);
    color: #22c55e;
    display: block;
}
.exercise-feedback.wrong {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #ef4444;
    display: block;
}

/* ---- Sentence Builder ---- */
.sentence-rule-box {
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.82rem;
    line-height: 1.6;
}
.sentence-rule-box .rule-title {
    font-weight: 800;
    color: #818cf8;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

/* ---- Score / Stats Bar ---- */
.tutor-score-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--input-bg, #1a1a2a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
}
.score-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-value { font-size: 1.1rem; font-weight: 900; }
.score-label { font-size: 0.65rem; color: var(--muted-text, #888); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Classroom CTA Buttons in toolbar ---- */
.tool-btn-classroom {
    color: #818cf8 !important;
    font-weight: 700 !important;
}
.tool-btn-tutor {
    color: #fbbf24 !important;
    font-weight: 700 !important;
}

/* ---- Connection Status Pill ---- */
.classroom-conn-pill {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.classroom-conn-pill.connected {
    background: rgba(34,197,94,0.15);
    color: #22c55e;
    border: 1px solid rgba(34,197,94,0.3);
}
.classroom-conn-pill.connecting {
    background: rgba(251,191,36,0.15);
    color: #fbbf24;
    border: 1px solid rgba(251,191,36,0.3);
}
.classroom-conn-pill.disconnected {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.3);
}

/* ---- Scrollbar styling ---- */
.tutor-panel-body::-webkit-scrollbar,
.classroom-panel::-webkit-scrollbar { width: 4px; }
.tutor-panel-body::-webkit-scrollbar-thumb,
.classroom-panel::-webkit-scrollbar-thumb {
    background: var(--border-color, #333);
    border-radius: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .tutor-drawer { width: 100vw; }
    .classroom-drawer.open { max-height: 600px; }
    .voice-broadcast-area { flex-direction: column; align-items: flex-start; }
}
