/* ============================================================
   CHAPTER PAGE — Header + Tabs + Panels + AI Teacher
   Usage: Unit-X/Chapter-name/index.php
   ============================================================ */

/* ============ CHAPTER HEADER ============ */
.ch-header {
    background: linear-gradient(135deg, #073b66, #0f766e);
    color: #fff;
    padding: 28px 26px;
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.ch-header-meta {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 0.85;
    margin-bottom: 6px;
    position: relative;
    z-index: 2;
}

.ch-header h1 {
    font-size: 26px;
    font-weight: 900;
    margin: 0 0 8px;
    color: #fff;
    position: relative;
    z-index: 2;
    line-height: 1.3;
}

.ch-header-sub {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.ch-tag {
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.25);
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 700;
}

/* ============ TABS ============ */
.ch-tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}

.ch-tabs::-webkit-scrollbar { display: none; }

.ch-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.ch-tab-btn:hover {
    background: #f1f5f9;
    color: #1e40af;
}

.ch-tab-btn.active {
    background: linear-gradient(135deg, #1e40af, #0f766e);
    color: #fff;
    box-shadow: 0 4px 12px rgba(30,64,175,0.25);
}

/* ============ PANELS ============ */
.ch-panel {
    display: none;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 26px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
    margin-bottom: 24px;
}

.ch-panel.active { display: block; }

.ch-panel h2 {
    font-size: 18px;
    font-weight: 900;
    color: #0f172a;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f1f5f9;
}

.ch-panel p {
    font-size: 15px;
    line-height: 1.8;
    color: #334155;
    margin: 0 0 14px;
}

/* ============ SOLUTIONS ============ */
.sol-item {
    padding: 18px;
    background: #f8fafc;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    margin-bottom: 14px;
}

.sol-item:last-child { margin-bottom: 0; }

.sol-q {
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
}

.sol-q-num { color: #2563eb; flex-shrink: 0; }

.sol-a {
    font-size: 14px;
    color: #475569;
    line-height: 1.7;
    padding-left: 24px;
}

/* ============ IMPORTANT QUESTIONS ============ */
.iq-item {
    padding: 16px;
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    margin-bottom: 12px;
}

.iq-q {
    font-size: 14px;
    font-weight: 800;
    color: #78350f;
    margin-bottom: 6px;
}

.iq-a {
    font-size: 13.5px;
    color: #64748b;
    line-height: 1.7;
}

/* ============ AI TEACHER ============ */
.ai-teach-box {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    border-radius: 14px;
    color: #fff;
}

.ai-teach-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #f0f9ff;
    border: 4px solid #fff;
    margin: 0 auto 16px;
    display: block;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.ai-teach-box h3 {
    font-size: 18px;
    font-weight: 900;
    margin: 0 0 6px;
    color: #fff;
}

.ai-teach-box p {
    font-size: 13px;
    opacity: 0.9;
    margin: 0 0 20px;
    color: #fff;
}

.ai-teach-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.ai-btn {
    padding: 12px 24px;
    border-radius: 50px;
    border: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-btn-play {
    background: #fff;
    color: #7c3aed;
}

.ai-btn-play:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255,255,255,0.3);
}

.ai-btn-stop {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}

.ai-btn-stop:hover {
    background: rgba(255,255,255,0.25);
}

/* ============ BOTTOM NAV ============ */
.ch-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.ch-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    color: #0f172a;
    font-weight: 700;
    font-size: 13.5px;
    transition: all 0.2s;
    flex: 1;
    min-width: 200px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.04);
}

.ch-nav-btn:hover {
    border-color: #1e40af;
    color: #1e40af;
    box-shadow: 0 8px 18px rgba(30,64,175,0.10);
    transform: translateY(-2px);
}

.ch-nav-btn.next { justify-content: flex-end; text-align: right; }
.ch-nav-btn.disabled { opacity: 0.4; pointer-events: none; }

.ch-nav-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    color: #94a3b8;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    .ch-header { padding: 22px 18px; }
    .ch-header h1 { font-size: 20px; }
    .ch-tab-btn { padding: 9px 14px; font-size: 12.5px; }
    .ch-panel { padding: 18px; }
    .ch-panel h2 { font-size: 16px; }
    .ch-panel p { font-size: 14px; }
    .ch-nav-btn { min-width: 0; padding: 12px 14px; font-size: 12.5px; }
}
/* ============================================================
   FULL-SCREEN TEACHING MODE
   ============================================================ */
.teach-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #0a1628 0%, #1a2f4a 50%, #0f2942 100%);
    z-index: 999999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    color: #fff;
}
.teach-screen.active { display: flex; }

/* Progress bar top */
.ts-progress {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: rgba(255,255,255,0.08);
    z-index: 10;
}
.ts-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    transition: width 0.4s ease;
    box-shadow: 0 0 12px rgba(245,158,11,0.5);
}

/* Top bar */
.ts-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    z-index: 5;
    flex-shrink: 0;
}
.ts-topic {
    font-size: 14px;
    font-weight: 800;
    color: #fbbf24;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.ts-close {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.ts-close:hover { background: #dc2626; border-color: #dc2626; }

/* Main stage */
.ts-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    position: relative;
    overflow: hidden;
}

/* Background past text (faded, scrolling up) */
.ts-bg-history {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    font-size: 14px;
    color: rgba(255,255,255,0.06);
    text-align: center;
    line-height: 1.6;
    pointer-events: none;
    user-select: none;
    transition: all 0.5s ease;
}

/* Avatar */
.ts-avatar-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 24px;
    flex-shrink: 0;
}
.ts-avatar-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(251,191,36,0.5), transparent 70%);
    animation: tsPulse 1.5s ease-in-out infinite;
}
@keyframes tsPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
}
.ts-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #f0f9ff;
    border: 3px solid #fbbf24;
    position: relative;
    z-index: 2;
    object-fit: cover;
}

/* Speaker waves */
.ts-waves {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
}
.ts-waves.active { opacity: 1; }
.ts-waves span {
    width: 4px;
    height: 10px;
    background: #fbbf24;
    border-radius: 3px;
    animation: tsWave 0.6s ease-in-out infinite;
}
.ts-waves span:nth-child(2) { animation-delay: 0.1s; }
.ts-waves span:nth-child(3) { animation-delay: 0.2s; }
.ts-waves span:nth-child(4) { animation-delay: 0.3s; }
.ts-waves span:nth-child(5) { animation-delay: 0.4s; }
@keyframes tsWave {
    0%, 100% { height: 8px; opacity: 0.6; }
    50% { height: 22px; opacity: 1; }
}

/* Content area */
.ts-content {
    position: relative;
    width: 100%;
    max-width: 750px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.ts-sentence {
    display: none;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    justify-content: center;
    width: 100%;
    animation: tsSlideIn 0.6s ease;
}
.ts-sentence.show { display: flex; }

@keyframes tsSlideIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.ts-en {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.4;
    max-width: 700px;
    position: relative;
    padding: 0 10px;
}
.ts-en::before {
    content: '"';
    position: absolute;
    left: -20px;
    top: -15px;
    font-size: 60px;
    color: rgba(251,191,36,0.25);
    font-family: Georgia, serif;
}

.ts-hi {
    font-size: 22px;
    font-weight: 600;
    color: #fbbf24;
    line-height: 1.5;
    max-width: 700px;
    padding: 16px 24px;
    background: rgba(251,191,36,0.08);
    border: 2px solid rgba(251,191,36,0.25);
    border-radius: 14px;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.5s ease;
}
.ts-hi.show {
    opacity: 1;
    transform: translateY(0);
}

/* Active state highlight */
.ts-sentence.speaking-en .ts-en {
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251,191,36,0.5);
    transition: all 0.3s;
}

.ts-sentence.speaking-hi .ts-hi {
    background: rgba(251,191,36,0.15);
    border-color: rgba(251,191,36,0.5);
    box-shadow: 0 0 30px rgba(251,191,36,0.2);
}

/* Bottom controls */
.ts-controls {
    display: flex;
    gap: 12px;
    padding: 20px;
    justify-content: center;
    z-index: 5;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.ts-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 12px 22px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}
.ts-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }
.ts-btn.primary {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(245,158,11,0.35);
}
.ts-btn.primary:hover { box-shadow: 0 10px 28px rgba(245,158,11,0.5); }

/* Counter */
.ts-counter {
    position: absolute;
    bottom: 95px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    font-weight: 600;
    letter-spacing: 1px;
}

/* Mobile */
@media (max-width: 600px) {
    .ts-topbar { padding: 12px 16px; }
    .ts-topic { font-size: 12px; }
    .ts-close { width: 36px; height: 36px; font-size: 18px; }
    .ts-avatar-wrap { width: 70px; height: 70px; margin-bottom: 18px; }
    .ts-avatar { width: 70px; height: 70px; }
    .ts-en { font-size: 18px; }
    .ts-hi { font-size: 16px; padding: 12px 16px; }
    .ts-content { min-height: 200px; padding: 14px; }
    .ts-btn { padding: 10px 16px; font-size: 13px; }
    .ts-counter { bottom: 85px; }
}