﻿﻿/* ============================================================
   shared-header.css - نسخة محسنة ومستقلة
   جميع التنسيقات معزولة داخل .navbar لمنع التعارض
   ============================================================ */

/* ===== منع الوميض عند تحميل الصفحة ===== */
html {
    scroll-behavior: smooth;
}

/* ===== منع overflow الأفقي الشامل ===== */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* === إصلاح جذري لمنع الوميض ومنع ظهور هيدر الموبايل على الديسكتوب === */
body:not(.loaded) .navbar {
    opacity: 0 !important;
    visibility: hidden !important;
    transition: none !important;
}

body.loaded .navbar {
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 0.15s ease;
}

/* منع ظهور زر الموبايل على الديسكتوب نهائياً - قاعدة حرجة تمنع FOUC */
@media (min-width: 1025px) {
    #subtoolDrawerToggle.subtool-drawer-toggle,
    .subtool-drawer-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    .navbar .nav-categories {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    .navbar .nav-actions {
        display: flex !important;
        visibility: visible !important;
    }
}

/* ===== حجز مساحة مسبقة ===== */
#header-placeholder {
    display: block;
    height: 60px;
    min-height: 60px;
    visibility: visible;
    background: transparent;
    transition: opacity 0.15s ease;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

#header-placeholder.loading {
    opacity: 0;
}

#header-placeholder:not(.loading) {
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* ============================================================
   جميع تنسيقات الهيدر معزولة داخل .navbar
   ============================================================ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 60px;
    min-height: 60px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.03);
    will-change: transform;
    transform: translateZ(0);
    opacity: 0;
    transition: opacity 0.15s ease;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* ===== جميع عناصر الهيدر معزولة ===== */
.navbar *,
.navbar *::before,
.navbar *::after {
    box-sizing: border-box;
}

.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    gap: 12px;
    min-width: 0;
    overflow: visible;
}

/* ============================================================
   شعار Edufiresoft - مُصحح لمنع قلب النص
   ============================================================ */

/* ===== منع قلب اسم الموقع ===== */
.navbar .edu-logo-container {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 18px;
    font-weight: 700;
    display: inline-flex;
    align-items: flex-end;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
    user-select: none;
    -webkit-user-select: none;
    /* منع قلب النص - الإصلاح الرئيسي */
    direction: ltr !important;
    unicode-bidi: normal !important;
    white-space: nowrap;
    /* === تحسين محاذاة الشعار لإظهار حركة الدوائر كاملة === */
    transform: translateY(4px);
    overflow: visible;
    padding-top: 2px;
}

.navbar .edu-part {
    color: #f97316;
    display: inline-block;
    direction: ltr !important;
    unicode-bidi: normal !important;
}

.navbar .fire-soft-part {
    display: inline-flex;
    color: #1e3a8a;
    align-items: flex-end;
    direction: ltr !important;
    unicode-bidi: normal !important;
}

.navbar .fire-soft-part > span {
    display: inline-block;
    direction: ltr !important;
    unicode-bidi: normal !important;
}

.navbar .logo-char {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    direction: ltr !important;
    unicode-bidi: normal !important;
    overflow: visible;
}

/* ===== تثبيت عرض النص لجميع العناصر الفرعية ===== */
.navbar .edu-logo-container *,
.navbar .edu-logo-container *::before,
.navbar .edu-logo-container *::after {
    direction: ltr !important;
    unicode-bidi: normal !important;
}

/* ===== النقاط المتحركة ===== */
.navbar .edu-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    display: inline-block;
    margin-bottom: 2px;
    animation: eduDotBounce 3s ease-in-out infinite;
    direction: ltr !important;
}

