/* ============================================================
   IELTS Speaking Trainer — Style Sheet
   فونت فارسی + طراحی شبیه آزمون رسمی، RTL-صحیح
   ============================================================ */

/* ---- ریست و متغیرها ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --navy:    #0d1f3c;
    --navy-mid:#1a3460;
    --blue:    #1657b5;
    --blue-lt: #2e7de9;
    --gold:    #c8973a;
    --gold-lt: #f0bc5e;
    --cream:   #f8f5ef;
    --white:   #ffffff;
    --gray-50: #f9fafb;
    --gray-100:#f0f2f5;
    --gray-200:#e2e6ed;
    --gray-400:#94a3b8;
    --gray-600:#4b5c72;
    --gray-800:#1e2d3d;
    --green:   #0b8a4b;
    --red:     #c0392b;
    --shadow-sm: 0 2px 8px rgba(13,31,60,.10);
    --shadow-md: 0 6px 24px rgba(13,31,60,.14);
    --shadow-lg: 0 16px 48px rgba(13,31,60,.18);
    --radius:  14px;
    --radius-sm: 8px;
    --transition: .25s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
    background: var(--cream);
    color: var(--gray-800);
    min-height: 100vh;
    direction: rtl;
    line-height: 1.65;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: var(--navy);
    border-bottom: 4px solid var(--gold);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 32px;
    max-width: 1200px;
    margin: 0 auto;
    direction: ltr;
}

/* ---- Trainer Photo ---- */
.trainer-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.trainer-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold);
    box-shadow: 0 0 0 3px rgba(200,151,58,.25);
    display: block;
}

.trainer-fallback {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(200,151,58,.15);
    border: 2px dashed rgba(200,151,58,.5);
    color: var(--gold-lt);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.trainer-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.trainer-name {
    font-family: 'Playfair Display', serif;
    font-size: .95rem;
    font-weight: 700;
    color: var(--gold-lt);
    white-space: nowrap;
}

.trainer-title {
    font-size: .68rem;
    color: rgba(255,255,255,.6);
    white-space: nowrap;
}

.header-spacer {
    /* mirrors trainer-area width to keep title centred */
    min-width: 180px;
    flex-shrink: 0;
}

.hidden { display: none !important; }

/* ---- عنوان مرکزی ---- */
.header-title {
    flex: 1;
    text-align: center;
    color: var(--white);
}

.header-title h1 {
    font-family: 'Playfair Display', 'Tahoma', serif;
    font-size: 1.65rem;
    font-weight: 900;
    letter-spacing: .5px;
    color: var(--gold-lt);
    line-height: 1.2;
}

.header-title p {
    font-size: .8rem;
    color: rgba(255,255,255,.7);
    margin-top: 4px;
}

/* ============================================================
   PROGRESS NAV
   ============================================================ */
.progress-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background: var(--navy-mid);
    padding: 10px 32px;
    max-width: 100%;
    overflow-x: auto;
    direction: ltr;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.55);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 110px;
}

.progress-step small {
    font-size: .68rem;
    opacity: .75;
}

.step-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: .85rem;
    transition: var(--transition);
}

.step-label {
    font-size: .8rem;
    font-weight: 600;
}

.progress-step.active {
    color: var(--white);
}

.progress-step.active .step-num {
    background: var(--gold);
    color: var(--navy);
}

.progress-step.completed {
    color: rgba(255,255,255,.8);
}

.progress-step.completed .step-num {
    background: var(--green);
    color: var(--white);
}

.step-connector {
    width: 36px;
    height: 2px;
    background: rgba(255,255,255,.2);
    flex-shrink: 0;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 36px 20px 60px;
}

/* ============================================================
   EXAM SECTIONS
   ============================================================ */
.exam-section {
    display: none;
    animation: sectionFade .45s ease;
}

.exam-section.active {
    display: block;
}

