/* ==========================================
   ************** 1. الخطوط المحلية **************
   ========================================== */
@font-face {
    font-family: 'CairoLocal';
    src: url('Cairo-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'AlMohanadLocal';
    src: url('al-mohanad.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ==========================================
   ************** 2. التنسيقات الأساسية (Base) **************
   ========================================== */
body {
    font-family: 'CairoLocal', sans-serif !important;
    line-height: 1.4;
}

/* منع الخطوط العربية من السيطرة على أيقونات Font Awesome */
i, .fa, .fas, .fab, .far {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands", sans-serif !important;
    font-style: normal !important;
}

[dir="rtl"] { text-align: right; }

/* فئات عامة للاتجاه */
.ltr-text { direction: ltr; text-align: left; }
.rtl-text { direction: rtl; text-align: right; }

/* ==========================================
   ************** 3. أزرار الخيارات وبطاقات الأسئلة **************
   ========================================== */
.question-card, .qa-concept-card {
    transition: transform .18s ease, box-shadow .18s ease;
    border-radius: 14px;
}
.question-card { border: 1px solid #d1d5db; }
.qa-concept-card { border: 1px solid #60a5fa; }

.question-card:hover, .qa-concept-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(16,24,40,0.06);
}
.dark .question-card:hover, .dark .qa-concept-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* إطارات الحالة */
.frame-neutral { border: 1px solid #d1d5db !important; }
.frame-red    { border: 1px solid #ef4444 !important; }
.frame-green  { border: 1px solid #10b981 !important; }
.frame-yellow { border: 1px solid #f59e0b !important; }
.frame-blue   { border: 1px solid #3b82f6 !important; }
.frame-purple { border: 1px solid #8b5cf6 !important; }

/* أزرار الخيارات */
.option-btn {
    transition: transform .08s ease, background .18s ease, border-color .18s ease, opacity .2s ease;
    direction: rtl;
    text-align: right;
}
.option-btn:active { transform: scale(.99); }
.option-btn:disabled { cursor: default; }
.option-btn.faded { opacity: .55; }

.option-label {
    min-width: 32px; min-height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9999px; background: #e0f7fa; color: #059669;
    font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0; margin-left: 0.75rem;
}
.option-btn .flex-1 { direction: rtl; text-align: right; }

/* الحالات: صحيح / خطأ */
.is-correct {
    background: #ecfdf5 !important;
    border-color: #4ade80 !important;
    color: #065f46 !important;
}
.dark .is-correct {
    background: #064e3b !important;
    border-color: #34d399 !important;
    color: #a7f3d0 !important;
}
.is-wrong {
    background: #fff1f2 !important;
    border-color: #f87171 !important;
    color: #7f1d1d !important;
}
.dark .is-wrong {
    background: #7f1d1d !important;
    border-color: #fca5a5 !important;
    color: #fecaca !important;
}
.is-correct .option-label { background: #16a34a !important; color: white !important; }
.is-wrong .option-label   { background: #dc2626 !important; color: white !important; }

/* تحسينات إضافية للخيارات الصحيحة والخاطئة */
.option-btn.is-correct {
    background-color: #ecfdf5 !important;
    border-color: #059669 !important;
    border-width: 1px !important;
    opacity: 1 !important;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}
.option-btn.is-wrong {
    background-color: #fff1f2 !important;
    border-color: #e11d48 !important;
    opacity: 0.9 !important;
}
.dark .option-btn.is-correct {
    background-color: rgba(6, 78, 59, 0.4) !important;
    border-color: #34d399 !important;
    color: #ecfdf5 !important;
}
.dark .option-btn.is-wrong {
    background-color: rgba(159, 18, 57, 0.4) !important;
    border-color: #fb7185 !important;
    color: #fff1f2 !important;
}

/* اختيار متعدد */
.multi-selected {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: #3b82f6 !important;
}
.dark .multi-selected {
    background: rgba(59, 130, 246, 0.3) !important;
    border-color: #3b82f6 !important;
}

/* أزرار التحقق متعدد */
.check-multi-btn.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background-color: #9ca3af !important;
}
.check-multi-btn.enabled {
    opacity: 1 !important;
    cursor: pointer !important;
    background-color: #059669 !important;
}

/* ==========================================
   ************** 4. الشريط العلوي الثابت **************
   ========================================== */
#fixedTopBar {
    position: fixed; width: 100%; top: 0;
    padding: 4px 10px; min-height: 44px;
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    backdrop-filter: blur(4px);
    border-bottom: 1px solid #e2e8f0;
    z-index: 9999;
}
.dark #fixedTopBar {
    background-color: rgba(17, 24, 39, 0.98);
    border-bottom: 1px solid #374151;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    color: #f3f4f6;
}

#progressFillTop {
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.shimmer-effect {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: translateX(-100%); pointer-events: none;
}
.animate-shimmer { animation: progress-shimmer 2s ease-in-out; }
@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==========================================
   ************** 5. البحث الذكي (Search) **************
   ========================================== */
.search-highlight {
    background-color: #fef08a;
    color: #1e293b;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.search-highlight-input {
    background-color: rgba(254, 240, 138, 0.2) !important;
    border-color: #eab308 !important;
    box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.1) !important;
}
.search-match-highlight {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}
#searchResultsInfo {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #93c5fd;
    color: #1e40af;
}
.dark .search-highlight {
    background-color: #854d0e;
    color: #fef9c3;
}
.dark .search-highlight-input {
    background-color: rgba(133, 77, 14, 0.2) !important;
    border-color: #a16207 !important;
}
.dark .search-match-highlight {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}
.dark #searchResultsInfo {
    background: linear-gradient(135deg, #1e3a5f, #1e40af);
    border-color: #3b82f6;
    color: #bfdbfe;
}

/* ==========================================
   ************** 6. المفضلة (Favorites) **************
   ========================================== */
.favorite-btn {
    transition: all 0.2s ease;
    color: #d1d5db;
}
.favorite-btn.active { color: #f59e0b; text-shadow: 0 0 8px rgba(245, 158, 11, 0.5); }
.favorite-btn:hover { transform: scale(1.1); }

.favorite-card {
    border-color: #f59e0b !important;
    background: linear-gradient(to left, #fffbeb, #fef3c7) !important;
}
.dark .favorite-card {
    background: linear-gradient(to left, #78350f, #92400e) !important;
    border-color: #f59e0b !important;
}

/* ==========================================
   ************** 7. النوافذ المنبثقة (Modals) **************
   ========================================== */
.modal-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 10000;
    opacity: 0; visibility: hidden;
    transition: 0.25s;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(25px) scale(0.95);
    opacity: 0;
    transition: 0.3s;
    max-height: 90vh; overflow: auto;
    direction: rtl;
}
.modal-overlay.active .modal-content { transform: none; opacity: 1; }
.dark .modal-content {
    background: rgba(17, 24, 39, 0.9);
    border-color: rgba(75, 85, 99, 0.4);
}

/* ==========================================
   ************** 8. إدارة المستخدمين (الأزرار – الجداول – القوائم) **************
   ========================================== */
/* الأزرار الإدارية العامة */
.admin-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    transition: all 0.3s ease;
}
.admin-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4); }

.edit-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.delete-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.action-btn {
    padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: bold;
    transition: all 0.2s ease;
    display: flex; align-items: center; gap: 5px;
    border: none; cursor: pointer;
}
.action-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.action-btn:active { transform: scale(0.95); }

/* صورة المستخدم (أفاتار) */
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s ease;
}
.user-avatar:hover { transform: scale(1.1); }

/* القائمة المنسدلة للمستخدم */
.user-dropdown {
    position: absolute; top: 100%; left: 0; margin-top: 10px;
    background: white; border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    min-width: 200px; z-index: 9999 !important;
    display: none;
}
.user-dropdown.show { display: block; }
.dark .user-dropdown { background: #1f2937; border-color: #374151; }

.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; color: #374151;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f9fafb; }
.dark .dropdown-item {
    color: #d1d5db; border-bottom: 1px solid #374151;
}
.dark .dropdown-item:hover { background: #374151; }

/* جداول المستخدمين */
.users-table {
    width: 100%; border-collapse: collapse; margin-top: 20px;
}
.users-table th {
    background: #f8fafc; padding: 12px; text-align: right;
    font-weight: 600; border-bottom: 2px solid #e2e8f0;
}
.users-table td { padding: 12px; border-bottom: 1px solid #e2e8f0; }
.users-table tr:hover { background: #f8fafc; }

.dark .users-table th {
    background: #1e293b; border-bottom: 2px solid #334155;
}
.dark .users-table td { border-bottom: 1px solid #334155; }
.dark .users-table tr:hover { background: #1e293b; }

/* صفحة إدارة المستخدمين */
#usersManagementView {
    min-height: 100vh;
    background: linear-gradient(to bottom, #f8fafc, #e2e8f0);
}
.dark #usersManagementView {
    background: linear-gradient(to bottom, #0f172a, #1e293b);
}
#usersManagementView table { min-width: 1000px; }
#usersManagementView th, #usersManagementView td {
    padding: 12px 16px; vertical-align: middle;
}
#usersManagementView th {
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600; color: #4b5563;
}
.dark #usersManagementView th {
    border-bottom: 2px solid #374151;
    color: #d1d5db;
}
#usersManagementView tbody tr { transition: background-color 0.2s; }
#usersManagementView tbody tr:hover { background-color: #f9fafb; }
.dark #usersManagementView tbody tr:hover { background-color: #374151; }

#usersManagementView .grid > div {
    transition: transform 0.2s;
}
#usersManagementView .grid > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.users-management-container {
    padding: 20px; max-width: 1400px; margin: 0 auto;
}

/* أزرار الإجراءات داخل صفوف الجدول */
.user-actions {
    display: flex; gap: 6px; flex-wrap: nowrap;
}
.user-actions button {
    padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
    transition: all 0.2s; white-space: nowrap; border: none; cursor: pointer; color: white;
}
.user-actions button:hover {
    transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* تحسين عرض العمود الأخير (الإجراءات) ليكون أفقياً مرناً */
td.actions-cell,
td:last-child {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-width: 220px !important;
}
td.actions-cell button,
td.actions-cell a,
td:last-child button {
    margin: 0 !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    flex: 1 !important;
}

/* أيقونات المستخدمين حسب الدور */
.user-icon {
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.user-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.icon-super_admin { background: linear-gradient(135deg, #f59e0b, #d97706); }
.icon-admin       { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.icon-editor      { background: linear-gradient(135deg, #10b981, #059669); }
.icon-student     { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* ==========================================
   ************** 9. سجل النشاط (Activity Log) **************
   ========================================== */
.activity-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.activity-badge-add     { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.activity-badge-edit    { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.activity-badge-delete  { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.activity-badge-restore { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }

.activity-action-btn {
    padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
    transition: all 0.2s; display: flex; align-items: center; gap: 5px;
    border: none; cursor: pointer; color: white; width: 100%;
}
.activity-action-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.restore-btn            { background: linear-gradient(135deg, #10b981, #059669); }
.delete-permanent-btn   { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* ==========================================
   ************** 10. القراءة الصوتية (TTS) **************
   ========================================== */
.tts-btn {
    transition: all 0.2s ease;
    cursor: pointer;
}
.tts-btn:hover { transform: scale(1.05); }
.tts-btn:active { transform: scale(0.95); }

.tts-controls {
    position: fixed; bottom: 20px; left: 20px; right: 20px;
    z-index: 1000; display: none;
    animation: slideUp 0.3s ease-out;
}
@media (min-width: 768px) {
    .tts-controls { left: auto; right: 20px; width: 380px; }
}
@keyframes slideUp {
    from { transform: translateY(100px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.speed-dropdown { position: relative; display: inline-block; }
.speed-btn {
    background: #4f46e5; color: white;
    padding: 8px 12px; border-radius: 12px; font-size: 13px; font-weight: bold;
    display: flex; align-items: center; gap: 6px;
    cursor: pointer;
}
.speed-btn:hover { background: #4338ca; transform: scale(1.02); }
.speed-menu {
    position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
    background: white; border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
    overflow: hidden; min-width: 120px; display: none; z-index: 100;
}
.speed-menu.show { display: block; animation: slideUp 0.2s ease-out; }
.speed-option {
    padding: 8px 16px; cursor: pointer; text-align: center; color: #1f2937;
}
.speed-option:hover { background: #e0e7ff; }
.speed-option.active { background: #4f46e5; color: white; }

.reading-now {
    transform: scale(1.02) !important;
    box-shadow: 0 20px 25px -12px rgba(0,0,0,0.25) !important;
    border: 2px solid #f59e0b !important;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
    position: relative; z-index: 10;
}
.reading-now::before {
    content: "🔊";
    position: absolute; top: -10px; right: -10px;
    background: #f59e0b; color: white;
    border-radius: 50%; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 🆕 اتجاه صف أزرار TTS */
.tts-action-row {
    direction: ltr !important;
}
.tts-action-row > * {
    direction: rtl !important;
}

/* 🆕 تأثير تنشيط زر التكرار */
.active-repeat {
    border-color: #4f46e5 !important;
    color: #4f46e5 !important;
    background-color: rgba(79, 70, 229, 0.06) !important;
}
.dark .active-repeat {
    border-color: #818cf8 !important;
    color: #818cf8 !important;
    background-color: rgba(129, 140, 248, 0.12) !important;
}

/* 🆕 تجميل إشعارات TTS */
.tts-toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastSlideIn 0.25s ease-out forwards;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 🆕 حل مشكلة تفعيل زر السرعة */
.speed-dropdown.open .speed-btn {
    border-color: #4f46e5 !important;
    background-color: rgba(79, 70, 229, 0.05) !important;
    color: #4f46e5 !important;
}
.dark .speed-dropdown.open .speed-btn {
    border-color: #818cf8 !important;
    background-color: rgba(129, 140, 248, 0.1) !important;
    color: #818cf8 !important;
}

/* ==========================================
   ************** 11. البطاقات المقالية (QA / المفاهيم) **************
   ========================================== */
.qa-concept-card {
    border-right: 5px solid #1e40af !important;
    background: linear-gradient(to left, #ffffff, #fcfcfc);
}
.dark .qa-concept-card {
    background: linear-gradient(to left, #1f2937, #111827);
    border-right-color: #3b82f6 !important;
}
.qa-concept-card p { text-align: justify; text-justify: inter-word; }
.qa-concept-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.02);
}
.qa-concept-card .favorite-btn {
    border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}
.qa-concept-card .favorite-btn:hover {
    background-color: rgba(139, 92, 246, 0.1);
    transform: scale(1.05);
}

.qa-header-card, .qa-note-card {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.qa-header-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}
.qa-note-card {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
    color: white !important;
}
.qa-header-card::before, .qa-note-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}
.qa-header-card:hover::before, .qa-note-card:hover::before {
    transform: translateX(100%);
}
.qa-header-card:hover, .qa-note-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* 🆕 تلوين خاص لوحدة الترجمة */
.qa-header-card[data-unit-type="translation"] {
    background: linear-gradient(135deg, #059669, #0d9488, #14b8a6) !important;
}
.qa-note-card[data-unit-type="translation"] {
    background: linear-gradient(135deg, #d97706, #ea580c, #f97316) !important;
}

.qa-action-buttons { display: flex; gap: 8px; margin-top: 12px; }
.qa-action-buttons button {
    transition: all 0.2s ease;
    font-weight: 600;
}
.qa-action-buttons button:hover { transform: translateY(-2px); }

/* 🆕 نموذج الإجابة */
.model-answer {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-right: 4px solid #22c55e;
}
.dark .model-answer {
    background: linear-gradient(135deg, #14532d 0%, #166534 100%);
    border-right-color: #4ade80;
}

/* 🆕 تمييز بطاقة الترجمة */
.translation-card-highlight { transition: all 0.3s ease; }
.translation-card-highlight:focus-within {
    box-shadow: 0 0 0 2px #6366f1, 0 0 0 4px rgba(99, 102, 241, 0.2);
}

/* 🆕 تكبير خط التفسير في وحدة الترجمة */
.translation-card .result-area .bg-gray-50,
.translation-card .result-area .bg-gray-50\/50,
#questionsList .question-card .result-area div[class*="bg-gray-50"],
#questionsList .question-card .result-area .text-sm:not(.text-xs) {
    font-size: 16px !important;
    line-height: 1.5 !important;
}
#questionsList .question-card .result-area .bg-gray-50 div,
#questionsList .question-card .result-area .bg-gray-50\/50 div {
    font-size: 16px !important;
}
#questionsList .question-card .result-area .text-sm {
    font-size: 16px !important;
}

/* ==========================================
   ************** 12. النماذج والحقول **************
   ========================================== */
.form-input {
    width: 100%; padding: 10px 15px;
    border: 1px solid #d1d5db; border-radius: 8px;
    background: white; color: #1f2937;
    transition: all 0.2s;
}
.form-input:focus {
    outline: none; border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.dark .form-input {
    background: #374151; border-color: #4b5563; color: white;
}

textarea {
    resize: vertical; min-height: 60px; max-height: 400px;
    overflow-y: auto; transition: height 0.2s ease;
}

/* 🆕 إزالة خيار عند التمرير */
.remove-option:hover {
    transform: scale(1.1); background: #fee2e2 !important;
    box-shadow: 0 2px 5px rgba(220, 38, 38, 0.2);
}

.password-strength { height: 4px; border-radius: 4px; margin-top: 6px; }
.strength-weak  { background: linear-gradient(90deg, #ef4444 25%, #e5e7eb 0); }
.strength-medium{ background: linear-gradient(90deg, #f59e0b 50%, #e5e7eb 0); }
.strength-strong{ background: linear-gradient(90deg, #10b981 75%, #e5e7eb 0); }
.strength-very-strong { background: #3b82f6; }

.validation-message { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.validation-success { color: #10b981; }
.validation-error   { color: #ef4444; }

/* تنسيقات نماذج إدارة المحتوى */
#contentFormContainer input,
#contentFormContainer textarea,
#contentFormContainer select { direction: rtl; text-align: right; }
#optionsContainer textarea { direction: rtl; text-align: right; }
#contentFormContainer .peer:checked~div { transform: scale(1.03); }
#contentFormContainer .w-16.h-16:hover { transform: scale(1.05) rotate(4deg); }

/* 🆕 نافذة إدارة المحتوى */
.content-modal-content { width: 95% !important; max-width: 850px !important; margin: 0 auto !important; }

/* ==========================================
   ************** 13. معالجة KaTeX والمعادلات الطويلة **************
   ========================================== */
.katex-display {
    direction: ltr !important;
    text-align: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-width: 100%;
    padding: 0.5rem 0.25rem;
    margin: 1rem 0;
}
.katex-display::-webkit-scrollbar { height: 5px; }
.katex-display::-webkit-scrollbar-thumb { background-color: #94a3b8; border-radius: 4px; }
.dark .katex-display::-webkit-scrollbar-thumb { background-color: #475569; }

.math-rtl { direction: rtl !important; text-align: right !important; }
.math-ltr { direction: ltr !important; text-align: center !important; }
.math-rtl .vlist-t, .math-rtl .vlist-b, .math-rtl .vlist { direction: ltr !important; }

.katex .text {
    direction: rtl !important;
    unicode-bidi: embed;
    white-space: nowrap;
}

/* ضبط الجداول والمعادلات في إدارة المحتوى */
#contentManagementView .question-card,
#contentManagementView .explanation-section,
#contentManagementView .explanation-text {
    overflow-x: auto !important;
    max-width: 100%;
}
.overflow-x-auto { overflow-x: auto !important; max-width: 100%; }
table {
    min-width: 400px;
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}
@media (max-width: 640px) {
    .explanation-steps table { font-size: 0.7rem; }
    .explanation-steps th, .explanation-steps td { padding: 4px; }
}

/* ==========================================
   ************** 14. الإشعارات (Toast) **************
   ========================================== */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 10001;
    display: flex; flex-direction: column; gap: 10px;
}
.toast {
    padding: 12px 20px; border-radius: 10px;
    color: white; font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease-out;
    display: flex; align-items: center; gap: 10px;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
.toast-success { background: #10b981; }
.toast-error   { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info    { background: #3b82f6; }

/* ==========================================
   ************** 15. 🆕 منطقة التفسير **************
   ========================================== */
.explanation-section {
    animation: fadeInUp 0.3s ease-out;
}
.explanation-text {
    line-height: 1.6;
}
.explanation-text p {
    margin-bottom: 0.5rem;
}
.explanation-text p:last-child {
    margin-bottom: 0;
}
.explanation-text ul,
.explanation-text ol {
    padding-right: 1.5rem;
    margin: 0.5rem 0;
}
.explanation-text li {
    margin-bottom: 0.25rem;
}
.explanation-section .fa-lightbulb {
    transition: all 0.2s ease;
}
.question-card:hover .explanation-section .fa-lightbulb {
    transform: scale(1.1);
    color: #8b5cf6;
}
.question-card:has(.explanation-section) {
    border-bottom: 2px solid #8b5cf6;
}

/* تنسيق منطقة التفسير في البطاقات الملونة */
.qa-header-card .explanation-section,
.qa-note-card .explanation-section {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-top: 0.5rem;
}
.qa-header-card .explanation-section:hover,
.qa-note-card .explanation-section:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* ==========================================
   ************** 16. 🆕 مؤشر التحميل العام **************
   ========================================== */
#globalLoadingIndicator {
    transform: translateY(-150%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.loading-spinner-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#refreshDataBtn {
    transition: all 0.3s ease;
}
#refreshDataBtn:active {
    transform: rotate(180deg);
}
.question-card.loading {
    opacity: 0.5;
    pointer-events: none;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
#globalLoadingIndicator .loading-spinner-small svg {
    animation: spin 0.8s linear infinite;
}

/* ==========================================
   ************** 17. 🆕 حركات إضافية **************
   ========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   ************** 18. تحسينات الشاشات الصغيرة **************
   ========================================== */
@media (max-width: 640px) {
    .qa-concept-card { padding: 1rem !important; }
    .qa-concept-card .w-8.h-8 { width: 1.75rem; height: 1.75rem; font-size: 0.75rem; min-width: 1.75rem; min-height: 1.75rem; }
    .qa-concept-card h4 { font-size: 0.9rem; }
    .modal-content { margin: 1rem; padding: 1.2rem !important; }
}
@media (max-width: 480px) {
    .qa-concept-card .flex.items-start.gap-3 { gap: 0.75rem !important; }
    .qa-concept-card .w-8.h-8 { width: 1.5rem; height: 1.5rem; font-size: 0.7rem; min-width: 1.5rem; min-height: 1.5rem; }
    .qa-concept-card h4 { font-size: 0.85rem; }
}
/* ==========================================
   ************** 19. 🆕 إصلاحات وحدة الترجمة **************
   ========================================== */

/* --- 19.1 إصلاح الشريط العلوي الثابت --- */
#fixedTopBar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 50 !important;
    width: 100% !important;
}

/* إضافة مساحة للشريط العلوي في وحدة الترجمة */
body.translation-active #questionsList {
    padding-top: 60px;
}

/* --- 19.2 إصلاحات حقول الإدخال في الوضع الليلي --- */

/* التنسيق الافتراضي للوضع الفاتح */
input:focus, 
textarea:focus {
    color: #111827 !important;
    background-color: #ffffff !important;
}

/* عند التركيز في الوضع الليلي */
.dark input:focus, 
.dark textarea:focus {
    background-color: #1f2937 !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

/* تأكيد على حقول الترجمة تحديداً */
.dark textarea[id^="trans-answer-"]:focus {
    background-color: #1f2937 !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

/* حالة التعطيل في الوضع الليلي */
.dark textarea:disabled,
.dark textarea[disabled] {
    background-color: #374151 !important;
    color: #d1d5db !important;
}

/* إصلاح placeholder في الوضع الليلي */
.dark textarea::placeholder,
.dark input::placeholder {
    color: #9ca3af !important;
}

/* --- 19.3 تحسينات عامة لوحدة الترجمة --- */

/* تحسين مظهر حقول الترجمة */
textarea[id^="trans-answer-"] {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* تحسين مظهر النتيجة */
.result-area {
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

/* تحسين أزرار التحقق */
.check-trans-btn {
    transition: all 0.2s ease;
}

.check-trans-btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* تحسين مظهر الكلمات المتاحة */
.word-chip {
    transition: all 0.2s ease;
}

.word-chip:not([style*="display: none"]):hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* --- 19.4 تحسين التمرير والانتقالات --- */

/* تمرير سلس لجميع العناصر */
html {
    scroll-behavior: smooth;
}

/* تحسين مظهر البطاقة النشطة في الترجمة */
.translation-card-active {
    scroll-margin-top: 70px;
}

/* تأثير انتقالي للبطاقات عند التمرير */
.question-card {
    scroll-margin-top: 70px;
}

/* --- 19.5 إصلاحات إضافية للوضع الليلي في الترجمة --- */

/* خلفية منطقة النتيجة في الوضع الليلي */
.dark .result-area .bg-gray-50\/50 {
    background-color: rgba(17, 24, 39, 0.5) !important;
}

/* لون نص النتيجة في الوضع الليلي */
.dark .result-area .text-gray-700 {
    color: #e5e7eb !important;
}

/* لون نص التغذية الراجعة في الوضع الليلي */
.dark .result-area .text-gray-400 {
    color: #9ca3af !important;
}

/* --- 19.6 تحسينات للطباعة --- */
@media print {
    #fixedTopBar {
        position: static !important;
    }
    
    body.translation-active #questionsList {
        padding-top: 0;
    }
    
    textarea[id^="trans-answer-"] {
        border: 1px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }
}