/* ═══════════════════════════════════════════════════════
   AI Tutor Panel — Reusable across LLOS.ai experiences
   Drop-in: <link href="/llos/common/tutor/tutor.css">
   ═══════════════════════════════════════════════════════ */

/* ── Overlay ── */
.tutor-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #f8fafc;
    display: grid;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.tutor-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Desktop: side-by-side ── */
@media (min-width: 768px) {
    .tutor-overlay {
        grid-template-columns: 2fr 3fr;
        grid-template-rows: 56px 1fr 64px;
    }

    .tutor-toolbar {
        grid-column: 1 / -1;
    }

    .tutor-controls {
        grid-column: 1 / -1;
    }
}

/* ── Mobile: stacked ── */
@media (max-width: 767px) {
    .tutor-overlay {
        grid-template-columns: 1fr;
        grid-template-rows: 48px 35% 1fr 56px;
    }
}

/* ── Toolbar ── */
.tutor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    z-index: 1;
}

.tutor-toolbar-title {
    font-weight: 700;
    font-size: 14px;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    text-align: center;
    flex: 1;
}

.tutor-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 16px;
    flex-shrink: 0;
}

.tutor-btn-icon:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* ── Avatar Zone — fixed internal layout, nothing content-dependent ── */
.tutor-avatar-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;   /* anchor from top, not center */
    padding: 20px 20px 16px;
    overflow: hidden;              /* fully isolate from right panel */
    background: linear-gradient(180deg, #fff7ed 0%, #f8fafc 100%);
    position: relative;
}

/* Avatar: fixed size per breakpoint — no flex-grow, no content influence */
.tutor-avatar-wrap {
    position: relative;
    width: 150px;
    height: 190px;
    flex-shrink: 0;
    flex-grow: 0;
}

@media (min-width: 768px) {
    .tutor-avatar-zone { padding: 24px 20px 20px; }
    .tutor-avatar-wrap {
        width: 200px;
        height: 250px;
    }
}

@media (min-width: 1024px) {
    .tutor-avatar-wrap {
        width: 240px;
        height: 300px;
    }
}

/* ── SVG Avatar — no filters, no transitions, no animations on container ── */
.tutor-svg-avatar {
    width: 100%;
    height: 100%;
}

/* Eyelid blink — only ry changes, gentle transition */
.tutor-eyelid-l,
.tutor-eyelid-r {
    transition: ry 0.1s ease;
}

/* Name + mood labels — fixed spacing */
.tutor-avatar-label {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-align: center;
    flex-shrink: 0;
}

.tutor-avatar-mood {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 2px;
    flex-shrink: 0;
}

/* ── Waveform — dedicated region, fixed height, never cut ── */
.tutor-waveform {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 40px;              /* fixed slot — bars live inside this */
    margin-top: 16px;
    padding: 0 32px 8px;       /* horizontal + bottom breathing room */
    opacity: 0;
    transition: opacity 0.3s;
    flex-shrink: 0;
    flex-grow: 0;
}

.tutor-waveform.active {
    opacity: 1;
}

.tutor-wave-bar {
    width: 4px;
    max-height: 28px;          /* bars can't exceed their region */
    background: #fb923c;
    border-radius: 2px;
    transition: height 0.1s ease;
    height: 4px;
}

/* ── Text Zone — fully isolated, own scroll context ── */
.tutor-text-zone {
    overflow-y: auto;
    overflow-x: hidden;           /* prevent horizontal influence */
    padding: 24px 20px;
    scrollbar-gutter: stable;
    scroll-behavior: smooth;
    contain: layout style;        /* CSS containment — isolate from siblings */
}

@media (min-width: 768px) {
    .tutor-text-zone {
        padding: 32px 40px;
        border-left: 1px solid #e2e8f0;
    }
}

.tutor-text-zone::-webkit-scrollbar {
    width: 4px;
}

.tutor-text-zone::-webkit-scrollbar-track {
    background: transparent;
}

.tutor-text-zone::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* ── Content cards inside text zone ── */
.tutor-content-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: #94a3b8;
    margin-bottom: 8px;
}

.tutor-phrase-card {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.tutor-phrase-text {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.3;
}

@media (max-width: 767px) {
    .tutor-phrase-text {
        font-size: 18px;
    }
}

.tutor-answer-area {
    line-height: 1.8;
    font-size: 16px;
    color: #334155;
    min-height: 60px;
}

@media (max-width: 767px) {
    .tutor-answer-area {
        font-size: 15px;
    }
}

/* ── Word-by-word reveal ── */
.tutor-word {
    display: inline;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tutor-word.spoken {
    opacity: 1;
}

.tutor-word.current {
    opacity: 1;
    background: #fff7ed;
    color: #c2410c;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}

/* ── Meaning section (after explanation) ── */
.tutor-meaning-block {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tutor-meaning-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.tutor-meaning-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
    color: #94a3b8;
    margin-bottom: 6px;
}

.tutor-meaning-text {
    font-size: 15px;
    color: #475569;
    font-style: italic;
    line-height: 1.6;
    border-left: 3px solid #fb923c;
    padding-left: 12px;
}

/* ── Extra info pills ── */
.tutor-meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.4s ease 0.2s;
}

.tutor-meta-pills.visible {
    opacity: 1;
}

.tutor-pill {
    font-size: 11px;
    background: #f1f5f9;
    color: #475569;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-weight: 500;
}

.tutor-pill-label {
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.05em;
    margin-right: 4px;
}

/* ── Controls Bar ── */
.tutor-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.tutor-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: white;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 16px;
}

.tutor-ctrl-btn:hover {
    border-color: #fb923c;
    color: #c2410c;
    background: #fff7ed;
}

.tutor-ctrl-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tutor-ctrl-play {
    width: 52px;
    height: 52px;
    background: #fb923c;
    border-color: #fb923c;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(251, 146, 60, 0.3);
}

.tutor-ctrl-play:hover {
    background: #ea580c;
    border-color: #ea580c;
    color: white;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.4);
}

/* ── Speed selector ── */
.tutor-speed-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.tutor-speed-btn {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}

.tutor-speed-btn.active {
    background: #fff7ed;
    border-color: #fb923c;
    color: #c2410c;
}

.tutor-speed-btn:hover {
    border-color: #fb923c;
}

/* ── Progress indicator ── */
.tutor-progress {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    margin-right: 8px;
    white-space: nowrap;
}

/* ── Settings dropdown ── */
.tutor-settings-panel {
    position: absolute;
    top: 56px;
    right: 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: none;
    min-width: 220px;
}

@media (max-width: 767px) {
    .tutor-settings-panel {
        top: 48px;
        right: 8px;
        left: 8px;
        min-width: auto;
    }
}

.tutor-settings-panel.open {
    display: block;
}

.tutor-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.tutor-setting-row + .tutor-setting-row {
    border-top: 1px solid #f1f5f9;
}

.tutor-setting-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.tutor-setting-select {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
}

/* ── FAB trigger button (placed by host page) ── */
.tutor-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: white;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.tutor-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.4);
}

.tutor-fab.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

/* ── No-speech fallback message ── */
.tutor-no-speech {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 14px;
}

.tutor-no-speech i {
    font-size: 32px;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

/* ── Completion state ── */
.tutor-complete {
    text-align: center;
    padding: 32px 20px;
}

.tutor-complete-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.tutor-complete-title {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 4px;
}

.tutor-complete-sub {
    font-size: 13px;
    color: #64748b;
}