@keyframes sectionFade {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section-badge {
    display: inline-block;
    background: var(--navy);
    color: var(--gold-lt);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 5px 18px;
    border-radius: 30px;
    margin-bottom: 12px;
    border: 1px solid var(--gold);
    direction: ltr;
    unicode-bidi: embed;
}

/* ============================================================
   EXAM CARD
   ============================================================ */
.exam-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

/* ---- Examiner Bar ---- */
.examiner-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 24px;
    background: var(--navy);
    color: var(--white);
    border-bottom: 3px solid var(--gold);
    flex-wrap: wrap;
}

.examiner-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.examiner-text {
    flex: 1;
    min-width: 0;
    direction: ltr;
    unicode-bidi: embed;
}

.examiner-text strong {
    display: block;
    font-size: .85rem;
    color: var(--gold-lt);
    letter-spacing: .5px;
}

.examiner-text span {
    font-size: .8rem;
    opacity: .8;
}

/* ---- Advance Button ---- */
.btn-advance {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--gold);
    color: var(--navy);
    border: none;
    padding: 9px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-advance:hover:not(:disabled) {
    background: var(--gold-lt);
    transform: translateX(3px); /* RTL: مثبت = به سمت راست */
    box-shadow: 0 4px 14px rgba(200,151,58,.4);
}

.btn-advance:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

/* ---- Question Panel ---- */
.question-panel {
    padding: 24px;
    border-bottom: 1px solid var(--gray-100);
}

.question-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-bottom: 12px;
    direction: ltr;
    unicode-bidi: embed;
}

.question-text p {
    font-size: 1.1rem;
    line-height: 1.75;
    color: var(--gray-800);
    padding: 18px 20px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border-right: 5px solid var(--blue); /* RTL: border-right برای سمت راست */
    border-left: none;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    background: var(--gray-100);
    color: var(--gray-600);
    border: none;
    padding: 7px 18px;
    border-radius: 30px;
    font-size: .82rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-refresh:hover {
    background: var(--gray-200);
    color: var(--gray-800);
    transform: translateY(-1px);
}

/* ============================================================
   CUE CARD
   ============================================================ */
.cue-card-wrap {
    margin: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid #e8c96a;
}

.cue-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #fef7e0;
    border-bottom: 2px solid #e8c96a;
}

.cc-logo {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 900;
    color: #92400e;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.cue-card-body {
    padding: 24px;
    background: #fffdf4;
}

.cc-topic {
    font-size: 1.15rem;
    font-weight: 700;
    color: #7c4a00;
    margin-bottom: 16px;
    line-height: 1.5;
}

.cc-say {
    font-size: .88rem;
    color: #92400e;
    margin-bottom: 8px;
    font-weight: 600;
}

.cc-points {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cc-points li {
    padding: 5px 0;
    padding-right: 20px; /* RTL: فاصله از راست */
    color: #78350f;
    font-size: .95rem;
    position: relative;
}

.cc-points li::before {
    content: '▸';
    position: absolute;
    right: 0; /* RTL: آیکون در سمت راست */
    color: #d97706;
}

/* ============================================================
   PREP TIMER
   ============================================================ */
.prep-section {
    padding: 0 24px;
}

.prep-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    background: #fef3c7;
    border-radius: var(--radius-sm);
    border: 2px solid #fbbf24;
    margin-bottom: 4px;
}

.prep-label {
    font-size: .9rem;
    color: #92400e;
    font-weight: 600;
}

.prep-count {
    font-size: 2.4rem;
    font-weight: 900;
    color: #c2410c;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    min-width: 2.5ch;
    text-align: center;
}

.prep-unit {
    font-size: .9rem;
    color: #92400e;
}

/* ============================================================
   RECORDER PANEL
   ============================================================ */
.recorder-panel {
    padding: 24px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
}

.rec-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.btn-rec {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--blue);
    color: var(--white);
    border: none;
    padding: 12px 28px;
    border-radius: 50px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(22,87,181,.3);
}

