:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f3f6fa;
    --card: #ffffff;
    --text: #1f2937;
    --border: #d1d5db;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 1350px;
    margin: 25px auto;
    padding: 0 20px;
}

.main-grid {
    display: grid;
    grid-template-columns: 440px 1fr;
    gap: 24px;
    align-items: start;
}

.card {
    background: var(--card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 18px;
}

.section-header h2 {
    font-size: 1.15rem;
    color: #1e3a8a;
    margin: 0;
}

.badge {
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.navbar {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    padding: 15px 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 5px 12px;
    border-radius: 10px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.logo p {
    font-size: 0.8rem;
    opacity: 0.85;
}

.api-box {
    display: flex;
    gap: 8px;
}

.api-box input {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    width: 220px;
    font-size: 0.85rem;
    outline: none;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background: #fff;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.checkbox-container input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-container label {
    margin-bottom: 0;
    cursor: pointer;
}

.highlight-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 10px;
    border-radius: 8px;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.export-btns {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    padding: 8px 14px;
    background: #e2e8f0;
    color: #334155;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-word {
    padding: 8px 14px;
    background: #1d4ed8;
    color: white;
}

.btn-word:hover {
    background: #1e40af;
}

.btn-print {
    padding: 8px 14px;
    background: #059669;
    color: white;
}

.btn-print:hover {
    background: #047857;
}

.btn-small {
    background: #10b981;
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.btn-small:hover {
    background: #059669;
}

.upload-area {
    border: 2px dashed #93c5fd;
    background: #eff6ff;
    border-radius: 8px;
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-area:hover, .upload-area.dragover {
    background: #dbeafe;
}

.upload-icon {
    font-size: 24px;
}

.upload-area p {
    font-size: 0.88rem;
    color: #1e40af;
    margin-top: 5px;
}

.upload-area span {
    text-decoration: underline;
    font-weight: 600;
}

.upload-area small {
    display: block;
    margin-top: 3px;
    font-size: 0.75rem;
    color: #6b7280;
}

.file-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #065f46;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

#removeFileBtn {
    background: none;
    color: #ef4444;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

.preview-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toolbar {
    background: var(--card);
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toolbar h2 {
    font-size: 1.1rem;
    color: #1e293b;
    margin: 0;
}

.exam-paper {
    background: white;
    padding: 40px 50px;
    border-radius: 12px;
    min-height: 750px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.empty-state {
    text-align: center;
    margin-top: 150px;
    color: #64748b;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.empty-state h3 {
    margin: 15px 0 8px;
    color: #334155;
    font-size: 1.2rem;
}

/* Variant konteyneri və Hər variantın üstündə gələn başlıq */
.variant-page-container {
    break-before: page;
    page-break-before: always;
    padding-top: 10px;
}

.variant-page-container:first-of-type {
    break-before: avoid;
    page-break-before: avoid;
}

.paper-header {
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.paper-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 12px;
    text-transform: uppercase;
    color: #1e293b;
}

.paper-topic {
    text-align: center;
    font-size: 0.9rem;
    color: #4b5563;
    font-style: italic;
}

.school-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.question-block {
    margin-bottom: 18px;
    page-break-inside: avoid;
}

.q-header {
    font-size: 0.85rem;
    color: #475569;
    margin-bottom: 4px;
    font-weight: 600;
}

.q-text {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.q-options {
    list-style: none;
    padding-left: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    font-size: 0.9rem;
}

.open-lines {
    margin-top: 8px;
    border-bottom: 1px dashed #94a3b8;
    height: 22px;
}

.answer-key-section {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 2px dashed #000;
    break-before: page;
    page-break-before: always;
}

.answer-key-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #1e293b;
}

.answer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
}

.answer-chip {
    background: #f3f4f6;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.hidden { 
    display: none !important; 
}

.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin { 
    to { transform: rotate(360deg); } 
}

@media (max-width: 900px) {
    .main-grid { 
        grid-template-columns: 1fr; 
    }
    .nav-content { 
        flex-direction: column; 
        text-align: center; 
        gap: 10px; 
    }
}

@media print {
    body { 
        background: white; 
    }
    .no-print { 
        display: none !important; 
    }
    .container, .main-grid { 
        display: block; 
        margin: 0; 
        padding: 0; 
        width: 100%;
    }
    .card.preview-section {
        box-shadow: none;
        border: none;
        padding: 0;
    }
    .exam-paper { 
        box-shadow: none; 
        padding: 0; 
        border: none;
        width: 100%;
    }
}

/* ---- Yeniliklər ---- */
.toast {
    position: fixed; right: 20px; bottom: 20px; max-width: 360px;
    padding: 12px 16px; border-radius: 10px; color: #fff; font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px);
    pointer-events: none; transition: opacity .25s, transform .25s; z-index: 1000;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #dc2626; }
.toast.success { background: #059669; }

.sum-hint { color: #b45309; font-size: 0.82rem; margin: -6px 0 12px; }
.sum-hint:empty { display: none; }

.btn-primary { position: sticky; bottom: 12px; box-shadow: 0 6px 16px rgba(37,99,235,.35); }
.btn-primary:disabled { cursor: wait; }

.preview-section { background: #e5e9f0; }
.exam-paper { max-width: 794px; width: 100%; margin: 0 auto; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.variant-page-container + .variant-page-container { margin-top: 40px; padding-top: 30px; border-top: 2px dashed #cbd5e1; }

.steps { display: inline-block; text-align: left; margin-top: 12px; padding-left: 20px; font-size: 0.95rem; line-height: 1.9; }

@media (max-width: 600px) {
    .container { padding: 0 10px; }
    .toolbar { flex-wrap: wrap; gap: 10px; }
    .exam-paper { padding: 20px 16px; }
    .school-row { flex-direction: column; }
    .q-options { grid-template-columns: 1fr; }
    .api-box input { width: 160px; }
}

@media print {
    .preview-section { background: white; }
    .variant-page-container + .variant-page-container { border-top: none; margin-top: 0; padding-top: 10px; }
    .toast { display: none !important; }
}

/* ---- Variant tabları və başlıqsız rejim ---- */
.variant-tabs { display: flex; flex-wrap: wrap; gap: 8px; max-width: 794px; width: 100%; margin: 0 auto; }
.variant-tabs button { padding: 7px 16px; background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.variant-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.variant-page-container.tab-hidden { display: none; }
.variant-label { text-align: right; font-size: 1rem; margin-bottom: 14px; color: #1e293b; }

@media print {
    .variant-page-container.tab-hidden { display: block !important; }
}

.header-fields { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px 12px 0; margin: -4px 0 15px; }

.q-text table, .passage-block table { border-collapse: collapse; margin: 8px 0; font-weight: 400; }
.q-text th, .q-text td, .passage-block th, .passage-block td { border: 1px solid #475569; padding: 5px 10px; }
.q-text th { background: #f1f5f9; }
.passage-block { border: 1px solid #cbd5e1; background: #f8fafc; padding: 12px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92rem; line-height: 1.6; }
@media print { .passage-block { background: #fff; border-color: #000; } }

.answer-chip { white-space: pre-line; }

.ai-note { max-width: 794px; width: 100%; margin: 0 auto; font-size: 0.82rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 12px; }
.exam-paper.hidden + .ai-note { display: none; }

.retry-bar { display: flex; flex-wrap: wrap; gap: 8px; max-width: 794px; width: 100%; margin: 0 auto; }
.retry-bar button { padding: 8px 14px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }