:root {
    --primary: #0066cc;
    --primary-dark: #004d99;
    --accent: #ff6b35;
    --bg: #f8f9fb;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-light: #6c757d;
    --border: #e2e8f0;
    --success: #28a745;
    --error: #dc3545;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ── Header ── */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header h1 { font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.header-nav { display: flex; align-items: center; gap: 1rem; }
.nav-link {
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-link:hover { color: white; }
.nav-link.active { color: white; font-weight: 700; }
.btn-nav-signup {
    background: rgba(255,255,255,0.2);
    padding: 0.4rem 1rem;
    border-radius: 6px;
}
.btn-nav-signup:hover { background: rgba(255,255,255,0.3); }
.user-badge {
    background: var(--accent);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    color: white;
}

/* Auth visibility */
.guest-only { display: inline; }
.auth-only { display: none; }
body.logged-in .guest-only { display: none; }
body.logged-in .auth-only { display: inline; }

/* ── Container ── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Hero ── */
.hero-text {
    text-align: center;
    margin-bottom: 2rem;
}
.hero-text h2 { font-size: 1.8rem; color: var(--primary-dark); margin-bottom: 0.5rem; }
.hero-text p { color: var(--text-light); font-size: 1.05rem; max-width: 600px; margin: 0 auto; }

/* ── Section Titles ── */
.section-title {
    font-size: 1.6rem;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}
.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card h2 .step-num {
    background: var(--primary);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--primary-dark);
}

/* ── Form ── */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}
.hint {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 0.6rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}
textarea { resize: vertical; min-height: 160px; }
select { cursor: pointer; background: white; }
.form-group { margin-bottom: 1.2rem; }

.input-row {
    display: flex;
    gap: 0.5rem;
}
.input-row input { flex: 1; }

/* ── Language selector ── */
.lang-row { display: flex; gap: 0.75rem; }
.lang-option {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}
.lang-option:hover { border-color: var(--primary); }
.lang-option.active {
    border-color: var(--primary);
    background: rgba(0, 102, 204, 0.06);
    color: var(--primary);
}
.lang-option .flag { font-size: 1.5rem; display: block; margin-bottom: 0.25rem; }

/* ── Buttons ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--text-light); cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(0,102,204,0.06); }

.btn-wide { flex: 1; }
.btn-row {
    display: flex;
    gap: 1rem;
}

.btn-tier {
    width: 100%;
    margin-top: 1rem;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.visible { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 90%;
    max-width: 420px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-wide { max-width: 520px; }

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}
.modal h2 { margin-bottom: 1.25rem; text-align: center; color: var(--primary-dark); }

.auth-error, .auth-success {
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    display: none;
}
.auth-error { background: #fef2f2; color: var(--error); }
.auth-error.visible { display: block; }
.auth-success { background: #f0fdf4; color: var(--success); }
.auth-success.visible { display: block; }

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── Payment ── */
.payment-tier-info {
    background: rgba(0,102,204,0.06);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
    text-align: center;
}

.pay-method-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.pay-method-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s ease;
}
.pay-method-tab:hover {
    border-color: var(--primary);
    background: rgba(0,102,204,0.04);
}
.pay-method-tab.active {
    border-color: var(--primary);
    background: rgba(0,102,204,0.08);
    color: var(--primary);
    font-weight: 600;
}
.pay-method-tab svg {
    flex-shrink: 0;
}

.stripe-brands {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.brand-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #f0f0f0;
    color: #555;
    letter-spacing: 0.02em;
}

.payment-status {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
}
.btn-pay { width: 100%; }

/* ── Progress ── */
.progress-container { display: none; }
.progress-container.visible { display: block; }

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}
.progress-step {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
}
.progress-step.active { color: var(--primary); font-weight: 600; }
.progress-step.done { color: var(--success); }

.status-text {
    text-align: center;
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 1rem;
}

/* ── Preview ── */
.preview-container { display: none; }
.preview-container.visible { display: block; }

.preview-content {
    background: var(--bg);
    padding: 1.5rem;
    border-radius: 8px;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.7;
    max-height: 400px;
    overflow-y: auto;
}
.preview-cta {
    text-align: center;
    margin-top: 1rem;
    font-weight: 600;
}
.preview-cta a { color: var(--primary); text-decoration: none; }

/* ── Results ── */
.results-container { display: none; }
.results-container.visible { display: block; }

.file-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 600px) { .file-grid { grid-template-columns: 1fr; } }

.file-card {
    padding: 1.25rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.file-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,102,204,0.12);
}
.file-card .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.file-card .name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem; }

.btn-download {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-download:hover { background: var(--primary-dark); }

.results-actions {
    margin-top: 1rem;
    text-align: center;
}

/* ── Pricing ── */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}
@media (max-width: 700px) { .pricing-grid { grid-template-columns: 1fr; } }

.pricing-card {
    padding: 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    background: var(--card-bg);
}
.pricing-card.featured {
    border-color: var(--primary);
    position: relative;
}
.pricing-card.featured::before {
    content: attr(data-badge);
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 0.2rem 1rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}
.pricing-card .tier { font-weight: 700; font-size: 1.1rem; margin-bottom: 0.5rem; }
.pricing-card .price { font-size: 2rem; font-weight: 800; color: var(--primary); }
.pricing-card ul {
    list-style: none;
    margin-top: 1rem;
    text-align: left;
    font-size: 0.88rem;
}
.pricing-card ul li {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}
.pricing-card ul li:last-child { border: none; }

/* ── Dashboard ── */
.dash-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 600px) { .dash-cards { grid-template-columns: 1fr; } }

.dash-stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}
.dash-stat-label { font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.25rem; }
.dash-stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); }

.referral-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 0.5rem;
}
.referral-box code {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    word-break: break-all;
}

.job-history {
    max-height: 400px;
    overflow-y: auto;
}
.job-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.job-row:last-child { border: none; }
.job-row .job-date { color: var(--text-light); font-size: 0.82rem; }
.job-status {
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.job-status.completed { background: #d4edda; color: #155724; }
.job-status.processing { background: #fff3cd; color: #856404; }
.job-status.error { background: #f8d7da; color: #721c24; }

/* ── Chatbot ── */
.chatbot-container { min-height: 500px; display: flex; flex-direction: column; }
.chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.chatbot-header h2 { margin-bottom: 0; }

.chat-messages {
    flex: 1;
    min-height: 300px;
    max-height: 450px;
    overflow-y: auto;
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.chat-bubble {
    margin-bottom: 0.75rem;
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
}
.chat-bubble.bot {
    background: white;
    border: 1px solid var(--border);
}
.chat-bubble.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
}

/* ═══ EXAM PREP ═══ */
.exam-filters {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.btn-filter {
    padding: 0.5rem 1.2rem;
    border: 2px solid var(--border);
    background: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-filter.active, .btn-filter:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.exam-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}
.exam-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.exam-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.exam-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-language { background: #e3f2fd; color: #1565c0; }
.badge-professional { background: #fff3e0; color: #e65100; }
.badge-academic { background: #f3e5f5; color: #7b1fa2; }
.exam-lang-badge {
    background: var(--bg);
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
}
.exam-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}
.exam-lock { color: var(--text-light); font-size: 0.8rem; font-weight: 400; }
.exam-full { color: var(--text-light); font-size: 0.85rem; margin-bottom: 0.5rem; }
.exam-desc { font-size: 0.9rem; margin-bottom: 0.75rem; }
.exam-sections-count { font-size: 0.8rem; color: var(--text-light); }

/* Exam Detail */
.exam-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.exam-progress-bar { margin-bottom: 1.5rem; }
.progress-label { font-weight: 500; margin-bottom: 0.5rem; }

.exam-sections { display: flex; flex-direction: column; gap: 0.75rem; }
.section-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 1rem;
    flex-wrap: wrap;
}
.section-card.section-passed {
    border-left: 4px solid var(--success);
    background: #f0fdf4;
}
.section-info h4 { font-size: 1rem; margin-bottom: 0.25rem; }
.section-stats { font-size: 0.85rem; color: var(--text-light); }
.section-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Study Material */
.study-material {
    margin-top: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}
.study-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.study-content {
    line-height: 1.7;
    font-size: 0.95rem;
}
.study-content h2, .study-content h3, .study-content h4 {
    margin: 1rem 0 0.5rem;
    color: var(--primary-dark);
}
.study-content ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.study-content li { margin-bottom: 0.25rem; }

/* ═══ QUIZ MODAL ═══ */
.quiz-modal { max-width: 700px; }
.quiz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 1rem;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.quiz-meta { color: var(--text-light); font-size: 0.9rem; }
.quiz-question-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.95rem;
}
.quiz-option:hover {
    border-color: var(--primary);
    background: #f0f6ff;
}
.quiz-option input[type="radio"],
.quiz-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

/* Quiz Results */
.quiz-results-header {
    text-align: center;
    margin-bottom: 2rem;
}
.quiz-score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem auto;
    font-size: 1.8rem;
    font-weight: 700;
}
.score-pass {
    background: #d4edda;
    color: var(--success);
    border: 4px solid var(--success);
}
.score-fail {
    background: #f8d7da;
    color: var(--error);
    border: 4px solid var(--error);
}
.quiz-results-detail {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}
.quiz-result-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    border-left: 4px solid;
}
.quiz-result-item.correct {
    background: #f0fdf4;
    border-color: var(--success);
}
.quiz-result-item.incorrect {
    background: #fef2f2;
    border-color: var(--error);
}
.qr-question { font-weight: 500; margin-bottom: 0.25rem; }
.qr-answers { font-size: 0.9rem; color: var(--text-light); margin-bottom: 0.25rem; }
.qr-correct { color: var(--success); font-weight: 500; }
.qr-explanation { font-size: 0.85rem; color: var(--text-light); font-style: italic; }
.quiz-results-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 600px) {
    .exam-grid { grid-template-columns: 1fr; }
    .section-card { flex-direction: column; align-items: flex-start; }
    .section-actions { width: 100%; }
    .quiz-modal { padding: 1rem; }
}

.chat-input-row {
    display: flex;
    gap: 0.5rem;
}
.chat-input-row input { flex: 1; }
.btn-send { padding: 0.75rem 1.5rem; }

/* ── Error ── */
.error-msg {
    background: #fef2f2;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1rem;
    border-radius: 8px;
    display: none;
    margin-bottom: 1.5rem;
}
.error-msg.visible { display: block; }

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .header-inner { flex-direction: column; gap: 0.5rem; }
    .header-nav { flex-wrap: wrap; justify-content: center; }
    .btn-row { flex-direction: column; }
    .lang-row { flex-direction: column; }
}
