/**
 * نظام الألوان والأنماط الموحد - ورشة الهاشم
 * Unified Color System & Styles
 * 
 * مبني على dashboard.css الموجود مع تحسينات
 * إضافة Layout Structure للتكامل مع Header + Sidebar
 */

/* ========================
   استيراد الخطوط
======================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;800&display=swap');

/* ========================
   المتغيرات العامة (CSS Variables)
======================== */
:root {
    /* الألوان الأساسية */
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --secondary-color: #764ba2;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* ألوان الحالة */
    --success-color: #10b981;
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --info-color: #3b82f6;
    --info-gradient: linear-gradient(135deg, #3730a3 0%, #2563eb 100%);
    --warning-color: #f59e0b;
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --danger-color: #ef4444;
    --danger-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    
    /* ألوان النص */
    --text-primary: #2c3e50;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #cbd5e1;
    
    /* ألوان الخلفية */
    --bg-body: #f8f9fa;
    --bg-white: #ffffff;
    --bg-light: #f1f5f9;
    --bg-dark: #1e293b;
    
    /* Sidebar */
    --sidebar-width: 280px;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --sidebar-active: var(--primary-gradient);
    
    /* Header */
    --header-height: 70px;
    
    /* الظلال */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    
    /* الحدود */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-color: #e2e8f0;
    
    /* الانتقالات */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ========================
   الإعدادات الأساسية
======================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-body);
    direction: rtl;
    text-align: right;
    overflow-x: hidden;
}

/* ========================
   LAYOUT STRUCTURE
======================== */

/* Main Wrapper */
.wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem;
    background: var(--primary-gradient);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon svg {
    width: 32px;
    height: 32px;
}

.brand-text h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.75rem;
    opacity: 0.9;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 1rem 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-right: 3px solid transparent;
    position: relative;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: white;
    border-right-color: var(--primary-color);
    padding-right: 1.75rem;
}

.nav-link.active {
    background: var(--primary-gradient);
    color: white;
    border-right-color: white;
    font-weight: 600;
}

.nav-icon {
    width: 24px;
    margin-left: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-text {
    flex: 1;
}

.nav-arrow {
    width: 16px;
    margin-right: auto;
    transition: transform var(--transition-fast);
}

/* Submenu */
.has-submenu + .submenu {
    display: none;
}

.nav-item.active .submenu {
    display: block;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--bg-body);
    display: flex;
    flex-direction: column;
}

