/**
 * ============================================================================
 * THE HIGHTOWER SCHOOL OF DIGITAL ARTS & APPLIED SCIENCES
 * Component: 32% Sidecar Container & Cosmic ClassChat Stylesheet (v9.15.00)
 * Theme: Deep-Space Cosmic Obsidian, Neon Cyan & Nebula Indigo
 * Features:
 *   - Perfectly Centered Xiaoli's Backpack Header Tray
 *   - Distinct Separated Styles for "Progress" and "Switch Class" Tabs
 *   - Vocab Playback Loading & Speaking Status Indicators (Matching ClassChat)
 *   - Structured 4-Card Layout: Lesson Topics, Key Terms, Strong Points, Review
 *   - Uniform 1.5px Border Width with 3px Left Accent Glow Line
 * Target Devices: iPad (9th Gen), Samsung Galaxy Tab A9+, Surface Pro
 * File: css/sidecar.css
 * ============================================================================
 */

/* ==========================================================================
   1. MASTER SIDECAR CONTAINER (32% RIGHT RAIL)
   ========================================================================== */
#sidecar-panel,
.sidecar-chat-panel {
    flex: 0 0 32% !important;
    width: 32% !important;
    max-width: 32% !important;
    height: 100% !important;
    min-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background-color: #090d16 !important;
    border-left: 2px solid rgba(255, 255, 255, 0.08) !important;
    position: relative !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    z-index: 50 !important;
}

[data-theme="day"] #sidecar-panel {
    background-color: #f1f5f9 !important;
    border-left-color: #cbd5e1 !important;
}

/* ==========================================================================
   2. XIAOLI'S BACKPACK TRAY (CENTERED HEADER & SUBJECT METERS)
   ========================================================================== */
#xiaoli-backpack-tray {
    width: 100% !important;
    background: #0d1322 !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.08) !important;
    padding: 10px !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    z-index: 20 !important;
}

[data-theme="day"] #xiaoli-backpack-tray {
    background: #ffffff !important;
    border-bottom-color: #cbd5e1 !important;
}

.backpack-title-row {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 8px !important;
    text-align: center !important;
    width: 100% !important;
}

.backpack-open-trigger {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.backpack-open-trigger:hover {
    background: rgba(56, 189, 248, 0.12);
}

.backpack-brand-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #e2e8f0;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.backpack-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 5px !important;
    width: 100% !important;
}

.bp-subject-card {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    outline: none;
    touch-action: manipulation;
}

.bp-subject-card:active {
    transform: scale(0.97);
}

.bp-subject-card.active-active-track {
    border-color: #38bdf8 !important;
    outline: 2px solid #38bdf8 !important;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.75) !important;
    transform: scale(1.02);
}

.bp-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    color: #ffffff;
    font-family: 'Fredoka', cursive;
    font-size: 0.74rem;
    font-weight: 600;
}

.bp-icon { font-size: 0.8rem; }
.bp-name { flex: 1; margin-left: 5px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-percent { font-family: 'JetBrains Mono', monospace; font-size: 0.65rem; opacity: 0.85; }

.bp-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
    overflow: hidden;
}

