/* ==========================================
   CBT UJIAN SEKOLAH - Stylesheet
   ========================================== */
/* @import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap'); */

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #6c757d;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --sidebar-bg: #1a1d3e;
    --sidebar-width: 260px;
    --topbar-height: 60px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    margin: 0;
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.8rem;
    color: var(--primary);
}

.sidebar-nav {
    list-style: none;
    padding: 10px 0;
    margin: 0;
}

.sidebar-nav .nav-heading {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 15px 20px 5px;
    font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(67, 97, 238, 0.2);
    color: #ffffff;
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
}

/* ==========================================
   TOPBAR
   ========================================== */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#sidebarToggle {
    color: #666;
    text-decoration: none;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* ==========================================
   PAGE CONTENT
   ========================================== */
#page-content-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.content-area {
    padding: 0 15px;
}

/* Sidebar toggle */
#wrapper.toggled .sidebar {
    transform: translateX(-100%);
}

#wrapper.toggled #page-content-wrapper {
    margin-left: 0;
    width: 100%;
}

/* ==========================================
   STAT CARDS
   ========================================== */
.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #eee;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card-primary .stat-icon {
    background: rgba(67, 97, 238, 0.12);
    color: var(--primary);
}

.stat-card-success .stat-icon {
    background: rgba(46, 204, 113, 0.12);
    color: var(--success);
}

.stat-card-warning .stat-icon {
    background: rgba(243, 156, 18, 0.12);
    color: var(--warning);
}

.stat-card-info .stat-icon {
    background: rgba(52, 152, 219, 0.12);
    color: var(--info);
}

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
    color: #222;
}

.stat-info p {
    margin: 4px 0 0;
    color: #555;
    font-size: 0.85rem;
}

/* ==========================================
   AUTH PAGES
   ========================================== */
.auth-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-wrapper {
    width: 100%;
    padding: 20px;
}

.auth-container {
    max-width: 440px;
    margin: 0 auto;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 2rem;
    color: #fff;
}

.auth-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 5px;
    color: #333;
}

.auth-header p {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
}

.auth-tabs {
    display: flex;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 4px;
}

.auth-tabs .nav-link {
    flex: 1;
    text-align: center;
    border-radius: 8px;
    color: #666;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 8px 16px;
}

.auth-tabs .nav-link.active {
    background: var(--primary);
    color: #fff;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: #999;
    font-size: 0.8rem;
}

/* ==========================================
   STUDENT DASHBOARD ENHANCEMENTS
   ========================================== */
.student-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 35px 30px;
    color: white;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    margin-bottom: 30px;
}

.student-hero::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
}

.student-hero .hero-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 5px;
    position: relative;
    z-index: 2;
}

.student-hero .hero-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    position: relative;
    z-index: 2;
}

/* Custom styling for available exams card */
.exam-card-modern {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    position: relative;
    background: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.exam-card-modern::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.exam-card-modern:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
}

.exam-card-modern:hover::before {
    transform: scaleX(1);
}

.exam-card-modern .badge {
    padding: 6px 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 8px;
}

/* Soft Badges with High Specificity & Contrast */
.badge.badge-soft-primary {
    background-color: #eef2ff !important;
    color: #3f51b5 !important;
    border: 1px solid #c5cae9 !important;
}

.badge.badge-soft-success {
    background-color: #e8f5e9 !important;
    color: #2e7d32 !important;
    border: 1px solid #c8e6c9 !important;
}

.badge.badge-soft-warning {
    background-color: #fff3e0 !important;
    color: #ef6c00 !important;
    border: 1px solid #ffe0b2 !important;
}


/* ==========================================
   EXAM INTERFACE (MODERN TEMA SAAS / E-LEARNING)
   ========================================== */
.exam-body {
    background: #f0f4f8;
    /* Modern cool grey/blue background */
    min-height: calc(100vh - 70px);
}