/* Top Header */
.top-header {
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 999;
    border-bottom: 1px solid var(--border-color);
    height: var(--header-height);
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Welcome Banner */
.welcome-banner {
    background: var(--primary-gradient);
    color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.welcome-banner h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.welcome-banner p {
    opacity: 0.9;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition-normal);
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: var(--primary-gradient);
    color: white;
}

.stat-success .stat-icon {
    background: var(--success-gradient);
    color: white;
}

.stat-warning .stat-icon {
    background: var(--warning-gradient);
    color: white;
}

.stat-danger .stat-icon {
    background: var(--danger-gradient);
    color: white;
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.table thead th {
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding: 1rem;
    text-align: right;
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background-color: var(--bg-light);
}

/* Buttons */
.btn {
    border-radius: var(--border-radius-sm);
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success-gradient);
    color: white;
}

.btn-info {
    background: var(--info-gradient);
    color: white;
}

.btn-warning {
    background: var(--warning-gradient);
    color: white;
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8125rem;
    font-weight: 600;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-info {
    background: var(--info-color);
    color: white;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-danger {
    background: var(--danger-color);
    color: white;
}

.badge-secondary {
    background: var(--text-muted);
    color: white;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-hover {
    transition: all var(--transition-normal);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* ========================
   Responsive Design
======================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .content-wrapper {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.active {
    display: block;
}

/* ========================
   RTL/LTR Support
======================== */
.ltr {
    direction: ltr;
    text-align: left;
}

.ltr .sidebar {
    right: auto;
    left: 0;
}

.ltr .main-content {
    margin-right: 0;
    margin-left: var(--sidebar-width);
}

.ltr .nav-link {
    border-right: none;
    border-left: 3px solid transparent;
}

.ltr .nav-link:hover {
    border-left-color: var(--primary-color);
    padding-left: 1.75rem;
    padding-right: 1.5rem;
}

.ltr .nav-link.active {
    border-left-color: white;
}

.ltr .nav-icon {
    margin-left: 0;
    margin-right: 0.75rem;
}

.ltr .table thead th,
.ltr .table tbody td {
    text-align: left;
}

@media (max-width: 768px) {
    .ltr .sidebar {
        transform: translateX(-100%);
    }
    
    .ltr .sidebar.show {
        transform: translateX(0);
    }
}

/* ========================
   HEADER STYLES
======================== */

/* Header Container */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 100%;
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Menu Toggle Button */
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-light);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    min-width: 300px;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-family: inherit;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
}

.dropdown-toggle:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    z-index: 1000;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9375rem;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background: var(--bg-light);
    color: var(--primary-color);
    padding-right: 1.25rem;
}

.dropdown-menu a.active {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
}

/* User Avatar in Header */
.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    margin: 1rem auto;
}

.user-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.125rem;
    margin: 1rem auto;
}

/* RTL Support for Header */
.rtl .dropdown-menu {
    right: auto;
    left: 0;
}

.rtl .dropdown-menu a:hover {
    padding-right: 1rem;
    padding-left: 1.25rem;
}

.ltr .dropdown-menu a:hover {
    padding-left: 1.25rem;
    padding-right: 1rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-box {
        min-width: 200px;
    }
    
    .header-container {
        padding: 0 1rem;
    }
    
    .dropdown-toggle span {
        display: none;
    }
}

@media (max-width: 480px) {
    .search-box {
        display: none;
    }
}
/* ========================
   FIX: Header RTL/LTR Position
======================== */

/* RTL: القوائم في اليسار */
body.rtl .header-container {
    flex-direction: row-reverse;
}

body.rtl .header-right {
    margin-left: 0;
    margin-right: auto;
}

body.rtl .dropdown-menu {
    right: auto;
    left: 0;
}

/* LTR: القوائم في اليمين */
body.ltr .header-container {
    flex-direction: row;
}

body.ltr .header-right {
    margin-left: auto;
    margin-right: 0;
}

body.ltr .dropdown-menu {
    left: auto;
    right: 0;
}

/* ===================================
   LANGUAGE SWITCHER - Enhanced
   =================================== */

/* جعل Language Switcher أوضح */
.dropdown.language-dropdown .dropdown-toggle {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    gap: 0.75rem;
}

.dropdown.language-dropdown .dropdown-toggle:hover {
    border-color: var(--primary-color);
    background: white;
}

.dropdown.language-dropdown .dropdown-toggle svg {
    color: var(--primary-color);
}

/* قائمة اللغات */
.dropdown.language-dropdown .dropdown-menu {
    min-width: 200px;
}

.dropdown.language-dropdown .dropdown-menu a {
    font-size: 0.9375rem;
    padding: 0.875rem 1rem;
}

.dropdown.language-dropdown .dropdown-menu a.active {
    background: var(--primary-gradient);
    color: white;
}

/* ===================================
   FIX: Header Position in RTL
   =================================== */

/* RTL: إبعاد header-right عن السايدبار */
html[dir="rtl"] .header-right,
body.rtl .header-right {
    margin-right: 20px; /* مسافة من حافة السايدبار */
}

/* LTR: طبيعي */
html[dir="ltr"] .header-right,
body.ltr .header-right {
    margin-left: 20px;
}

/* للموبايل: إزالة الـ margin */
@media (max-width: 768px) {
    html[dir="rtl"] .header-right,
    body.rtl .header-right,
    html[dir="ltr"] .header-right,
    body.ltr .header-right {
        margin-right: 0;
        margin-left: 0;
    }
}

/* ===================================
   FIX: Submenu Styles Enhancement
   =================================== */

/* القوائم الفرعية */
.submenu {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

.nav-item.active > .submenu {
    display: block;
}

.submenu li {
    margin: 0;
}

.submenu a {
    display: block;
    padding: 0.75rem 1rem 0.75rem 3.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    border-right: 3px solid transparent;
}

.submenu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding-right: 3.75rem;
    border-right-color: var(--primary-color);
}

.submenu a.active {
    background: rgba(102, 126, 234, 0.3);
    color: white;
    border-right-color: white;
}

/* RTL Support for Submenu */
html[dir="rtl"] .submenu a,
body.rtl .submenu a {
    padding: 0.75rem 3.5rem 0.75rem 1rem;
    border-right: 3px solid transparent;
    border-left: none;
}

html[dir="rtl"] .submenu a:hover,
body.rtl .submenu a:hover {
    padding-right: 3.75rem;
    padding-left: 1rem;
    border-right-color: var(--primary-color);
}

/* LTR Support for Submenu */
html[dir="ltr"] .submenu a,
body.ltr .submenu a {
    padding: 0.75rem 1rem 0.75rem 3.5rem;
    border-left: 3px solid transparent;
    border-right: none;
}

html[dir="ltr"] .submenu a:hover,
body.ltr .submenu a:hover {
    padding-left: 3.75rem;
    padding-right: 1rem;
    border-left-color: var(--primary-color);
}

/* ===================================
   ANIMATION: Slide Down
   =================================== */
@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        overflow: hidden;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* ===================================
   FIX: User Avatar in Sidebar
   =================================== */

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent 0%, var(--sidebar-bg) 30%);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===================================
   SCROLLBAR CUSTOM STYLES
   =================================== */

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content Scrollbar */
.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.main-content::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
/* ===================================
   FIX: Header Above Sidebar
   =================================== */

/* رفع z-index للهيدر ليكون فوق السايدبار */
.top-header {
    z-index: 1001 !important; /* أعلى من السايدبار */
}

/* RTL: الهيدر يبدأ بعد السايدبار */
html[dir="rtl"] .top-header,
body.rtl .top-header {
    padding-right: calc(var(--sidebar-width) + 1.5rem);
    padding-left: 1.5rem;
}

/* LTR: الهيدر يبدأ بعد السايدبار */
html[dir="ltr"] .top-header,
body.ltr .top-header {
    padding-left: calc(var(--sidebar-width) + 1.5rem);
    padding-right: 1.5rem;
}

/* Header Container Adjustment */
html[dir="rtl"] .header-container,
body.rtl .header-container {
    padding-right: 0;
}

html[dir="ltr"] .header-container,
body.ltr .header-container {
    padding-left: 0;
}

/* Mobile: إزالة الـ padding الزائد */
@media (max-width: 768px) {
    html[dir="rtl"] .top-header,
    body.rtl .top-header,
    html[dir="ltr"] .top-header,
    body.ltr .top-header {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    /* رفع z-index السايدبار في الموبايل */
    .sidebar {
        z-index: 2000 !important;
    }
    
    .top-header {
        z-index: 1500 !important;
    }
}

/* ===================================
   FIX: Language Switcher in Dashboard
   =================================== */

/* إخفاء Language Switcher في dashboard (استخدم الموجود في Header) */
.page-language-switcher {
    display: none !important;
}

/* إذا أردت إبقائه، اجعل z-index عالي جداً */
/*
.page-language-switcher {
    position: fixed;
    top: 20px;
    z-index: 10000 !important;
    background: white;
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

html[dir="rtl"] .page-language-switcher {
    left: 20px;
    right: auto;
}

html[dir="ltr"] .page-language-switcher {
    right: 20px;
    left: auto;
}
*/

/* ===================================
   FIX: Dropdown Menu Above Everything
   =================================== */

.dropdown-menu {
    z-index: 9999 !important; /* أعلى من كل شيء */
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ===================================
   FIX: User Dropdown in RTL
   =================================== */

/* RTL: القائمة تنزل من اليسار */
html[dir="rtl"] .dropdown-menu,
body.rtl .dropdown-menu {
    right: auto;
    left: 0;
}

/* LTR: القائمة تنزل من اليمين */
html[dir="ltr"] .dropdown-menu,
body.ltr .dropdown-menu {
    left: auto;
    right: 0;
}

/* ===================================
   ENSURE CLICKABLE ELEMENTS
   =================================== */

/* التأكد من أن العناصر قابلة للنقر */
.dropdown-toggle,
.dropdown-menu a {
    position: relative;
    z-index: inherit;
}

.dropdown {
    position: relative;
    z-index: 1002; /* أعلى من الهيدر */
}

.dropdown.active,
.dropdown:hover {
    z-index: 10000; /* عند الفتح يرتفع للأعلى */
}

/* ===================================
   🔧 CRITICAL FIXES - Added [DATE]
   =================================== */

/* ===================================
   1. HEADER: Full Width Fixed
   =================================== */

.top-header {
    position: fixed !important;
    top: 0;
    height: var(--header-height);
    background: white;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-color);
    z-index: 1001 !important;
}

/* RTL: Header width after sidebar */
html[dir="rtl"] .top-header,
body.rtl .top-header {
    left: 0 !important;
    right: var(--sidebar-width) !important;
    width: calc(100% - var(--sidebar-width)) !important;
}

/* LTR: Header width after sidebar */
html[dir="ltr"] .top-header,
body.ltr .top-header {
    left: var(--sidebar-width) !important;
    right: 0 !important;
    width: calc(100% - var(--sidebar-width)) !important;
}

/* ===================================
   2. HEADER CONTAINER: Full Width
   =================================== */

.header-container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 2rem !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* ===================================
   3 & 4. HEADER LAYOUT - SIMPLIFIED FIX
   =================================== */

.header-container {
    display: flex !important;
    align-items: center !important;
    padding: 0 2rem !important;
    height: 100% !important;
    width: 100% !important;
}

.header-left {
    display: flex !important;
    align-items: center !important;
    gap: 1rem !important;
}

.header-right {
    display: flex !important;
    align-items: center !important;
    gap: 1rem !important;
}

/* RTL (العربية): 
   [Search + Menu]................[User + Language] */
html[dir="rtl"] .header-container,
body.rtl .header-container {
    justify-content: space-between !important;
}

html[dir="rtl"] .header-left,
body.rtl .header-left {
    /* Menu + Search في اليسار */
    order: 2 !important;
}

html[dir="rtl"] .header-right,
body.rtl .header-right {
    /* User + Language في اليمين */
    order: 1 !important;
    flex-direction: row-reverse !important;
}

/* LTR (الإنجليزية): 
   [Menu + Search]................[Language + User] */
html[dir="ltr"] .header-container,
body.ltr .header-container {
    justify-content: space-between !important;
}

html[dir="ltr"] .header-left,
body.ltr .header-left {
    /* Menu + Search في اليسار */
    order: 1 !important;
}

html[dir="ltr"] .header-right,
body.ltr .header-right {
    /* Language + User في اليمين */
    order: 2 !important;
    flex-direction: row !important;
}
/* ===================================
   6. SIDEBAR: Ensure Fixed Position
   =================================== */

.sidebar {
    position: fixed !important;
    top: 0 !important;
    width: var(--sidebar-width) !important;
    height: 100vh !important;
    z-index: 1000 !important;
}

html[dir="rtl"] .sidebar,
body.rtl .sidebar {
    right: 0 !important;
    left: auto !important;
}

html[dir="ltr"] .sidebar,
body.ltr .sidebar {
    left: 0 !important;
    right: auto !important;
}

/* ===================================
   7. FOOTER: Proper Styling
   =================================== */

.main-footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    margin-top: auto;
    width: 100%;
    text-align: center;
}