.bp-progress-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.bp-subject-card.science { background: linear-gradient(135deg, #0284c7, #0369a1); border-color: #38bdf8; }
.bp-subject-card.math { background: linear-gradient(135deg, #2563eb, #1d4ed8); border-color: #60a5fa; }
.bp-subject-card.reading { background: linear-gradient(135deg, #7c3aed, #6d28d9); border-color: #a78bfa; }
.bp-subject-card.language { background: linear-gradient(135deg, #0891b2, #0e7490); border-color: #22d3ee; }
.bp-subject-card.social-studies { background: linear-gradient(135deg, #d97706, #b45309); border-color: #fbbf24; }
.bp-subject-card.world-languages { background: linear-gradient(135deg, #4f46e5, #4338ca); border-color: #818cf8; }
.bp-subject-card.life-skills { background: linear-gradient(135deg, #e11d48, #be123c); border-color: #fb7185; }
.bp-subject-card.music-arts { background: linear-gradient(135deg, #c026d3, #9333ea); border-color: #f472b6; }

/* ==========================================================================
   3. CLASSCHAT ROSTER & LIVE ACTIVITY STATUS PILLS
   ========================================================================== */
#chat-container {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    background-color: #090d16 !important;
}

.sidecar-roster-header {
    background: #0b1120 !important;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.08) !important;
    padding: 8px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    gap: 8px;
    flex-wrap: wrap;
    box-sizing: border-box;
}

.roster-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.roster-badge {
    font-family: 'Fredoka', cursive;
    font-size: 0.74rem;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 0.5px;
}

.live-telemetry-heartbeat {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 6px #38bdf8;
    transition: all 0.3s ease;
}

.live-telemetry-heartbeat.active-speaking {
    background: #00f0ff;
    box-shadow: 0 0 12px #00f0ff, 0 0 20px #8a2be2;
    animation: activeCosmicPulsar 1.2s infinite ease-in-out;
}

@keyframes activeCosmicPulsar {
    0% { transform: scale(0.9); opacity: 0.7; background: #00f0ff; }
    50% { transform: scale(1.3); opacity: 1; background: #c084fc; }
    100% { transform: scale(0.9); opacity: 0.7; background: #00f0ff; }
}

.classchat-activity-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Fredoka', cursive;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.classchat-activity-pill.status-thinking {
    background: rgba(139, 92, 246, 0.22);
    border: 1px solid #c084fc;
    color: #e9d5ff;
}

.classchat-activity-pill.status-loading {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid #fbbf24;
    color: #fde68a;
}

.classchat-activity-pill.status-speaking {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #34d399;
    color: #6ee7b7;
}

.mini-dot-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c084fc;
    animation: activeCosmicPulsar 1s infinite ease-in-out;
}

.chat-thinking-bubble {
    align-self: flex-start;
    background: #0f1526;
    border: 1.5px solid rgba(56, 189, 248, 0.45);
    border-left: 3px solid #38bdf8;
    border-radius: 14px;
    border-bottom-left-radius: 2px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.2);
    animation: cardCosmicFloat 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-label {
    font-family: 'Fredoka', cursive;
    font-size: 0.78rem;
    color: #bae6fd;
}

.thinking-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fbbf24;
    animation: thinkingBounce 1.1s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.18s; background: #38bdf8; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; background: #f472b6; }

@keyframes thinkingBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-5px); opacity: 1; }
}

.roster-avatars {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.avatar-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #1e293b;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.teacher-dot { background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.student-dot { background: #38bdf8; box-shadow: 0 0 6px rgba(56, 189, 248, 0.6); }
.peer-dot.zoey { background: #ec4899; box-shadow: 0 0 6px rgba(236, 72, 153, 0.6); }
.peer-dot.finley { background: #818cf8; box-shadow: 0 0 6px rgba(129, 140, 248, 0.6); }

/* ==========================================================================
   4. CHAT STREAM FEED & UNIFORM BUBBLE CARDS
   ========================================================================== */
.chat-stream-feed {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 12px 14px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    scroll-behavior: smooth;
    box-sizing: border-box !important;
}

.chat-turn-card {
    display: flex;
    flex-direction: column;
    max-width: 92%;
    animation: cardCosmicFloat 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardCosmicFloat {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-turn-card.role-student { align-self: flex-end; }
.chat-turn-card.role-teacher,
.chat-turn-card.role-peer { align-self: flex-start; }

.card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.chat-turn-card.role-student .card-meta { justify-content: flex-end; }

.speaker-tag {
    font-family: 'Fredoka', cursive;
    font-size: 0.68rem;
    font-weight: 700;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 8px;
}

.turn-timestamp {
    font-size: 0.65rem;
    color: #64748b;
    font-family: 'JetBrains Mono', monospace;
}

.card-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.83rem;
    line-height: 1.55;
    word-break: break-word;
    box-sizing: border-box;
}

.chat-turn-card.role-student .card-bubble {
    background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
    color: #ffffff !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    border-left: 3px solid #38bdf8 !important;
    box-shadow: 0 4px 18px rgba(56, 189, 248, 0.25) !important;
    border-bottom-right-radius: 2px;
}

.chat-turn-card.role-teacher .card-bubble {
    background: #0f1526 !important;
    color: #f8fafc !important;
    border: 1.5px solid rgba(245, 158, 11, 0.45) !important;
    border-left: 3px solid #fbbf24 !important;
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.25) !important;
    border-bottom-left-radius: 2px;
}

.chat-turn-card.role-peer.speaker-zoey .card-bubble {
    background: #141124 !important;
    color: #fce7f3 !important;
    border: 1.5px solid rgba(244, 114, 182, 0.45) !important;
    border-left: 3px solid #f472b6 !important;
    box-shadow: 0 4px 18px rgba(244, 114, 182, 0.25) !important;
    border-bottom-left-radius: 2px;
}

.chat-turn-card.role-peer.speaker-finley .card-bubble {
    background: #101426 !important;
    color: #e0e7ff !important;
    border: 1.5px solid rgba(129, 140, 248, 0.45) !important;
    border-left: 3px solid #818cf8 !important;
    box-shadow: 0 4px 18px rgba(129, 140, 248, 0.25) !important;
    border-bottom-left-radius: 2px;
}

.chat-turn-card.role-peer:not(.speaker-zoey):not(.speaker-finley) .card-bubble {
    background: #101426 !important;
    color: #f8fafc !important;
    border: 1.5px solid rgba(56, 189, 248, 0.45) !important;
    border-left: 3px solid #38bdf8 !important;
    box-shadow: 0 4px 18px rgba(56, 189, 248, 0.25) !important;
    border-bottom-left-radius: 2px;
}

/* ==========================================================================
   5. TALK-AND-TEXT INPUT DOCK
   ========================================================================== */
.chat-input-bar {
    width: 100% !important;
    background: #090d16 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 8px 10px !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

.talk-text-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 4px 6px;
    box-sizing: border-box;
}

.talk-text-wrapper:focus-within {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.chat-hand-raise-action {
    background: rgba(245, 158, 11, 0.2);
    border: 1.5px solid #fbbf24;
    color: #fbbf24;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: transform 0.12s ease, background 0.15s ease;
}

.chat-hand-raise-action:hover {
    background: #fbbf24;
    color: #000000;
    transform: scale(1.08);
}

.chat-mic-action {
    background: #0284c7;
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: transform 0.12s ease;
}

.btn-continue-lesson {
    background: linear-gradient(135deg, #8a2be2, #4f46e5);
    border: 1px solid #c084fc;
    color: #ffffff;
    font-family: 'Fredoka', cursive;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.35);
    flex-shrink: 0;
    transition: transform 0.12s ease;
}

.talk-text-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #f8fafc;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.82rem;
    padding: 4px 2px;
    min-width: 60px;
}

.talk-text-input::placeholder { color: #64748b; }

.chat-send-action {
    background: #2563eb;
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ==========================================================================
   6. VOCAB PLAYBACK STATUS INDICATORS (CARD-LEVEL & TRAY-LEVEL FEEDBACK)
   ========================================================================== */
.vocab-audio-indicator-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Fredoka', cursive;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.vocab-audio-indicator-pill.loading {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid #fbbf24;
    color: #fde68a;
    animation: pulseVocabStatus 1.2s infinite ease-in-out;
}

.vocab-audio-indicator-pill.speaking {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #34d399;
    color: #6ee7b7;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

@keyframes pulseVocabStatus {
    0%, 100% { opacity: 0.75; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.02); }
}

.btn-bp-speak.is-loading {
    background: #d97706 !important;
    border: 1.5px solid #fbbf24 !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6) !important;
}

.btn-bp-speak.is-speaking {
    background: #059669 !important;
    border: 1.5px solid #34d399 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.65) !important;
}

/* ==========================================================================
   7. STRUCTURED 4-CARD NOTES: TOPICS, TERMS, STRONG POINTS & REVIEW
   ========================================================================== */
.notes-structured-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.notes-card {
    background: #090d16;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-sizing: border-box;
}

.notes-card-topics {
    border: 1.5px solid rgba(56, 189, 248, 0.45);
    border-left: 4px solid #38bdf8;
}

.notes-card-terms {
    border: 1.5px solid rgba(192, 132, 252, 0.45);
    border-left: 4px solid #c084fc;
}

.notes-card-strong {
    background: rgba(16, 185, 129, 0.08);
    border: 1.5px solid #10b981;
    border-left: 4px solid #10b981;
}

.notes-card-review {
    background: rgba(245, 158, 11, 0.08);
    border: 1.5px solid #fbbf24;
    border-left: 4px solid #fbbf24;
}

.notes-card-title {
    font-family: 'Fredoka', cursive;
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}