.btn-rec:hover:not(:disabled) {
    background: var(--blue-lt);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22,87,181,.4);
}

.btn-rec:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    display: inline-block;
}

.btn-rec.active .rec-dot {
    background: #ef4444;
    animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(1.4); }
}

.btn-stop {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    color: var(--red);
    border: 2px solid var(--red);
    padding: 11px 28px;
    border-radius: 50px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-stop:hover:not(:disabled) {
    background: var(--red);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-stop:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.btn-prep {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f59e0b;
    color: var(--navy);
    border: none;
    padding: 12px 28px;
    border-radius: 50px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(245,158,11,.3);
}

.btn-prep:hover:not(:disabled) {
    background: var(--gold-lt);
    transform: translateY(-2px);
}

.btn-prep:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ---- وضعیت ضبط ---- */
.rec-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 20px;
    background: var(--white);
    border-radius: 30px;
    border: 1px solid var(--gray-200);
    font-size: .88rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-400);
    transition: var(--transition);
    flex-shrink: 0;
}

.status-dot.recording {
    background: #ef4444;
    animation: pulseDot 1s infinite;
}

.status-dot.done {
    background: var(--green);
}

.audio-wrap {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.audio-wrap audio {
    width: 100%;
    direction: ltr; /* پلیر صوتی LTR باشد */
}

/* ============================================================
   ANALYSIS PANEL
   ============================================================ */
.analysis-panel {
    padding: 24px;
    border-top: 3px solid var(--navy);
    background: #f0f4ff;
    animation: sectionFade .4s ease;
}

.analysis-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--navy);
    margin-bottom: 16px;
    direction: ltr;
    unicode-bidi: embed;
}

.band-scores {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.band-box {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.band-box:hover { transform: translateY(-2px); }

.band-box.highlight {
    background: var(--navy);
    border-color: var(--gold);
}

.band-label {
    font-size: .72rem;
    color: var(--gray-400);
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.band-box.highlight .band-label { color: rgba(255,255,255,.6); }

.band-val {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
}

.band-box.highlight .band-val { color: var(--gold-lt); }

.feedback-panel {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    border-right: 4px solid var(--blue); /* RTL: راست */
    font-size: .93rem;
    line-height: 1.75;
    color: var(--gray-800);
}

/* ============================================================
   RESULT CARD
   ============================================================ */
.result-card {
    text-align: center;
    overflow: visible;
}

.result-header {
    padding: 36px 24px 24px;
    background: var(--navy);
    color: var(--white);
}

.result-seal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    background: var(--gold);
    color: var(--navy);
    border-radius: 50%;
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(200,151,58,.5);
}

.result-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    color: var(--gold-lt);
    margin-bottom: 6px;
}

.result-header p {
    font-size: .85rem;
    opacity: .7;
}

/* ---- جدول نتایج ---- */
.result-table {
    padding: 32px 32px 8px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}

.result-row:last-child { border-bottom: none; }

.rt-label {
    min-width: 200px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--gray-800);
    text-align: right;
}

.rt-bar-wrap {
    flex: 1;
    height: 10px;
    background: var(--gray-200);
    border-radius: 5px;
    overflow: hidden;
    min-width: 80px;
}

.rt-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--blue), var(--blue-lt));
    border-radius: 5px;
    transition: width .8s cubic-bezier(.4,0,.2,1);
}

.overall-bar {
    background: linear-gradient(90deg, var(--gold), var(--gold-lt));
}

.rt-score {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--blue);
    min-width: 40px;
    text-align: center;
}