.exam-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Prevent text selection/highlighting */
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in inputs and textareas so students can type/highlight their own answers */
.exam-container input,
.exam-container textarea {
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Premium Header Gradient & Glassmorphism */
.exam-header {
    background: rgba(30, 30, 45, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding-top: calc(15px + env(safe-area-inset-top));
    padding-bottom: 15px;
    position: sticky;
    top: 0;
    z-index: 1030;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}

.exam-header h4 {
    letter-spacing: 0.5px;
    background: linear-gradient(120deg, #e0c3fc 0%, #8ec5fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.exam-header h5 {
    letter-spacing: 0.5px;
    color: #e0c3fc;
}

/* Glassmorphism Timer */
.exam-timer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 24px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.exam-timer i {
    font-size: 1.25rem;
    color: #ffd166;
}

.exam-timer.warning {
    background: rgba(243, 156, 18, 0.85) !important;
    border-color: #f39c12;
    animation: none;
    color: white !important;
}

.exam-timer.danger {
    background: rgba(231, 76, 60, 0.9) !important;
    border-color: #e74c3c;
    animation: pulseTimer 1s infinite alternate;
}

@keyframes pulseTimer {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }

    100% {
        transform: scale(1.03);
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
}

/* Sync Status Badge */
.exam-sync-badge {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 15px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    color: white;
}

.exam-sync-badge i {
    font-size: 1.1rem;
}

.exam-sync-badge.sync-success {
    border-color: rgba(46, 204, 113, 0.4);
    background: rgba(46, 204, 113, 0.1);
}

.exam-sync-badge.sync-warning {
    border-color: rgba(243, 156, 18, 0.4);
    background: rgba(243, 156, 18, 0.1);
}

.exam-sync-badge.sync-danger {
    border-color: rgba(231, 76, 60, 0.4);
    background: rgba(231, 76, 60, 0.1);
}

.exam-violation-badge {
    background: #e74c3c;
    color: #fff;
    padding: 6px 16px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.9rem;
    border: none;
    box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}

.exam-body-content {
    flex: 1;
    padding: 24px 0;
}

/* Panel Lembar Soal Utama (Modern Card) */
.exam-question-area {
    background: #fff;
    border: none;
    border-radius: 20px;
    padding: 40px;
    min-height: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

.question-number {
    color: #6c757d;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.question-number::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.question-text {
    font-size: 1.35rem;
    /* Larger font size for better readability */
    line-height: 1.85;
    color: #2b2b40;
    margin-bottom: 35px;
    font-weight: 500;
}

/* Mini Progress Bar (Premium Mobile & Desktop) */
.exam-mini-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #f0f2f5;
    overflow: hidden;
}

.exam-mini-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #9b59b6);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Question Navigator Summary Cards */
.stat-item {
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.exam-nav-buttons {
    transition: all 0.3s ease;
    background: #fff;
    padding-top: 25px;
    margin-top: 40px;
    border-top: 2px solid #f0f2f5;
    position: relative;
}

.exam-nav-buttons .btn {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Desktop Hover Interaction */
@media (min-width: 992px) {
    .exam-nav-buttons .btn:hover {
        transform: translateY(-3px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.1) !important;
    }
    
    .exam-nav-buttons .btn:active {
        transform: translateY(-1px);
    }
}

/* Opsi Pilihan Ganda (Interactive Modern Cards) */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 22px;
    border: 2px solid #eef0f4;
    border-radius: 16px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.option-item:hover {
    border-color: #d1d9e6;
    background: #f8faff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(67, 97, 238, 0.08);
}

.option-item.selected {
    background: rgba(67, 97, 238, 0.04);
    border-color: var(--primary);
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.15);
}

.option-label {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f4f7f6;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #6c757d;
    font-size: 1.15rem;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.option-item.selected .option-label {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.option-text {
    font-size: 1.25rem;
    color: #3f4254;
    width: 100%;
}

/* ==========================================
   QUESTION NAVIGATOR (Modern Grid)
   ========================================== */
.exam-navigator {
    background: #fff;
    border-radius: 20px;
    border: none;
    padding: 24px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
}

.exam-navigator h6 {
    color: #3f4254;
    border-bottom: none;
    padding-bottom: 0;
    text-align: left;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.navigator-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 20px;
}

.nav-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #eef0f4;
    background: #fff;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    color: #6c757d;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: #f8faff;
    border-color: #d1d9e6;
    color: var(--primary);
}

.nav-btn.current {
    border-color: var(--info);
    background: rgba(52, 152, 219, 0.1);
    color: var(--info);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.2);
}

.nav-btn.answered {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2);
}

.nav-btn.answered.current {
    border: 2px solid #229954;
    box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.3);
}

.navigator-legend {
    font-size: 0.85rem;
    color: #a1a5b7;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed #eef0f4;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 6px;
    display: inline-block;
    vertical-align: sub;
}

.legend-dot.empty {
    border: 2px solid #eef0f4;
    background: #fff;
}

.legend-dot.answered {
    background: var(--success);
    box-shadow: 0 2px 6px rgba(46, 204, 113, 0.2);
}

.legend-dot.current {
    background: rgba(52, 152, 219, 0.1);
    border: 2px solid var(--info);
}

/* ==========================================
   TABLE STYLES
   ========================================== */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #333;
}

.table td {
    vertical-align: middle;
}

/* ==========================================
   CARD ENHANCEMENTS
   ========================================== */
.card {
    border-radius: 12px;
}

.card-header {
    padding: 15px 20px;
}

.card-body {
    padding: 20px;
}

/* Modal scrollable fix */
.modal-dialog-scrollable .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* ==========================================
   RESPONSIVE (MOBILE OPTIMIZATIONS)
   ========================================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    #page-content-wrapper {
        margin-left: 0;
        width: 100%;
    }

    #wrapper.toggled .sidebar {
        transform: translateX(0);
    }

    #wrapper.toggled #page-content-wrapper {
        margin-left: 0;
    }

    .exam-navigator {
        position: static;
        margin-top: 20px;
    }
}