.navbar .edu-dot-1 { background-color: #4f46e5; animation-delay: 0s; }
.navbar .edu-dot-2 { background-color: #2563eb; animation-delay: 0.2s; }
.navbar .edu-dot-3 { background-color: #0ea5e9; animation-delay: 0.4s; }
.navbar .edu-dot-4 { background-color: #8b5cf6; animation-delay: 0.6s; }

@keyframes eduDotBounce {
    0%, 60%, 100% { transform: translateY(0) scale(1); }
    20% { transform: translateY(-5px) scale(1.3); }
    40% { transform: translateY(0) scale(1); }
}

/* ===== قائمة التنقل ===== */
.navbar .nav-categories {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.navbar .nav-list {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.navbar .nav-category {
    position: relative;
    list-style: none;
}

/* ===== أزرار التصنيفات - حجم خط أكبر ===== */
.navbar .category-trigger {
    background: transparent;
    border: none;
    padding: 4px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    line-height: 1;
    font-family: inherit;
    white-space: nowrap;
}

.navbar .category-trigger:hover,
.navbar .category-trigger:focus-visible {
    background: rgba(37, 99, 235, 0.08);
    color: #2563EB;
}

.navbar .category-trigger .category-icon {
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.navbar .category-trigger .dropdown-arrow {
    font-size: 0.55rem;
    margin-right: 2px;
    transition: transform 0.2s;
}

.navbar .nav-category:hover .dropdown-arrow,
.navbar .nav-category:focus-within .dropdown-arrow {
    transform: rotate(180deg);
}

/* ===== القوائم المنسدلة ===== */
.navbar .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 190px;
    max-width: calc(100vw - 20px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    padding: 4px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.15s ease;
    transform-origin: top right;
    z-index: 1001;
    pointer-events: none;
    margin-top: 0;
    list-style: none;
    overflow-x: hidden;
}

.navbar .nav-category:hover .dropdown-menu,
.navbar .nav-category:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.navbar .nav-category .dropdown-menu {
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.25s ease;
    transition-delay: 0s;
}

.navbar .nav-category:hover .dropdown-menu {
    transition-delay: 0s;
}

.navbar .nav-category:not(:hover) .dropdown-menu {
    transition-delay: 0.2s;
}

/* ===== عناصر القوائم المنسدلة - حجم خط أكبر ===== */
.navbar .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1e293b;
    text-decoration: none;
    transition: all 0.15s;
    border-radius: 6px;
    margin: 2px 4px;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.navbar .dropdown-item:hover {
    background: #f1f5f9;
    color: #2563EB;
}

.navbar .dropdown-item .nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.navbar .dropdown-item:hover .nav-icon {
    color: #2563EB;
}

.navbar .dropdown-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 10px;
}

/* ============================================================
   أيقونات SVG موحدة - مثبتة الحجم
   ============================================================ */
.navbar .header-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.navbar .header-icon-sm {
    width: 14px;
    height: 14px;
}

.navbar .header-icon-md {
    width: 20px;
    height: 20px;
}

.navbar .header-icon-lg {
    width: 24px;
    height: 24px;
}

/* ===== أزرار الإجراءات ===== */
.navbar .nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== زر اللغة ===== */
.navbar .lang-toggle-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-weight: 700;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    height: 32px;
    min-width: 34px;
    justify-content: center;
    color: #1e293b;
    font-family: inherit;
}

.navbar .lang-toggle-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* ===== زر السمة (Dark Mode) ===== */
.navbar .dark-toggle {
    background: #f1f5f9;
    border-radius: 9999px;
    border: 1px solid #E5E7EB;
    padding: 4px 10px;
    cursor: pointer;
    transition: 0.2s;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.navbar .dark-toggle:hover {
    background: #E5E7EB;
}

.navbar .dark-toggle .header-icon {
    width: 16px;
    height: 16px;
}

/* ===== زر تسجيل الدخول ===== */
.navbar .google-login-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-weight: 700;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    transition: all 0.2s;
    height: 32px;
    flex-shrink: 0;
    color: #1e293b;
    font-family: inherit;
}

.navbar .google-login-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.navbar .google-login-btn.hidden {
    display: none !important;
}

.navbar .google-login-btn .google-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ===== منطقة المستخدم ===== */
.navbar .user-area {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.navbar .user-area.hidden {
    display: none !important;
}

.navbar .user-avatar-wrapper {
    position: relative;
    display: inline-block;
}

.navbar .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    object-fit: cover;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
}

/* ===== Skeleton Loading ===== */
.navbar .avatar-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    display: none;
}

.navbar .avatar-skeleton.active {
    display: block;
}

.navbar .user-name-skeleton {
    width: 80px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    display: none;
}

.navbar .user-name-skeleton.active {
    display: block;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.navbar .user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 60px;
}

.navbar .user-info #userName {
    font-weight: 700;
    font-size: 0.75rem;
    color: #1e293b;
    transition: opacity 0.2s ease;
}

.navbar .user-info #welcomeMessage {
    font-size: 0.55rem;
    color: #64748b;
    transition: opacity 0.2s ease;
}

/* ============================================================
   DARK MODE - معزول داخل .navbar
   ============================================================ */
body.dark-mode .navbar {
    background: rgba(15, 23, 42, 0.92);
    border-bottom-color: #1e293b;
}

body.dark-mode .navbar .edu-part {
    color: #f97316;
}

body.dark-mode .navbar .fire-soft-part {
    color: #60a5fa;
}

body.dark-mode .navbar .dropdown-menu {
    background: rgba(30, 41, 59, 0.96);
    border-color: #334155;
}

body.dark-mode .navbar .dropdown-item {
    color: #e2e8f0;
}

body.dark-mode .navbar .dropdown-item:hover {
    background: #334155;
    color: #60a5fa;
}

body.dark-mode .navbar .dropdown-item .nav-icon {
    color: #94a3b8;
}

body.dark-mode .navbar .dropdown-item:hover .nav-icon {
    color: #60a5fa;
}

body.dark-mode .navbar .dropdown-divider {
    background: #334155;
}

body.dark-mode .navbar .category-trigger {
    color: #e2e8f0;
}

body.dark-mode .navbar .category-trigger:hover,
body.dark-mode .navbar .category-trigger:focus-visible {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
}

body.dark-mode .navbar .lang-toggle-btn {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e6;
}

body.dark-mode .navbar .google-login-btn {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e6;
}

body.dark-mode .navbar .google-login-btn:hover {
    background: #334155;
}

body.dark-mode .navbar .user-info #userName {
    color: #e2e8f0;
}

body.dark-mode .navbar .user-info #welcomeMessage {
    color: #94a3b8;
}

body.dark-mode .navbar .dark-toggle {
    background: #1e293b;
    border-color: #475569;
}

body.dark-mode .navbar .dark-toggle:hover {
    background: #334155;
}

body.dark-mode .navbar .dark-toggle .header-icon {
    stroke: #e2e8f0;
}

/* ===== Skeleton في الوضع الليلي ===== */
body.dark-mode .navbar .avatar-skeleton {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
}

body.dark-mode .navbar .user-name-skeleton {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .navbar {
        height: auto;
        min-height: auto;
        padding: 6px 12px;
        max-width: 100%;
    }

    .navbar-inner {
        flex-wrap: wrap;
        gap: 6px;
        max-width: 100%;
    }

    .navbar .edu-logo-container {
        font-size: 15px;
    }

    .navbar .nav-categories {
        order: 3;
        flex: 1 1 100%;
        justify-content: center;
        padding: 4px 0;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    .navbar .nav-list {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    body.dark-mode .navbar .nav-categories {
        border-top-color: #1e293b;
    }

    .navbar .category-trigger {
        font-size: 0.75rem;
        padding: 2px 10px;
        height: 28px;
    }

    .navbar .dropdown-menu {
        min-width: 160px;
        max-width: calc(100vw - 24px);
        right: auto;
        left: 0;
    }

    /* RTL fix for mobile dropdowns */
    [dir="rtl"] .navbar .dropdown-menu,
    html[dir="rtl"] .navbar .dropdown-menu {
        right: 0;
        left: auto;
    }

    .navbar .dropdown-item {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    #header-placeholder {
        height: auto;
        min-height: auto;
    }
}

@media (max-width: 480px) {
    .navbar .category-trigger {
        font-size: 0.65rem;
        padding: 2px 8px;
        height: 24px;
    }

    .navbar .dropdown-menu {
        min-width: 150px;
        max-width: calc(100vw - 16px);
        right: auto;
        left: 0;
    }

    [dir="rtl"] .navbar .dropdown-menu,
    html[dir="rtl"] .navbar .dropdown-menu {
        right: 0;
        left: auto;
    }

    .navbar .dropdown-item {
        font-size: 0.7rem;
        padding: 4px 8px;
        gap: 4px;
    }

    .navbar .dropdown-item .nav-icon {
        width: 14px;
        height: 14px;
    }

    .navbar .user-info #userName {
        font-size: 0.65rem;
    }

    .navbar .user-info #welcomeMessage {
        font-size: 0.5rem;
    }

    .navbar .dark-toggle {
        padding: 4px 8px;
    }

    .navbar .dark-toggle .header-icon {
        width: 14px;
        height: 14px;
    }
}

/* ===== تحسينات إضافية ===== */
.navbar {
    transition: opacity 0.15s ease !important;
}

.navbar * {
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.15s ease;
}

/* ============================================================
   مودال الملف الشخصي - مُحسّن لجميع المتصفحات
   ============================================================ */

/* ===== المودال ===== */
#profileModal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

#profileModal.active {
    display: flex !important;
    opacity: 1;
}

/* ===== محتوى المودال - حجم ثابت لجميع المتصفحات ===== */
#profileModal .modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 1.5rem;
    padding: 2rem 1.5rem 1.5rem;
    max-width: 340px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    margin: 0 auto;
    transform: scale(1);
    transform-origin: center center;
}

/* ===== منع التضخم في Edge ===== */
#profileModal .modal-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* ===== عنوان المودال ===== */
#profileModal .modal-content h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0 0 0.8rem 0;
    color: #0f172a;
    text-align: center;
}

/* ===== زر الإغلاق ===== */
#profileModal .modal-close {
    position: absolute;
    top: 0.6rem;
    inset-inline-end: 0.8rem;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 50%;
    line-height: 1;
    transition: all 0.2s;
}

#profileModal .modal-close:hover {
    color: #1e293b;
    background: rgba(0, 0, 0, 0.05);
}

/* ===== صورة المستخدم ===== */
#profileModal .profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e2e8f0;
    margin: 0 auto 0.5rem;
    display: block;
}

/* ===== اسم المستخدم ===== */
#profileModal .profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    margin-bottom: 0.1rem;
    word-break: break-word;
}

/* ===== البريد الإلكتروني ===== */
#profileModal .profile-email {
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
    margin-bottom: 0.8rem;
    word-break: break-all;
}

/* ===== أزرار الإجراءات ===== */
#profileModal .profile-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

#profileModal .profile-actions button {
    flex: 1;
    min-width: 60px;
    background: #f1f5f9;
    border: none;
    padding: 0.5rem 0.6rem;
    border-radius: 40px;
    font-weight: 700;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #1e293b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

#profileModal .profile-actions button:hover {
    background: #e2e8f0;
}

/* ===== زر تعديل الاسم ===== */
#profileModal .profile-actions .btn-edit-name {
    background: #2563eb;
    color: white;
    flex: 1.5;
    min-width: 80px;
}

#profileModal .profile-actions .btn-edit-name:hover {
    background: #1d4ed8;
}

#profileModal .profile-actions .btn-edit-name .header-icon {
    stroke: white;
}

/* ===== زر التحديث ===== */
#profileModal .profile-actions .btn-refresh {
    background: #f59e0b;
    color: white;
    flex: 1;
}

#profileModal .profile-actions .btn-refresh:hover {
    background: #d97706;
}

#profileModal .profile-actions .btn-refresh .header-icon {
    stroke: white;
}

/* ===== زر الخروج ===== */
#profileModal .profile-actions .btn-logout {
    background: #dc2626;
    color: white;
    flex: 1;
}

#profileModal .profile-actions .btn-logout:hover {
    background: #b91c1c;
}

#profileModal .profile-actions .btn-logout .header-icon {
    stroke: white;
}

/* ============================================================
   الوضع الليلي للمودال
   ============================================================ */
body.dark-mode #profileModal .modal-content {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode #profileModal .modal-content h2 {
    color: #e2e8f0;
}

body.dark-mode #profileModal .profile-name {
    color: #e2e8f0;
}

body.dark-mode #profileModal .profile-email {
    color: #94a3b8;
}

body.dark-mode #profileModal .profile-actions button {
    background: #334155;
    color: #e2e8f0;
}

body.dark-mode #profileModal .profile-actions button:hover {
    background: #475569;
}

body.dark-mode #profileModal .profile-actions .btn-edit-name {
    background: #3b82f6;
}

body.dark-mode #profileModal .profile-actions .btn-edit-name:hover {
    background: #2563eb;
}

body.dark-mode #profileModal .profile-actions .btn-refresh {
    background: #f59e0b;
}

body.dark-mode #profileModal .profile-actions .btn-refresh:hover {
    background: #d97706;
}

body.dark-mode #profileModal .profile-actions .btn-logout {
    background: #dc2626;
}

body.dark-mode #profileModal .profile-actions .btn-logout:hover {
    background: #b91c1c;
}

body.dark-mode #profileModal .modal-close {
    color: #94a3b8;
}

body.dark-mode #profileModal .modal-close:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================
   تحسينات إضافية لمتصفح Edge
   ============================================================ */
@supports (-ms-ime-align: auto) {
    #profileModal .modal-content {
        max-width: 320px;
    }
}

/* ===== منع التكبير/التصغير في Edge ===== */
#profileModal .modal-content {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ===== تثبيت حجم الخطوط ===== */
#profileModal .modal-content,
#profileModal .modal-content * {
    font-size: inherit;
}

/* ============================================================
   إصلاحات RTL والجوال الإضافية
   ============================================================ */

/* إصلاح خاص لمتصفح Safari على iOS */
@supports (-webkit-touch-callout: none) {
    .navbar {
        position: -webkit-sticky;
    }
}

/* منع bounce effect في Safari */
@supports (-webkit-touch-callout: none) {
    body {
        overscroll-behavior-x: none;
    }
}

/* إصلاح للشاشات الصغيرة جداً */
@media (max-width: 360px) {
    .navbar {
        padding: 4px 8px;
    }

    .navbar-inner {
        gap: 4px;
    }

    .navbar .edu-logo-container {
        font-size: 13px;
    }

    .navbar .category-trigger {
        font-size: 0.6rem;
        padding: 2px 6px;
        height: 22px;
    }

    .navbar .nav-actions {
        gap: 4px;
    }

    .navbar .lang-toggle-btn {
        padding: 0.15rem 0.4rem;
        font-size: 0.6rem;
        height: 28px;
    }

    .navbar .google-login-btn {
        padding: 0.15rem 0.5rem;
        font-size: 0.6rem;
        height: 28px;
    }

    .navbar .dark-toggle {
        padding: 3px 6px;
        height: 28px;
    }
}

/* ============================================================
   القائمة الجانبية للأدوات الفرعية - نسخة نهائية كاملة
   ============================================================ */
.subtool-drawer-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.08);
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.subtool-drawer-toggle:hover { background: rgba(37,99,235,0.14); color:#2563eb; }
.subtool-drawer-backdrop {
    position: fixed; inset:0; background: rgba(15,23,42,0.55); backdrop-filter: blur(4px);
    z-index:1999; opacity:0; pointer-events:none; transition: opacity 0.32s;
}
.subtool-drawer-backdrop.open { opacity:1; pointer-events:auto; }
.subtool-drawer {
    position: fixed; top:0; inset-inline-end:0; width:340px; max-width:88vw; height:100vh; height:100dvh;
    background: rgba(255,255,255,0.98); backdrop-filter: blur(18px); border-inline-start:1px solid #E5E7EB;
    box-shadow: -8px 0 32px rgba(0,0,0,0.12); z-index:2000; display:flex; flex-direction:column;
    transform: translateX(100%); transition: transform 0.38s cubic-bezier(0.34,1.2,0.64,1); overflow:hidden;
}
html[dir="ltr"] .subtool-drawer { right:0; transform: translateX(100%); }
.subtool-drawer.open { transform: translateX(0) !important; }
.subtool-drawer .drawer-header { display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid #E5E7EB; background: rgba(255,255,255,0.9); flex-shrink:0; }
.subtool-drawer .drawer-logo { font-family:'Poppins',sans-serif; font-weight:800; font-size:18px; text-decoration:none; display:inline-flex; direction:ltr !important; }
.subtool-drawer .drawer-logo .edu-part { color:#f97316; } .subtool-drawer .drawer-logo .fire-soft-part { color:#1e3a8a; }
.subtool-drawer .drawer-close-btn { width:40px; height:40px; border:none; border-radius:10px; background:#f1f5f9; color:#475569; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
.subtool-drawer .drawer-content { flex:1; overflow-y:auto; padding:14px 12px 24px; display:flex; flex-direction:column; gap:18px; }
.subtool-drawer .drawer-section { background:#fff; border:1px solid #F1F5F9; border-radius:16px; padding:12px; }
.subtool-drawer .drawer-section-title { font-size:0.75rem; font-weight:800; color:#94a3b8; margin-bottom:10px; text-transform:uppercase; }
.drawer-user-area { display:flex; align-items:center; gap:12px; padding:10px 12px; background:#f8fafc; border-radius:12px; border:1px solid #f1f5f9; cursor:pointer; }
.drawer-user-area.hidden { display:none !important; }
.drawer-user-avatar { width:42px; height:42px; border-radius:50%; object-fit:cover; border:2px solid #e2e8f0; }
.drawer-user-name { font-weight:700; font-size:0.92rem; color:#0f172a; }
.drawer-welcome { font-size:0.72rem; color:#64748b; display:block; margin-top:2px; }
.drawer-login-btn { width:100%; display:inline-flex; align-items:center; justify-content:center; gap:10px; padding:12px 16px; border-radius:12px; border:1px solid #E5E7EB; background:#0f172a; color:#fff; font-weight:700; font-size:0.88rem; cursor:pointer; }
.drawer-login-btn:hover { background:#1e293b; }
.drawer-actions-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.drawer-action-btn { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:14px 10px; border-radius:14px; border:1px solid #e2e8f0; background:#f8fafc; cursor:pointer; font-weight:600; color:#334155; }
.drawer-action-btn:hover { background:#eff6ff; border-color:#bfdbfe; color:#2563eb; }
.drawer-action-label { font-size:0.75rem; font-weight:700; }
.drawer-action-value { font-size:0.78rem; font-weight:800; background:#2563eb; color:#fff; padding:2px 10px; border-radius:999px; }
.drawer-nav { display:flex; flex-direction:column; gap:8px; }
.drawer-category { border:1px solid #f1f5f9; border-radius:12px; background:#f8fafc; overflow:hidden; }
.drawer-category.open { background:#fff; border-color:#dbeafe; box-shadow:0 2px 12px rgba(37,99,235,0.06); }
.drawer-category-trigger { width:100%; display:flex; align-items:center; justify-content:space-between; padding:12px 14px; background:transparent; border:none; font-weight:700; font-size:0.88rem; color:#1e293b; cursor:pointer; text-align:start; }
.drawer-category-arrow { font-size:0.65rem; color:#94a3b8; transition:transform 0.25s; }
.drawer-category.open .drawer-category-arrow { transform:rotate(180deg); color:#2563eb; }
.drawer-dropdown { list-style:none; margin:0; padding:0 8px 10px; display:none; flex-direction:column; gap:4px; }
.drawer-category.open .drawer-dropdown { display:flex; }
.drawer-dropdown-item { display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:10px; text-decoration:none; color:#334155; font-weight:600; font-size:0.84rem; background:#fff; border:1px solid transparent; }
.drawer-dropdown-item:hover { background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.drawer-dropdown-item .nav-icon, .drawer-dropdown-item .header-icon { width:18px; height:18px; flex-shrink:0; }
.drawer-blog-link { display:flex; align-items:center; gap:10px; padding:14px 16px; border-radius:12px; background:linear-gradient(135deg,#2563eb 0%,#1e40af 100%); color:#fff; text-decoration:none; font-weight:800; font-size:0.9rem; box-shadow:0 4px 14px rgba(37,99,235,0.22); }
.drawer-blog-icon { width:36px; height:36px; border-radius:10px; background:rgba(255,255,255,0.18); display:inline-flex; align-items:center; justify-content:center; }
.drawer-external-icon { margin-inline-start:auto; opacity:0.85; }
/* ===== توحيد الهيدر - الديسكتوب: إخفاء القائمة الجانبية ===== */
@media (min-width:1025px){
  body.subtool-header-mode .subtool-drawer-toggle,
  body.subtool-header-mode .subtool-drawer,
  body.subtool-header-mode .subtool-drawer-backdrop,
  body.main-header-mode .subtool-drawer-toggle,
  body.main-header-mode .subtool-drawer,
  body.main-header-mode .subtool-drawer-backdrop { display:none !important; }
}
@media (max-width:1024px){
  body.subtool-header-mode .navbar .nav-categories,
  body.subtool-header-mode .navbar .nav-actions { display:none !important; }
  body.subtool-header-mode .subtool-drawer-toggle { display:inline-flex !important; }
  body.subtool-header-mode .navbar-inner { justify-content:space-between; gap:12px; }
  body.subtool-header-mode .navbar { padding:0 14px; }
  /* الصفحة الرئيسية - نفس سلوك الصفحات الفرعية على الموبايل/تابلت: زرين فقط */
  body.main-header-mode .navbar .nav-links,
  body.main-header-mode .navbar .nav-actions,
  body.main-header-mode .navbar .nav-categories { display:none !important; }
  body.main-header-mode .subtool-drawer-toggle { display:inline-flex !important; visibility:visible !important; opacity:1 !important; pointer-events:auto !important; }
  body.main-header-mode .navbar-inner { justify-content:space-between !important; gap:12px; }
  body.main-header-mode .navbar { padding:0 14px !important; }
}
@media (max-width:380px){ .subtool-drawer { width:100vw; max-width:100vw; } }
body.dark-mode .subtool-drawer-toggle { background:rgba(255,255,255,0.08); color:#e2e8f0; }
body.dark-mode .subtool-drawer { background:rgba(15,23,42,0.98); border-color:rgba(255,255,255,0.08); }
body.dark-mode .subtool-drawer .drawer-header { background:rgba(15,23,42,0.95); border-color:rgba(255,255,255,0.08); }
body.dark-mode .subtool-drawer .drawer-logo .fire-soft-part { color:#60a5fa; }
body.dark-mode .subtool-drawer .drawer-close-btn { background:#1e293b; color:#94a3b8; }
body.dark-mode .subtool-drawer .drawer-section { background:#1e293b; border-color:rgba(255,255,255,0.06); }
body.dark-mode .drawer-user-area { background:#0f172a; border-color:rgba(255,255,255,0.06); }
body.dark-mode .drawer-user-name { color:#e2e8f0; } body.dark-mode .drawer-welcome { color:#94a3b8; }
body.dark-mode .drawer-login-btn { background:#e2e8f0; color:#0f172a; }
body.dark-mode .drawer-action-btn { background:#0f172a; border-color:rgba(255,255,255,0.06); color:#cbd5e1; }
body.dark-mode .drawer-category { background:#0f172a; border-color:rgba(255,255,255,0.06); }
body.dark-mode .drawer-category.open { background:#1e293b; border-color:rgba(59,130,246,0.25); }
body.dark-mode .drawer-category-trigger { color:#e2e8f0; }
body.dark-mode .drawer-dropdown-item { background:#0f172a; color:#cbd5e1; }
body.drawer-open { overflow:hidden !important; touch-action:none; }

/* إصلاح قوي لظهور زر القائمة - موحد للرئيسية والفرعية */
#subtoolDrawerToggle.subtool-drawer-toggle { display:none; }
@media (max-width:1024px){
  body.subtool-header-mode #subtoolDrawerToggle.subtool-drawer-toggle,
  body.main-header-mode #subtoolDrawerToggle.subtool-drawer-toggle,
  body:not(.main-header-mode):not(.subtool-header-mode) #subtoolDrawerToggle.subtool-drawer-toggle { display:inline-flex !important; visibility:visible !important; opacity:1 !important; pointer-events:auto !important; }
}
.subtool-drawer, .subtool-drawer-backdrop { will-change:transform; }


/* === إصلاح: إظهار زر القائمة الجانبية في الصفحة الرئيسية على الموبايل/تابلت - إصلاح جذري === */
@media (max-width:1024px){
  /* إظهار الزر في جميع الحالات على الموبايل، حتى بدون كلاس وضع */
  #subtoolDrawerToggle,
  #subtoolDrawerToggle.subtool-drawer-toggle,
  .subtool-drawer-toggle {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  /* التأكد أن القائمة الجانبية نفسها قابلة للظهور على الموبايل */
  .subtool-drawer {
    display: flex !important;
    visibility: hidden;
    transform: translateX(100%) !important;
  }
  .subtool-drawer.open {
    visibility: visible !important;
    transform: translateX(0) !important;
  }
  .subtool-drawer-backdrop {
    display: block !important;
    visibility: hidden;
    opacity: 0 !important;
  }
  .subtool-drawer-backdrop.open {
    visibility: visible !important;
    opacity: 1 !important;
  }
}


/* إصلاح قسري لإظهار الهيدر - مع احترام حالة التحميل لمنع الوميض */
body.loaded .navbar,
body.loaded.subtool-header-mode .navbar,
body.loaded.main-header-mode .navbar { opacity:1 !important; visibility:visible !important; }
body.loaded #header-placeholder,
body.loaded.subtool-header-mode #header-placeholder,
#header-placeholder { display:block !important; visibility:visible !important; }
body.loaded #header-placeholder { opacity:1 !important; }
body.loaded .navbar { opacity:1 !important; }
body:not(.loaded) .navbar { opacity:0 !important; visibility:hidden !important; }

/* تكبير اللوجو للأدوات الفرعية والرئيسية موبايل/تابلت - موحد مثل AI XPLORIA */
@media (max-width:1024px){
  body.subtool-header-mode .navbar,
  body.main-header-mode .navbar { height:64px !important; min-height:64px !important; padding:0 14px !important; }
  body.subtool-header-mode #header-placeholder,
  body.main-header-mode #header-placeholder { height:64px !important; min-height:64px !important; }
  body.subtool-header-mode .navbar-inner,
  body.main-header-mode .navbar-inner { height:64px; }
  body.subtool-header-mode .edu-logo-container,
  body.main-header-mode .edu-logo-container { font-size:26px !important; font-weight:800 !important; letter-spacing:-0.02em; line-height:1; transform: translateY(4px) !important; overflow: visible !important; }
  body.subtool-header-mode .edu-logo-container .edu-part,
  body.main-header-mode .edu-logo-container .edu-part { font-size:26px !important; }
  body.subtool-header-mode .fire-soft-part,
  body.main-header-mode .fire-soft-part { font-size:26px !important; }
  body.subtool-header-mode .edu-dot,
  body.main-header-mode .edu-dot { width:5px !important; height:5px !important; margin-bottom:3px !important; }
  body.subtool-header-mode .subtool-drawer-toggle,
  body.main-header-mode .subtool-drawer-toggle { width:46px !important; height:46px !important; border-radius:12px !important; background:#f8fafc !important; border:1px solid #e2e8f0 !important; }
  body.subtool-header-mode .subtool-drawer-toggle svg,
  body.main-header-mode .subtool-drawer-toggle svg { width:24px !important; height:24px !important; }
  body.dark-mode.subtool-header-mode .subtool-drawer-toggle,
  body.dark-mode.main-header-mode .subtool-drawer-toggle { background:#1e293b !important; border-color:rgba(255,255,255,0.08) !important; }
}
@media (max-width:768px){
  body.subtool-header-mode .edu-logo-container,
  body.main-header-mode .edu-logo-container { font-size:24px !important; }
  body.subtool-header-mode .edu-logo-container .edu-part, body.subtool-header-mode .fire-soft-part,
  body.main-header-mode .edu-logo-container .edu-part, body.main-header-mode .fire-soft-part { font-size:24px !important; }
}
@media (max-width:480px){
  body.subtool-header-mode .edu-logo-container,
  body.main-header-mode .edu-logo-container { font-size:22px !important; }
  body.subtool-header-mode .edu-logo-container .edu-part, body.subtool-header-mode .fire-soft-part,
  body.main-header-mode .edu-logo-container .edu-part, body.main-header-mode .fire-soft-part { font-size:22px !important; }
  body.subtool-header-mode .navbar,
  body.main-header-mode .navbar { padding:0 12px !important; }
}
body.subtool-header-mode .navbar,
body.main-header-mode .navbar { overflow:visible; border-bottom:1px solid #E5E7EB; }
body.subtool-header-mode .edu-logo-container,
body.main-header-mode .edu-logo-container { max-width:70vw; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ===== تنسيقات إضافية لقائمة الرئيسية المبسطة ===== */
.drawer-about-link {
  display:flex; align-items:center; gap:10px; padding:14px 16px; border-radius:12px;
  background:#f8fafc; color:#1e293b; text-decoration:none; font-weight:700; font-size:0.9rem;
  border:1px solid #e2e8f0; margin-top:8px;
}
.drawer-about-link:hover { background:#eff6ff; color:#1d4ed8; border-color:#dbeafe; }
.drawer-about-icon { width:36px; height:36px; border-radius:10px; background:#e0f2fe; display:inline-flex; align-items:center; justify-content:center; }
body.dark-mode .drawer-about-link { background:#1e293b; color:#e2e8f0; border-color:rgba(255,255,255,0.06); }
body.dark-mode .drawer-about-link:hover { background:#0f172a; border-color:rgba(59,130,246,0.25); }