/* =====================================================
   استایل حرفه‌ای فرم آزمون ورودی باقرالعلوم
   نمایش فرمول‌های ریاضی به سبک کتاب‌های درسی ایران
   توسعه یافته توسط: فرخ دائی
   وبسایت: bavs.ir
   نسخه 3.2.0
   ===================================================== */

/* ========== تنظیمات پایه ========== */
.bel-exam-wrapper {
    direction: rtl;
    font-family: 'Vazirmatn FD', 'Vazirmatn', 'Vazir', Tahoma, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(145deg, #f0f4f8 0%, #e2e8f0 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.bel-exam-container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 32px;
    padding: 35px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* ========== مراحل ========== */
.bel-step {
    display: none;
    animation: fadeSlideUp 0.5s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

.bel-step.active {
    display: block;
}

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

/* ========== هدر ========== */
.bel-exam-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, #1a5f7a 0%, #0d3b4f 100%);
    border-radius: 24px;
    color: white;
    position: relative;
    overflow: hidden;
}

.bel-exam-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f5b042, #e8a020, #f5b042);
}

.bel-exam-header h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.bel-subtitle {
    font-size: 15px;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.bel-date-range {
    font-size: 12px;
    margin-top: 8px;
    opacity: 0.8;
    position: relative;
    z-index: 1;
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 16px;
    border-radius: 30px;
}

/* ========== باکس ثبت‌نام ========== */
.bel-registration-box {
    background: white;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.bel-registration-box h3 {
    font-size: 22px;
    font-weight: 700;
    color: #1a5f7a;
    margin-bottom: 6px;
}

/* ========== فرم ========== */
.bel-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.bel-form-group {
    flex: 1;
}

.bel-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c4a5e;
    font-size: 13px;
}

.bel-form-group label .required {
    color: #e67e22;
    margin-right: 3px;
}

.bel-form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2edf2;
    border-radius: 16px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #fafcff;
}

.bel-form-group input:focus {
    outline: none;
    border-color: #f5b042;
    box-shadow: 0 0 0 3px rgba(245, 176, 66, 0.1);
    background: white;
}

.bel-form-group input:invalid {
    border-color: #ef4444;
}

.bel-form-group small {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #7f9eb0;
}

/* ========== باکس اطلاعات ========== */
.bel-info-box {
    background: #fef9e8;
    border-right: 4px solid #f5b042;
    padding: 18px 24px;
    border-radius: 20px;
    margin: 25px 0;
}

.bel-info-box-warning {
    background: #fff3cd;
    border-right-color: #ffc107;
}

.bel-info-box-danger {
    background: #f8d7da;
    border-right-color: #dc3545;
}

.bel-info-box h4 {
    margin: 0 0 12px 0;
    color: #a05e15;
    font-size: 15px;
}

.bel-info-box ul {
    margin: 0;
    padding-right: 20px;
}

.bel-info-box li {
    margin: 8px 0;
    color: #6b4e1a;
    font-size: 13px;
}

/* ========== دکمه‌ها ========== */
.bel-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 60px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    position: relative;
    overflow: hidden;
}

.bel-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.bel-btn:hover::before {
    width: 200%;
    height: 200%;
}

.bel-btn-primary {
    background: linear-gradient(105deg, #e8a020 0%, #f5b042 100%);
    color: white;
    width: 100%;
    max-width: 300px;
    display: block;
    margin: 30px auto 10px;
    font-size: 18px;
    padding: 15px 28px;
    box-shadow: 0 10px 20px -5px rgba(245, 176, 66, 0.4);
}

.bel-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 28px -8px rgba(245, 176, 66, 0.5);
}

.bel-btn-primary:disabled {
    opacity: 0.65;
    transform: none;
    cursor: not-allowed;
}

.bel-btn-secondary {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #1a5f7a;
    border: 1px solid #cbd5e1;
    border-radius: 40px;
    padding: 10px 24px;
    font-weight: 600;
}

.bel-btn-secondary:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bel-btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    border-radius: 40px;
    padding: 12px 32px;
    font-size: 16px;
}

.bel-btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

/* ========== تایمر و شمارنده ========== */
.bel-exam-header .bel-timer-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 24px;
    font-weight: 700;
    font-family: 'Vazirmatn FD', monospace;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    direction: ltr;
}

.bel-exam-header .bel-question-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    margin-right: 12px;
    font-size: 15px;
    font-weight: 600;
}

