/* ================================================
   COMPLETE FIX - إصلاح شامل ونهائي
   ================================================ */

/* تأكد من ظهور الأيقونات */
i[class*="fa-"],
i[class*="bi-"],
.fas, .far, .fab, .bi {
    display: inline-block !important;
    font-style: normal !important;
}

/* إعادة تعيين */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* المتغيرات */
:root {
    --primary: #5b21b6;
    --primary-light: #7c3aed;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --dark: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
}

/* الجسم */
html, body {
    height: 100%;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    direction: rtl;
    text-align: right;
}

/* ================================================
   التخطيط الأساسي
   ================================================ */
#app,
.app-wrapper {
    min-height: 100vh;
    display: flex;
}

/* ================================================
   السايد بار - مهم جداً
   ================================================ */
#sidebar,
.sidebar {
    width: 250px !important;
    height: 100vh;
    background: linear-gradient(180deg, #5b21b6 0%, #7c3aed 100%) !important;
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    z-index: 1000 !important;
    display: block !important;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease-in-out;
}

/* محتوى السايد بار مع سكرول */
.sidebar-content {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

/* تصميم السكرول بار */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* محتوى السايد بار */
.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

/* الشعار في السايد بار */
.sidebar-logo {
    max-width: 150px;
    height: auto;
    display: block;
    margin: 0 auto;
    background: white;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* زر إغلاق السايد بار للموبايل */
.sidebar-close-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.sidebar-close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar-brand {
    color: white !important;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
}

/* قائمة السايد بار */
.sidebar ul,
.sidebar-menu {
    list-style: none !important;
    padding: 20px 0 !important;
    margin: 0 !important;
}

.sidebar li,
.sidebar-menu-item {
    margin: 0 !important;
}

.sidebar a,
.sidebar-menu-link,
.nav-link {
    display: block !important;
    padding: 12px 20px !important;
    color: rgba(255,255,255,0.9) !important;
    text-decoration: none !important;
    transition: all 0.3s;
}

.sidebar a:hover,
.sidebar-menu-link:hover {
    background: rgba(255,255,255,0.1) !important;
    color: white !important;
    padding-right: 25px !important;
}

.sidebar a.active,
.sidebar-menu-link.active,
.nav-link.active {
    background: rgba(255,255,255,0.2) !important;
    border-right: 4px solid white !important;
    color: white !important;
}

.sidebar i,
.sidebar-menu-icon {
    margin-left: 10px;
    width: 20px;
    display: inline-block;
}

/* تأكد من ظهور كل نصوص السايد بار بالأبيض */
.sidebar * {
    color: white !important;
}

/* ================================================
   زر القائمة للموبايل
   ================================================ */
.mobile-menu-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    background: var(--primary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 1100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s;
}

.mobile-menu-toggle:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

/* الخلفية المظللة للسايد بار في الموبايل */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ================================================
   ريسبونسيف - الموبايل والتابلت
   ================================================ */
@media (max-width: 991px) {
    /* إخفاء السايد بار افتراضياً في الموبايل */
    .sidebar {
        transform: translateX(100%);
    }
    
    /* إظهار السايد بار عند التفعيل */
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* إظهار زر القائمة */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* إظهار زر الإغلاق داخل السايد بار */
    .sidebar-close-btn {
        display: flex !important;
    }
    
    /* تعديل المحتوى الرئيسي */
    .main-wrapper,
    .main-content,
    main {
        margin-right: 0 !important;
        width: 100% !important;
        padding-top: 70px;
    }
    
    /* إظهار الخلفية المظللة عند فتح القائمة */
    .sidebar.active ~ .sidebar-overlay,
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

@media (max-width: 576px) {
    /* السايد بار بعرض كامل في الموبايل الصغير */
    .sidebar {
        width: 85% !important;
    }
    
    .sidebar-logo {
        max-width: 120px;
    }
    
    .content-wrapper,
    .content {
        padding: 15px;
    }
}

/* ================================================
   المحتوى الرئيسي
   ================================================ */
.main-wrapper,
.main-content,
main {
    flex: 1;
    margin-right: 250px !important;
    background: #f1f5f9;
    min-height: 100vh;
    width: calc(100% - 250px);
}

.content-wrapper,
.content {
    padding: 20px;
}

/* ================================================
   الهيدر
   ================================================ */
.header,
.navbar {
    background: white !important;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    display: block !important;
}

/* إصلاح الناف بار الأساسي */
.navbar.bg-primary {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%) !important;
}

.navbar-dark .navbar-brand,
.navbar-dark .navbar-nav .nav-link {
    color: white !important;
}

.navbar-nav .dropdown-menu {
    background: white;
    border: 1px solid #e5e7eb;
}

.navbar-nav .dropdown-item {
    color: #1e293b !important;
}

.navbar-nav .dropdown-item:hover {
    background: #f3f4f6;
}

/* إصلاح شارة الإشعارات */
.notification-badge {
    background: #ef4444 !important;
    color: white !important;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    position: relative !important;
    display: inline-block;
    margin-left: 5px;
    min-width: 18px;
    text-align: center;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    color: white !important;
    font-size: 1.2rem;
}

/* Help Icon */
.help-icon-wrapper {
    position: relative;
}

.help-icon {
    color: white !important;
    font-size: 1.2rem;
}

/* Notification Dropdown */
.notification-dropdown {
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
}

.notification-header {
    background: #f8f9fa;
    font-weight: 600;
}

.notification-body {
    max-height: 300px;
    overflow-y: auto;
}

/* User Menu */
.navbar-nav .nav-link {
    color: white !important;
    padding: 0.5rem 1rem;
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-search {
    position: relative;
}

.header-search-input {
    padding: 8px 35px 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    width: 250px;
    background: #f8f9fa;
}

.header-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
}

.header-notifications {
    position: relative;
}

.header-notifications-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    position: relative;
}

.header-notifications-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.header-user:hover {
    background: #f8f9fa;
}

.header-user-avatar {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, #5b21b6, #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.header-user-info {
    text-align: right;
}

.header-user-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.header-user-role {
    font-size: 12px;
    color: #6b7280;
}

.page-header {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.page-title {
    font-size: 24px;
    font-weight: bold;
    color: #1e293b;
    margin-bottom: 5px;
}

.page-subtitle {
    color: #64748b;
    font-size: 14px;
}

/* ================================================
   البطاقات
   ================================================ */
.card {
    background: white !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    border: none !important;
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: #f8fafc !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    font-weight: 600;
    color: #1e293b !important;
}

.card-body {
    padding: 20px !important;
    background: white !important;
    color: #1e293b !important;
}

/* ================================================
   بطاقات الإحصائيات
   ================================================ */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

/* بطاقات ملونة */
.stat-card.bg-gradient-primary {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%) !important;
}

.stat-card.bg-gradient-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
}

.stat-card.bg-gradient-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.stat-card.bg-gradient-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

.stat-card.bg-gradient-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}

