/* ==================================================================== */
/* ۱. تنظیمات پایه و عمومی */
/* ==================================================================== */

body {
    font-family: 'Tahoma', sans-serif;
    background-color: #f4f7f6; /* پس‌زمینه روشن */
    margin: 0;
    direction: rtl; 
    color: #212529; /* رنگ متن اصلی */
    font-size: 14px;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s; /* انتقال نرم برای Dark Mode */
}

.page-wrapper {
    width: 100%;
    min-height: 100vh;
}

.hidden { 
    display: none !important; 
}

/* ==================================================================== */
/* ۲. استایل هدر و حالت تاریک */
/* ==================================================================== */

/* هدر اصلی */
.main-header {
    background-color: #007bff; /* آبی اصلی */
    color: white;
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
}

.site-name { font-size: 1.5em; font-weight: bold; margin: 0; }
.course-name { font-size: 1em; opacity: 0.9; margin: 3px 0 0; }

/* دکمه حالت تاریک */
#dark-mode-toggle {
    position: absolute;
    left: 20px;
    top: 20px;
    font-size: 1.5em;
    cursor: pointer;
    color: white;
    padding: 5px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
}

/* --- Dark Mode Styles --- */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}
body.dark-mode .main-header {
    background-color: #333;
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}
body.dark-mode .quiz-container,
body.dark-mode .info-box,
body.dark-mode .card,
body.dark-mode .question-area {
    background-color: #1e1e1e;
    border-color: #3a3a3a;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.05);
}
body.dark-mode .box-title,
body.dark-mode .question-text,
body.dark-mode .state-text {
    color: #ccc !important;
}
body.dark-mode .option-label {
    background-color: #2a2a2a;
    border-color: #3a3a3a;
    color: #e0e0e0;
}
body.dark-mode .option-label:hover {
    background-color: #3a3a3a;
}
body.dark-mode .qn-button {
    background-color: #333;
    color: #aaa;
    border-color: #555;
}
body.dark-mode .status-answered { 
    background-color: #1e873a !important; 
    color: white !important; 
}

/* ==================================================================== */
/* ۳. استایل صفحه ورود (Start Page) */
/* ==================================================================== */

.main-content-area {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.card {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
    text-align: right;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-group-voice {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

#audio-test {
    width: 100%;
    margin-bottom: 15px;
}

.error-message {
    color: #dc3545;
    font-weight: bold;
    margin-top: 15px;
    font-size: 0.9em;
}

.restore-message {
    margin-top: 15px;
    padding: 10px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    font-weight: bold;
}

/* ==================================================================== */
/* ۴. ساختار آزمون و سایدبار */
/* ==================================================================== */

.main-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    max-width: 1200px;
    width: 100%;
    gap: 20px;
}

.quiz-sidebar {
    width: 250px;
    flex-shrink: 0;
}

.info-box {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.box-title {
    font-size: 1em;
    font-weight: bold;
    color: #333;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
    margin: 0 0 10px 0;
}

/* تایمر */
.timer-box {
    text-align: center;
    background-color: #fff3cd; 
    border-color: #ffeeba;
}

.timer-display {
    font-family: monospace;
    color: #856404; 
    margin: 10px 0 5px;
    transition: all 0.3s ease;
}

/* نوار پیشرفت */
.progress-box { padding: 15px; }

#progress-bar-fill {
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

#progress-bar-fill::before {
    content: '';
    display: block;
    height: 100%;
    width: 0%;
    background-color: #28a745;
    transition: width 0.4s ease-in-out;
}

#progress-percent {
    display: block;
    text-align: center;
    font-size: 0.9em;
    margin-top: 5px;
    color: #28a745;
    font-weight: bold;
}

/* ناوبری سؤالات */
.qn-buttons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 10px 0;
    max-height: 400px;
    overflow-y: auto;
}

.qn-button { /* ... (استایل دکمه ها) ... */ }
.status-answered { background-color: #d4edda !important; color: #155724 !important; border-color: #c3e6cb !important; }
.status-current { box-shadow: 0 0 0 3px #007bff; border-color: #007bff !important; }

/* وضعیت صفحه جاری */
.state-text { font-weight: bold; }

/* ==================================================================== */
/* ۵. استایل سؤالات و دکمه‌ها */
/* ==================================================================== */

.region-main-content { flex-grow: 1; min-width: 0; }

.quiz-questions {
    padding: 0;
}

.question-block {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.question-block h3 { font-size: 1.1em; font-weight: bold; color: #007bff; margin: 0 0 15px; }
.question-text { font-size: 1.3em; margin-top: 0; margin-bottom: 20px; line-height: 1.7; }

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.option-label {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    transition: background-color 0.1s;
    display: flex;
    align-items: center;
}
.option-label:hover { background-color: #e9ecef; }

/* بازخورد رنگی */
.correct-answer { background-color: #d4edda !important; border: 2px solid #28a745; }
.incorrect-answer { background-color: #f8d7da !important; border: 2px solid #dc3545; }
.selected-incorrect { box-shadow: 0 0 0 3px #dc3545; }

/* دکمه‌های ناوبری پایینی */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-top: 1px solid #dee2e6;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    flex-grow: 1;
    margin: 0 5px;
}

.btn-primary { background-color: #007bff; color: white; }
.btn-secondary { background-color: #6c757d; color: white; }
.btn-submit { background-color: #dc3545; color: white; }

/* ==================================================================== */
/* ۶. استایل مدرک و پاپ آپ */
/* ==================================================================== */

/* پاپ آپ هشدار امنیتی */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    text-align: center;
    max-width: 400px;
}

/* استایل مدرک */
#certificate-page { /* ... (استایل نمایش مدرک) ... */ }
.certificate-box { /* ... (استایل جعبه مدرک) ... */ }
.cert-score-grade { margin-top: 20px; }
.grade-badge { /* ... (استایل سطح کیفی) ... */ }
.signatures { /* ... (استایل امضا) ... */ }
.seal { /* ... (استایل مهر) ... */ }

/* استایل چاپ */
@media print {
    /* ... (تنظیمات چاپ) ... */
    body {
        background-color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .page-wrapper, .certificate-box {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: none !important;
    }
    .cert-actions, .main-header, #quiz-page, #start-page, #dark-mode-toggle, #sidebar-left {
        display: none !important;
    }
    #certificate-page {
        padding: 0;
        margin: 0;
        background: white !important;
    }
    .certificate-box {
        border: 10px solid #f0e68c !important;
        padding: 30px;
        min-height: 100vh;
    }
}

/* واکنش‌گرایی (Mobile-friendly) */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        padding: 10px;
    }

    .quiz-sidebar {
        width: 100%;
        margin-left: 0;
        order: -1; 
    }

    .options-grid {
        grid-template-columns: 1fr; 
    }

    .qn-buttons-grid {
        grid-template-columns: repeat(7, 1fr); 
    }
    
    .navigation-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        margin: 5px 0;
    }
    
    .custom-modal {
        width: 90%;
    }
}

/* ... (بقیه کدهای CSS برای جزئیات کامل) ... */

/* ==================================================================== */
/* ۱. تنظیمات پایه و عمومی */
/* ==================================================================== */

body {
    font-family: 'Tahoma', sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    direction: rtl; 
    color: #212529;
    font-size: 14px;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.hidden { display: none !important; }
.btn { /* استایل پایه دکمه ها */ }

/* --- Dark Mode Styles --- (برای حفظ یکپارچگی) */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}
body.dark-mode .main-header { background-color: #333; }
/* ... (سایر استایل‌های Dark Mode) ... */
body.dark-mode .quiz-container,
body.dark-mode .info-box,
body.dark-mode .card,
body.dark-mode .question-area,
body.dark-mode .custom-modal {
    background-color: #1e1e1e;
    border-color: #3a3a3a !important;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.05);
}
body.dark-mode .option-label {
    background-color: #2a2a2a;
    border-color: #3a3a3a;
    color: #e0e0e0;
}

/* ==================================================================== */
/* ۲. ساختار آزمون (Start/Quiz Page) */
/* ==================================================================== */

.main-header { background-color: #007bff; color: white; padding: 15px 30px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); text-align: center; position: relative; }
.main-container { display: flex; justify-content: center; align-items: flex-start; max-width: 1200px; width: 100%; gap: 20px; padding: 20px; }
.quiz-sidebar { width: 250px; flex-shrink: 0; }
.info-box { background-color: #ffffff; border: 1px solid #dee2e6; border-radius: 4px; margin-bottom: 15px; padding: 15px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); }

/* تایمر */
.timer-box { text-align: center; background-color: #fff3cd; border-color: #ffeeba; }
.timer-display { font-family: monospace; color: #856404; margin: 10px 0 5px; transition: all 0.3s ease; }

/* سوالات */
.question-block { background-color: #ffffff; border: 1px solid #dee2e6; border-radius: 4px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* دکمه ها */
.btn { padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: background-color 0.2s; flex-grow: 1; margin: 0 5px; }
.btn-primary { background-color: #007bff; color: white; }
.btn-secondary { background-color: #6c757d; color: white; }
.btn-submit { background-color: #28a745; color: white; }

/* ==================================================================== */
/* ۳. استایل مدرک (Certificate Page) - شکیل و رسمی */
/* ==================================================================== */

#certificate-page {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px 20px;
    background: linear-gradient(135deg, #f7f7f7 0%, #e0e0e0 100%); /* پس‌زمینه لایت */
    min-height: 100vh;
}

.certificate-box {
    width: 100%;
    max-width: 1000px; /* پهنای بیشتر */
    min-height: 680px;
    background: url('data:image/png;base64,...(یک تصویر با کیفیت بالا برای واترمارک) ') white; /* واترمارک ILI */
    border: 25px solid transparent; 
    border-image: linear-gradient(45deg, #ffc107, #ffd700, #ffc107) 30; /* قاب طلایی گرادیانت */
    padding: 40px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    position: relative;
    font-family: 'Times New Roman', serif;
}

.cert-header {
    color: #8b0000; 
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 15px;
    border-bottom: 4px double #8b0000;
    padding-bottom: 10px;
}

.cert-subheader {
    font-size: 1.2em;
    color: #444;
    margin-bottom: 10px;
    font-style: italic;
}

.cert-title {
    font-size: 3.5em;
    color: #ff8c00; 
    text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1);
    margin: 30px 0 10px;
    font-family: Georgia, serif;
    text-transform: uppercase;
}

.cert-text {
    font-size: 1.3em;
    margin: 20px 0;
    line-height: 2;
}

.cert-name {
    font-size: 3em;
    color: #007bff; 
    font-weight: bold;
    border-bottom: 3px solid #007bff;
    display: inline-block;
    padding: 0 60px 5px;
    margin: 20px 0 40px;
    font-family: cursive, sans-serif;
}

.cert-result-container {
    background-color: #f0f8ff;
    padding: 20px;
    border-radius: 10px;
    border: 1px dashed #007bff;
    margin-top: 30px;
}

.cert-score {
    font-size: 1.8em;
    color: #28a745;
    font-weight: bold;
    margin: 10px 0;
}

.cert-score-grade {
    font-size: 1.5em;
    margin-bottom: 20px;
}

.grade-badge {
    padding: 8px 20px;
    border-radius: 5px;
    font-weight: bold;
    color: white;
    font-size: 1.1em;
}

/* امضا و مهر شبیه‌سازی شده */
.signatures {
    display: flex;
    justify-content: space-around;
    margin-top: 80px;
    padding-top: 20px;
    border-top: 2px solid #ccc;
    position: relative;
}

.signature-block {
    text-align: center;
    font-style: italic;
    color: #555;
    position: relative;
    width: 30%;
}

.signature-block::before {
    content: 'Signature'; 
    font-size: 2em;
    display: block;
    color: #111;
    margin-bottom: 5px;
    opacity: 0.2; /* شبیه سازی اثر قلم */
    font-family: 'Times New Roman', serif;
}

.seal {
    position: absolute;
    top: -50px;
    right: 150px;
    width: 90px;
    height: 90px;
    background-color: #8b0000;
    border-radius: 50%;
    border: 6px double #f0e68c;
    color: white;
    font-size: 1.6em;
    line-height: 78px;
    text-align: center;
    transform: rotate(-10deg);
}
.seal::after {
    content: 'OFFICIAL';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(5deg);
    font-size: 0.5em;
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
}

/* جداول جزئیات */
.cert-details table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
}
.cert-details th, .cert-details td {
    padding: 10px;
    border: 1px solid #ccc;
}
.cert-details th {
    background-color: #f0f0f0;
    font-weight: bold;
    color: #333;
}

/* استایل چاپ (تنظیمات نهایی برای کیفیت) */
@media print {
    body {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background: white !important;
    }
    .page-wrapper, #certificate-page {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }
    .cert-actions, .main-header, #quiz-page, #start-page, #dark-mode-toggle, #sidebar-left {
        display: none !important;
    }
    .certificate-box {
        border: 10px solid #ffc107 !important; 
        padding: 40px !important;
        box-shadow: none !important;
        min-height: 100vh;
        width: 100% !important;
        max-width: none !important;
    }
}
/* ... (سایر کدهای CSS) ... */