/* هدر بخش آزمون */
.bel-exam-header .bel-header-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* ========== باکس سوال ========== */
.bel-question-box {
    background: white;
    border-radius: 24px;
    padding: 30px;
    margin: 20px 0;
    border: 1px solid #eef3f7;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

/* ========== فرمول‌های ریاضی حرفه‌ای - نسخه نهایی ========== */

/* کانتینر فرمول‌ها */
.bel-question-text .math-display,
.bel-option-text .math-display {
    width: 100%;
    display: inline-block;
}

/* فرمول‌های بلوکی - نمایش کامل و خوانا با پشتیبانی از چندخطی */
.bel-question-text mjx-container[display="true"],
.bel-question-text .MathJax_Display,
.math-display mjx-container[display="true"] {
    display: block !important;
    text-align: center !important;
    margin: 25px auto !important;
    padding: 20px 24px !important;
    background: #f8fafc !important;
    border-radius: 16px !important;
    font-size: 1.15em !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    border-right: 4px solid #f5b042 !important;
    line-height: 2.2 !important;
    direction: ltr !important;
    max-width: 100%;
    white-space: normal !important;
    word-break: break-word;
    font-family: 'Times New Roman', 'STIXGeneral', 'MathJax_Main', serif !important;
}

/* فرمول‌های درون خطی */
.bel-question-text mjx-container,
.bel-question-text .MathJax,
.math-display mjx-container {
    display: inline-block !important;
    vertical-align: middle !important;
    font-size: 1.05em !important;
    background: transparent !important;
    direction: ltr !important;
}

/* گزینه‌های پاسخ - فرمول‌ها */
.bel-option-text mjx-container,
.bel-option-text .MathJax {
    display: inline-block !important;
    vertical-align: middle !important;
    font-size: 0.95em !important;
    background: transparent !important;
    direction: ltr !important;
}

/* آرایه‌ها و موارد چندخطی (مانند \begin{array}) */
mjx-mtable {
    margin: 20px auto !important;
    text-align: center !important;
}

mjx-mtd {
    padding: 8px 12px !important;
}

/* براکت‌ها و پرانتزهای بزرگ (مانند \left\{ و \right\}) */
mjx-mo[stretchy="true"] {
    font-size: 1.2em !important;
}

/* کسرها - بزرگ و خوانا */
mjx-mfrac {
    font-size: 1.15em !important;
    margin: 4px 0 !important;
}

/* رادیکال‌ها */
mjx-msqrt,
mjx-mroot {
    font-size: 1.08em !important;
}

/* توان‌ها و زیرنویس‌ها */
mjx-msub,
mjx-msup,
mjx-msubsup {
    font-size: 0.92em !important;
}

/* مجموعه‌ها (مانند { ... }) */
mjx-mrow {
    font-size: 1em !important;
}

/* مخفی کردن المنت‌های موقت MathJax */
.MathJax_Preview,
.mjx-error,
.MathJax .merror,
mjx-merror,
.MathJax_Error,
.MathJax_Processing,
.mathjax-preview {
    display: none !important;
}

/* اسکرول بار سفارشی برای فرمول‌های طولانی */
.bel-question-text::-webkit-scrollbar,
.math-display::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.bel-question-text::-webkit-scrollbar-track,
.math-display::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.bel-question-text::-webkit-scrollbar-thumb,
.math-display::-webkit-scrollbar-thumb {
    background: #f5b042;
    border-radius: 10px;
}

/* ========== متن سوال ========== */
.bel-question-text {
    font-size: 18px;
    line-height: 1.85;
    color: #1e293b;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eef3f7;
    font-weight: 500;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
}

/* ========== گزینه‌های پاسخ ========== */
.bel-options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bel-option {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    background: #fbfefd;
    border: 2px solid #e2edf2;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.bel-option:hover {
    background: #fef9e8;
    border-color: #f5b042;
    transform: translateX(-5px);
}

.bel-option.selected {
    background: linear-gradient(135deg, #fef9e8 0%, #fdf4dc 100%);
    border-color: #f5b042;
}

.bel-option input[type="radio"] {
    margin-left: 15px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #f5b042;
    flex-shrink: 0;
}

.bel-option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #1a5f7a 0%, #0d3b4f 100%);
    color: white;
    border-radius: 30px;
    font-weight: bold;
    margin-left: 12px;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(26, 95, 122, 0.3);
}

.bel-option-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.6;
    color: #2c4a5e;
    word-break: break-word;
}

/* ========== نوار پیشرفت ========== */
.bel-progress-bar {
    background: #e2edf2;
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin: 20px 0;
}

.bel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f5b042 0%, #e8a020 100%);
    transition: width 0.3s ease;
    border-radius: 10px;
    position: relative;
}

/* ========== ناوبری سوالات ========== */
.bel-navigation {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
    flex-wrap: wrap;
}

/* ========== نمای کلی سوالات ========== */
.bel-questions-overview-box {
    background: #f8fbfd;
    border-radius: 20px;
    padding: 18px;
    margin-top: 20px;
}