.overall-row {
    background: linear-gradient(135deg, #f0f4ff, #fff7e6);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 8px;
    border: 2px solid var(--gold);
}

.overall-row .rt-label { color: var(--navy); font-size: 1rem; }

.overall-score {
    font-size: 2rem;
    color: var(--gold);
}

/* ---- Band Scale ---- */
.band-scale {
    display: flex;
    justify-content: space-between;
    padding: 4px 32px 20px;
    font-size: .72rem;
    color: var(--gray-400);
    font-weight: 700;
    letter-spacing: 1px;
}

/* ---- Overall Feedback ---- */
.overall-feedback-box {
    margin: 0 24px 24px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 20px 24px;
    text-align: right;
    border-right: 4px solid var(--gold); /* RTL */
}

.ofb-title {
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 10px;
    font-size: .95rem;
}

.overall-feedback-box p {
    font-size: .93rem;
    line-height: 1.8;
    color: var(--gray-800);
}

.result-actions {
    padding: 8px 24px 32px;
}

.btn-restart {
    background: var(--navy);
    color: var(--white);
    border: none;
    padding: 13px 36px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-restart:hover {
    background: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13,31,60,.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-box {
    text-align: center;
    color: var(--white);
}

.loader-ring {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(255,255,255,.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-box p {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.loading-box small {
    font-size: .82rem;
    opacity: .7;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--navy);
    border-top: 3px solid var(--gold);
    padding: 28px 20px;
}

.footer-inner {
    max-width: 860px;
    margin: 0 auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-quote {
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--gold-lt);
    line-height: 1.6;
}

.footer-credit {
    font-size: .78rem;
    color: rgba(255,255,255,.5);
    letter-spacing: .3px;
}

/* ============================================================
   PREP ALERT
   ============================================================ */
.prep-alert {
    position: fixed;
    inset: 0;
    background: rgba(13,31,60,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    animation: sectionFade .25s ease;
}

.prep-alert-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px 36px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border-top: 5px solid var(--gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.prep-alert-icon {
    font-size: 2.4rem;
    animation: pulse 1s 3;
}

.prep-alert-text strong {
    display: block;
    font-size: 1.1rem;
    color: var(--navy);
    margin-bottom: 4px;
}

.prep-alert-text span {
    font-size: .9rem;
    color: var(--gray-600);
}

.prep-alert-close {
    margin-top: 8px;
    background: var(--gold);
    color: var(--navy);
    border: none;
    padding: 10px 36px;
    border-radius: 30px;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    transition: var(--transition);
}

.prep-alert-close:hover {
    background: var(--gold-lt);
    transform: translateY(-1px);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .header-inner {
        padding: 12px 16px;
        gap: 12px;
    }

    .header-title h1 { font-size: 1.1rem; }
    .header-title p  { font-size: .7rem; }

    .logo-placeholder,
    .profile-placeholder { min-width: 64px; padding: 8px 10px; font-size: .65rem; }

    .progress-nav { padding: 8px 16px; gap: 0; }
    .progress-step { min-width: 70px; padding: 6px 10px; }
    .step-label { font-size: .68rem; }
    .step-connector { width: 16px; }

    .main-content { padding: 20px 12px 48px; }

    .band-scores { grid-template-columns: repeat(3, 1fr); }
    .band-scores .band-box:last-child { grid-column: 1 / -1; }

    .result-table { padding: 20px 16px 8px; }
    .rt-label { min-width: 140px; font-size: .82rem; }
    .result-row { gap: 8px; }
    .band-scale { padding: 4px 16px 16px; }
    .overall-feedback-box { margin: 0 12px 16px; }

    .rec-controls { gap: 8px; }
    .btn-rec, .btn-stop, .btn-prep { padding: 10px 18px; font-size: .85rem; }

    .examiner-bar { padding: 12px 16px; }
    .question-panel, .recorder-panel, .analysis-panel { padding: 16px; }
    .question-text p { font-size: 1rem; }
}

@media (max-width: 480px) {
    .band-scores { grid-template-columns: repeat(2, 1fr); }
    .band-scores .band-box:last-child { grid-column: unset; }

    .result-row { flex-direction: column; align-items: flex-end; }
    .rt-bar-wrap { width: 100%; }
    .rt-label, .rt-score { width: 100%; text-align: right; }
}