/* نصوص البطاقات الملونة */
.stat-card[class*="bg-gradient"] * {
    color: white !important;
}

.stat-card-icon {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 40px;
    opacity: 0.3;
}

.stat-card-title {
    font-size: 13px;
    text-transform: uppercase;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-card-value {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-card-change {
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* ================================================
   الجداول
   ================================================ */
.table {
    width: 100% !important;
    background: white !important;
}

.table thead {
    background: #5b21b6 !important;
}

.table thead th {
    color: white !important;
    padding: 12px 15px !important;
    font-weight: 600 !important;
    border: none !important;
}

.recent-discount-requests-table {
    table-layout: auto;
}

.recent-discount-requests-table thead th {
    white-space: normal !important;
    word-break: break-word;
    line-height: 1.25;
    vertical-align: middle;
    padding: 10px 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.recent-discount-requests-table thead th + th {
    border-right: 1px solid rgba(255, 255, 255, 0.35) !important;
}

.table tbody td {
    padding: 12px 15px !important;
    color: #1e293b !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.table tbody tr:hover {
    background: #f8fafc !important;
}

/* ================================================
   النماذج
   ================================================ */
input,
select,
textarea,
.form-control,
.form-select {
    width: 100%;
    padding: 8px 12px !important;
    background: white !important;
    border: 1px solid #cbd5db !important;
    border-radius: 6px !important;
    color: #1e293b !important;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
    outline: none !important;
    border-color: #7c3aed !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1) !important;
}

label,
.form-label {
    display: block;
    margin-bottom: 6px !important;
    color: #475569 !important;
    font-weight: 500 !important;
    font-size: 14px !important;
}

/* ================================================
   الأزرار
   ================================================ */
.btn {
    padding: 8px 16px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.3s !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.btn-primary {
    background: #5b21b6 !important;
    color: white !important;
}

.btn-primary:hover {
    background: #7c3aed !important;
    transform: translateY(-1px);
}

.btn-success {
    background: #10b981 !important;
    color: white !important;
}

.btn-danger {
    background: #ef4444 !important;
    color: white !important;
}

.btn-warning {
    background: #f59e0b !important;
    color: white !important;
}

.btn-info {
    background: #3b82f6 !important;
    color: white !important;
}

.btn-secondary {
    background: #64748b !important;
    color: white !important;
}

.btn-light {
    background: #f1f5f9 !important;
    color: #1e293b !important;
}

/* ================================================
   الشارات والحالات
   ================================================ */
.badge {
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    display: inline-block;
}

.badge-primary,
.bg-primary {
    background: #5b21b6 !important;
    color: white !important;
}

.badge-success,
.bg-success {
    background: #10b981 !important;
    color: white !important;
}

.badge-danger,
.bg-danger {
    background: #ef4444 !important;
    color: white !important;
}

.badge-warning,
.bg-warning {
    background: #f59e0b !important;
    color: white !important;
}

.badge-info,
.bg-info {
    background: #3b82f6 !important;
    color: white !important;
}

/* ================================================
   أدوات مساعدة
   ================================================ */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 2rem !important; }

.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 2rem !important; }

.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 2rem !important; }

/* ================================================
   التوافق مع الموبايل
   ================================================ */
@media (max-width: 768px) {
    #sidebar,
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s;
    }
    
    #sidebar.active,
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-wrapper,
    .main-content,
    main {
        margin-right: 0 !important;
        width: 100% !important;
    }
}

/* زر toggle للموبايل */
.sidebar-toggle,
#sidebarToggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: #5b21b6;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar-toggle,
    #sidebarToggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* ================================================
   إصلاحات نهائية
   ================================================ */

/* تأكد من ظهور كل النصوص */
body * {
    visibility: visible !important;
}

/* تأكد من ألوان النصوص */
p, span, div, li, td, th {
    color: #1e293b;
}

/* استثناءات للعناصر البيضاء */
.btn-primary *,
.btn-success *,
.btn-danger *,
.btn-warning *,
.btn-info *,
.badge *,
.table thead *,
.sidebar *,
.stat-card[class*="bg-gradient"] * {
    color: white !important;
}

/* إصلاح أي مشاكل في العرض */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col,
[class*="col-"] {
    padding: 0 10px;
}

.col-12 { width: 100%; }
.col-6 { width: 50%; }
.col-4 { width: 33.333%; }
.col-3 { width: 25%; }

@media (max-width: 768px) {
    .col-md-12,
    .col-lg-12,
    [class*="col-"] {
        width: 100%;
    }
}

/* تأكد من عمل الموقع */
#app {
    width: 100%;
}

/* إزالة أي هوامش غير مرغوبة */
body {
    margin: 0 !important;
    padding: 0 !important;
}

/* تأكد من الخط */
* {
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* إصلاح مشكلة النص الأبيض على خلفية بيضاء في الجداول */
.table .table-light th,
.table thead.table-light th,
.table-light thead th {
    color: #333 !important;
    background-color: #f8f9fa !important;
}

.table .table-light td,
.table tbody.table-light td,
.table-light tbody td {
    color: #333 !important;
}

/* إصلاح الجداول المتداخلة في صفحة المستخدمين */
.table .table thead.table-light th {
    color: #212529 !important;
    background-color: #f8f9fa !important;
    font-weight: 600 !important;
}

.table .table tbody td {
    color: #212529 !important;
}