.footer-content {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-content p {
    margin: 0.25rem 0;
}

/* ===================================
   8. SCROLL TO TOP BUTTON
   =================================== */

.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    background: var(--primary-gradient);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: all var(--transition-normal);
}

.scroll-to-top.show {
    display: flex !important;
}

.scroll-to-top:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

html[dir="rtl"] .scroll-to-top,
body.rtl .scroll-to-top {
    left: 2rem;
    right: auto;
}

html[dir="ltr"] .scroll-to-top,
body.ltr .scroll-to-top {
    right: 2rem;
    left: auto;
}

/* ===================================
   9. MODAL STYLES
   =================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal[style*="display: block"],
.modal[style*="display:block"] {
    display: flex !important;
}

.modal-dialog {
    background: white;
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content {
    padding: 0;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.close-modal:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   10. MOBILE RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    html[dir="rtl"] .top-header,
    body.rtl .top-header,
    html[dir="ltr"] .top-header,
    body.ltr .top-header {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }
    
    html[dir="rtl"] .main-content,
    body.rtl .main-content,
    html[dir="ltr"] .main-content,
    body.ltr .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    html[dir="rtl"] .sidebar,
    body.rtl .sidebar {
        transform: translateX(100%);
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    .header-container {
        padding: 0 1rem !important;
    }
    
    .search-box {
        display: none !important;
    }
}
/* ===================================
   EMERGENCY FIX: Content Visibility
   =================================== */

/* التأكد من أن المحتوى لا يبدأ من تحت الـ Header */
body {
    padding-top: 0 !important;
}

.wrapper {
    padding-top: 0 !important;
}

.main-content {
    padding-top: 0 !important;
}

/* Content Wrapper هو الذي يحتاج padding */
.content-wrapper {
    padding-top: calc(var(--header-height) + 2rem) !important;
    padding-right: 2rem !important;
    padding-bottom: 2rem !important;
    padding-left: 2rem !important;
}

/* في RTL */
html[dir="rtl"] .content-wrapper,
body.rtl .content-wrapper {
    padding-right: 2rem !important;
    padding-left: 2rem !important;
}

/* في LTR */
html[dir="ltr"] .content-wrapper,
body.ltr .content-wrapper {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
}

/* للموبايل */
@media (max-width: 768px) {
    .content-wrapper {
        padding-top: calc(var(--header-height) + 1rem) !important;
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }
}
/* ===================================
   END OF FIXES
   =================================== */