@media (max-width: 576px) {
    .auth-card {
        padding: 25px;
    }

    .stat-card {
        padding: 15px;
    }

    /* Massive mobile improvements for exam */
    .exam-question-area {
        padding: 25px 20px;
        border-radius: 16px;
    }

    .exam-header {
        padding-top: calc(5px + env(safe-area-inset-top));
        padding-bottom: 5px;
        min-height: auto !important;
    }

    .exam-header .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .exam-header-icon {
        display: none !important;
    }

    .exam-header h5 {
        display: none !important;
    }

    .exam-header small {
        display: none !important;
    }

    .exam-timer {
        padding: 3px 10px;
        font-size: 0.9rem;
        letter-spacing: 0.5px;
        min-width: 80px;
        justify-content: center;
    }

    .exam-timer i {
        font-size: 0.9rem !important;
    }

    .question-text {
        font-size: 1.25rem;
        margin-bottom: 25px;
    }

    .option-item {
        padding: 14px 15px;
        border-radius: 12px;
    }

    .option-label {
        width: 32px;
        height: 32px;
        font-size: 1.05rem;
    }

    .navigator-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    /* Sticky Bottom Nav on Mobile for faster navigation */
    .exam-nav-buttons {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 12px 15px calc(12px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.08);
        z-index: 1040;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        border-radius: 24px 24px 0 0;
        margin-top: 0;
    }

    .exam-nav-buttons .nav-btn-container {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    .exam-nav-buttons .btn {
        flex: 1;
        font-size: 0.85rem;
        font-weight: 800;
        letter-spacing: 0.5px;
        padding: 16px 10px;
        border-radius: 18px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none !important;
    }

    .exam-nav-buttons .btn:active {
        transform: scale(0.94);
        opacity: 0.9;
    }

    #btn-prev {
        background-color: #f1f3f5 !important;
        color: #495057 !important;
    }

    #btn-next {
        background: linear-gradient(135deg, #e74c3c, #c0392b) !important;
        color: #fff !important;
        box-shadow: 0 6px 15px rgba(231, 76, 60, 0.3) !important;
    }

    .exam-nav-buttons .btn-daftar-soal {
        flex: 0 0 auto;
        width: 58px;
        background: linear-gradient(135deg, #3498db, #2980b9) !important;
        color: white !important;
        border-radius: 18px !important;
        box-shadow: 0 6px 15px rgba(52, 152, 219, 0.3) !important;
    }

    /* Add padding bottom to body so content doesn't get hidden behind sticky nav */
    .exam-body-content .container-fluid,
    .exam-body .container-fluid {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    /* Offcanvas Adjustments */
    .offcanvas-exam-nav {
        border-radius: 20px 20px 0 0;
        height: 80vh !important;
        max-height: none !important;
    }

    .offcanvas-exam-nav .offcanvas-body {
        padding: 0;
    }

    .offcanvas-exam-nav .exam-navigator {
        box-shadow: none;
        padding: 20px;
        top: 0;
        margin-top: 0;
        max-height: none;
    }
}

/* ==========================================
   TYPOGRAPHY ENHANCEMENTS (ARABIC & MATH)
   ========================================== */
.math-render {
    font-family: 'Amiri', 'Noto Naskh Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 2.0;
    font-size: 1.25rem;
    direction: ltr;
    /* Default to LTR for math/mixed content */
    text-align: left;
}

/* Auto-detect Arabic characters and apply RTL + Better Font */
.math-render:contains-arabic,
.math-render[lang="ar"],
.arabic-text {
    font-family: 'Amiri', 'serif';
    direction: rtl;
    text-align: right;
    font-size: 1.8rem;
    line-height: 2.2;
}

/* Helper for mixed content where Arabic should stand out */
[dir="rtl"] {
    font-family: 'Amiri', 'serif';
}