.bel-questions-overview-box h4 {
    color: #1a5f7a;
    margin-bottom: 12px;
    font-size: 16px;
}

.bel-questions-overview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.bel-ov-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #cde0e8;
    background: white;
    border-radius: 16px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    font-family: 'Vazirmatn FD', monospace;
    transition: all 0.2s;
    color: #1a5f7a;
}

.bel-ov-btn:hover {
    border-color: #f5b042;
    transform: scale(1.05);
}

.bel-ov-btn.answered {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #10b981;
}

.bel-ov-btn.current {
    background: linear-gradient(135deg, #f5b042 0%, #e8a020 100%);
    color: white;
    border-color: #f5b042;
    box-shadow: 0 0 0 3px rgba(245, 176, 66, 0.3);
}

.bel-legend {
    font-size: 12px;
    display: flex;
    gap: 16px;
    justify-content: center;
    color: #475569;
}

.bel-legend-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 6px;
    margin-left: 5px;
    vertical-align: middle;
}

.bel-legend-box.current {
    background: #f5b042;
}

.bel-legend-box.answered {
    background: #10b981;
}

.bel-legend-box.unanswered {
    background: #e2e8f0;
}

/* ========== پیام‌ها ========== */
.bel-message {
    padding: 15px 20px;
    border-radius: 16px;
    margin-top: 20px;
    display: none;
    font-size: 14px;
    line-height: 1.6;
}

.bel-message.success {
    display: block;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.bel-message.error {
    display: block;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.bel-message.info {
    display: block;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ========== Toast Notifications ========== */
.bel-toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 12px 24px;
    border-radius: 50px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 100000;
    animation: slideInLeft 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.bel-toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.bel-toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.bel-toast-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.bel-toast-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========== باکس نتیجه ========== */
.bel-result-box {
    background: white;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.bel-result-box h2 {
    color: #10b981;
    margin-bottom: 20px;
}

.bel-success-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.bel-result-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.bel-stat-item {
    background: linear-gradient(135deg, #1a5f7a 0%, #0d3b4f 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 20px;
    min-width: 150px;
}

.bel-stat-label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.bel-stat-value {
    font-size: 32px;
    font-weight: bold;
    font-family: 'Vazirmatn FD', monospace;
}

.bel-result-message {
    background: #f8fafc;
    padding: 20px;
    border-radius: 16px;
    margin-top: 20px;
    color: #475569;
}

/* ========== لودینگ ========== */
.bel-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.bel-loading-overlay div {
    color: white;
    font-size: 16px;
}

.bel-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #f5b042;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== ریسپانسیو موبایل ========== */
@media (max-width: 768px) {
    .bel-exam-container {
        padding: 12px !important;
        border-radius: 20px !important;
    }
    
    .bel-exam-header {
        padding: 16px 12px !important;
    }
    
    .bel-exam-header h2 {
        font-size: 18px !important;
    }
    
    .bel-timer-box {
        font-size: 18px !important;
        padding: 6px 14px !important;
    }
    
    .bel-question-counter {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
    
    .bel-question-text {
        font-size: 15px !important;
    }
    
    .bel-question-text mjx-container[display="true"],
    .bel-question-text .MathJax_Display,
    .math-display mjx-container[display="true"] {
        font-size: 0.9em !important;
        padding: 12px 16px !important;
        margin: 15px auto !important;
    }
    
    mjx-mtd {
        padding: 4px 6px !important;
    }
    
    .bel-option {
        padding: 8px 12px !important;
    }
    
    .bel-option-letter {
        width: 28px !important;
        height: 28px !important;
        font-size: 13px !important;
    }
    
    .bel-option-text {
        font-size: 13px !important;
    }
    
    .bel-ov-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 13px !important;
    }
    
    .bel-navigation {
        gap: 10px !important;
    }
    
    .bel-btn-secondary,
    .bel-btn-success {
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
    
    .bel-stat-item {
        padding: 12px 16px !important;
        min-width: 100px !important;
    }
    
    .bel-stat-value {
        font-size: 20px !important;
    }
}

@media (max-width: 480px) {
    .bel-exam-container {
        padding: 8px !important;
    }
    
    .bel-question-text {
        font-size: 14px !important;
    }
    
    .bel-ov-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
}

/* ========== حالت پرینت ========== */
@media print {
    .bel-exam-wrapper {
        background: white;
        padding: 0;
    }
    .bel-timer-box,
    .bel-navigation,
    .bel-questions-overview-box,
    .bel-progress-bar,
    .bel-btn {
        display: none !important;
    }
    
    .bel-question-text mjx-container[display="true"],
    .bel-question-text .MathJax_Display {
        background: none !important;
        box-shadow: none !important;
        border-right: none !important;
        padding: 10px 0 !important;
        margin: 10px 0 !important;
    }
}