@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

/* ================= 🎨 1. الهوية البصرية ( ERP Premium Branding) ================= */
:root {
    /* ألوان MIND الأساسية وتوجيهها لمكتبة البوتستراب */
    --bs-primary: #1E40AF;       /* أزرق ملكي رئيسي */
    --bs-primary-rgb: 30, 64, 175;
    --bs-success: #10B981;       /* أخضر للنجاح (Emerald) */
    --bs-success-rgb: 16, 185, 129;
    --bs-warning: #F59E0B;       /* برتقالي للنواقص (Amber) */
    --bs-warning-rgb: 245, 158, 11;
    --bs-danger: #EF4444;        /* أحمر داكن (Red) */
    --bs-danger-rgb: 239, 68, 68;
    --bs-info: #3B82F6;          /* أزرق فاتح (Blue) */
    --bs-dark: #0F172A;          /* أسود رمادي مريح (Slate) */

    /* 💎 ألوان الهوية المالية المخصصة (Clean Corporate) */
    --main-blue: #0078d7;        /* أزرق المحافظ الأساسي */
    --main-blue-hover: #005a9e;  
    --danger-red: #b02a37;       /* أحمر الإلغاء الأنيق */

    /* ألوان خلفيات ونصوص النظام */
    --bg-body: #F8FAFC;          /* رمادي فاتح جداً نقي */
    --bg-surface: #FFFFFF;       /* أبيض البطاقات */
    --text-dark: #0F172A;        /* نصوص أساسية */
    --text-muted: #64748B;       /* رمادي للنصوص الفرعية */
    --border-color: #E2E8F0;     /* حدود ناعمة */
    
    --sidebar-width: 260px;
}

body {
    font-family: 'Cairo', sans-serif !important;
    background-color: var(--bg-body);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* ================= 📐 2. الهيكل الأساسي (Layout) ================= */
/* شاشة تسجيل الدخول */
#login-screen {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-body);
}
.login-card {
    background: var(--bg-surface);
    padding: 3rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 400px;
}

/* القائمة الجانبية (MIND Sidebar Style) */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface) !important;
    border-left: 1px solid var(--border-color);
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    padding: 20px 12px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: -4px 0 15px rgba(0,0,0,0.02);
}
.sidebar h3, .sidebar .header-logo { 
    color: var(--bs-primary) !important; 
    font-weight: 800; 
}
.sidebar p#active-cashier-name { 
    color: var(--text-muted) !important; 
}
.sidebar a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-muted) !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}
.sidebar a i { 
    width: 24px; 
    font-size: 1.1rem; 
    margin-left: 12px; 
    transition: transform 0.2s; 
    color: var(--text-muted) !important; 
}

/* تفاعلات السايد بار */
.sidebar a:hover {
    background-color: #EFF6FF !important; /* Primary Light */
    color: var(--bs-primary) !important;
}
.sidebar a:hover i { 
    transform: translateX(-3px); 
    color: var(--bs-primary) !important; 
}
.sidebar a.active {
    background-color: var(--bs-primary) !important;
    color: white !important;
}
.sidebar a.active i { color: white !important; }

/* أزرار التقفيل والخروج أسفل السايد بار */
.sidebar .border-top { border-color: var(--border-color) !important; }
.sidebar .border-top a.text-warning { color: var(--bs-warning) !important; }
.sidebar .border-top a.text-warning i { color: var(--bs-warning) !important; }
.sidebar .border-top a.text-danger { color: var(--bs-danger) !important; }
.sidebar .border-top a.text-danger i { color: var(--bs-danger) !important; }
.sidebar .border-top a:hover { background-color: transparent !important; opacity: 0.8; }


/* 🌟 تأثيرات الهيدر الذكي */
#top-header {
    transition: transform 0.4s ease-in-out;
}
.main-content {
    transition: padding-top 0.4s ease-in-out; 
}

/* مساحة العمل (Main Content) */
.main-content {
    margin-right: var(--sidebar-width);
    padding: 24px 32px;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin 0.3s;
}

/* حالة إلغاء السايد بار (Grid Mode) */
#set-layout-mode:checked ~ .main-content,
body:has(#set-layout-mode:checked) .main-content {
    margin-right: 0 !important;
    width: 100% !important;
}

/* الهيدر العلوي الذكي (Glassmorphism) */
.smart-header {
    background-color: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.smart-header .header-logo { color: var(--bs-primary) !important; }

/* ================= 🌟 إصلاح القائمة المنسدلة للهيدر ================= */
.user-info-btn {
    background-color: var(--bg-surface);
}
.user-info-btn:hover {
    background-color: var(--border-color) !important;
}
.admin-dropdown {
    display: none; 
    flex-direction: column;
    min-width: 220px;
    left: 0; 
    top: 100%;
    z-index: 2000;
}
.admin-dropdown.show {
    display: flex !important;
    animation: slideUpFade 0.2s ease forwards;
}
.dropdown-item {
    text-decoration: none;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}
.dropdown-item:hover {
    background-color: var(--bg-body) !important;
}

/* ================= 💎 المحافظ والخدمات المالية (Clean Corporate UI) ================= */
.wallet-card-clean {
    background: var(--bg-surface);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--main-blue);
    transition: all 0.3s ease;
}
.wallet-card-clean:hover {
    box-shadow: 0 8px 20px rgba(0, 120, 215, 0.15);
    transform: translateY(-2px);
}
.icon-box-blue {
    background: rgba(0, 120, 215, 0.1);
    color: var(--main-blue);
    border-radius: 10px;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.btn-main-blue {
    background-color: var(--main-blue);
    color: #ffffff;
    border: none;
}
.btn-main-blue:hover {
    background-color: var(--main-blue-hover);
    color: #ffffff;
}
.btn-exit-red {
    background-color: #f8d7da;
    color: var(--danger-red);
    border: 1px solid #f5c2c7;
}
.btn-exit-red:hover {
    background-color: var(--danger-red);
    color: #ffffff;
}
.modal-header-blue {
    background-color: var(--main-blue);
    color: white;
}

/* ================= 🖼️ 3. النوافذ المنبثقة (Modals) ================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6); 
    display: none; 
    justify-content: center; align-items: center;
    z-index: 2000; 
    backdrop-filter: blur(4px);
}
.modal-box {
    background: var(--bg-surface);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    max-width: 95%;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= 🖱️ 4. التفاعلات والحركات (MIND Animations) ================= */
.btn { transition: all 0.2s ease-in-out; border-radius: 8px; font-weight: 600; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); }
.btn:active { transform: translateY(0); }

.card, .bg-white, .bg-light {
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px 0 rgba(0,0,0,0.06) !important;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(30, 64, 175, 0.04) !important;
    border-color: #BFDBFE !important; 
}

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table th { 
    color: var(--text-muted); 
    font-size: 0.85rem; 
    font-weight: 700; 
    border-bottom: 2px solid var(--border-color) !important; 
    padding: 16px;
}
.table td { 
    border-bottom: 1px solid var(--border-color); 
    vertical-align: middle; 
    padding: 12px 16px;
}
.table-hover tbody tr:hover, .table-striped tbody tr:nth-of-type(odd) { 
    background-color: #F8FAFC !important; 
}
.table-dark { background-color: var(--bs-dark) !important; color: white; }
.table-dark th { color: white; border-color: #334155 !important;}

.tab-content { display: none; }
.tab-content.active { display: block !important; }

/* ================= 📜 5. تخصيصات عامة (Scroll & Skeleton & Print) ================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

.skeleton {
    background: #eee; background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
    border-radius: 5px; background-size: 200% 100%;
    animation: 1.5s shine linear infinite; min-height: 20px; width: 100%; display: inline-block;
}
@keyframes shine { to { background-position-x: -200%; } }

#print-area { display: none; }
@media print {
    body * { display: none !important; }
    #print-area, #print-area * { display: block !important; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; background: white; color: black; }
}

/* ================= 🌙 6. الوضع الليلي (Premium Dark Mode) ================= */
body.dark-mode { 
    --bg-body: #0F172A; 
    --bg-surface: #1E293B; 
    --text-dark: #F8FAFC; 
    --text-muted: #94A3B8;
    --border-color: #334155;
    background-color: var(--bg-body) !important; 
    color: var(--text-dark) !important; 
}

body.dark-mode .text-dark, body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, 
body.dark-mode h4, body.dark-mode h5, body.dark-mode h6, body.dark-mode label { color: var(--text-dark) !important; }
body.dark-mode .text-secondary, body.dark-mode .text-muted { color: var(--text-muted) !important; }

body.dark-mode .card, body.dark-mode .modal-box, body.dark-mode .login-card, body.dark-mode .bg-white, body.dark-mode .bg-light, body.dark-mode .wallet-card-clean { 
    background-color: var(--bg-surface) !important; 
    border-color: var(--border-color) !important; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
}

body.dark-mode .sidebar { background-color: var(--bg-surface) !important; border-color: var(--border-color) !important; }
body.dark-mode .smart-header { background-color: rgba(30, 41, 59, 0.9) !important; border-color: var(--border-color) !important;}
body.dark-mode .sidebar a:hover { background-color: #334155 !important; color: white !important; }
body.dark-mode .sidebar a.active { background-color: var(--bs-primary) !important; color: white !important; }

body.dark-mode input.form-control, body.dark-mode select.form-select { 
    background-color: #0F172A !important; color: white !important; border-color: var(--border-color) !important; 
}
body.dark-mode input.form-control:focus, body.dark-mode select.form-select:focus { 
    border-color: var(--bs-primary) !important; box-shadow: 0 0 0 0.2rem rgba(30, 64, 175, 0.4); 
}

body.dark-mode .table-light, body.dark-mode .table th, body.dark-mode .table-secondary { 
    background-color: #0F172A !important; color: var(--text-muted) !important; border-color: var(--border-color) !important; 
}
body.dark-mode .table td { border-color: var(--border-color) !important; color: #E2E8F0 !important; }
body.dark-mode .table-striped>tbody>tr:nth-of-type(odd)>* { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, 0.02); }
body.dark-mode .table-dark { background-color: #020617 !important; color: #fff !important; }

body.dark-mode .user-info-btn { background-color: var(--bg-body) !important; border-color: var(--border-color) !important; }
body.dark-mode .admin-dropdown { background-color: var(--bg-surface) !important; border-color: var(--border-color) !important; }
body.dark-mode .dropdown-item:hover { background-color: var(--bg-body) !important; }

#admin-branch-container { margin: 0 10px; }
#global-branch-select { border: 2px solid #0d6efd; background-color: #f8f9fa; color: #0d6efd; cursor: pointer; transition: 0.3s; }
#global-branch-select:hover { background-color: #0d6efd; color: white; }
.table-responsive { scrollbar-width: thin; scrollbar-color: #0d6efd #f1f1f1; }
#dashboard-branch-container { z-index: 100; position: relative; visibility: visible !important; }

/* ================= 🌟 الهيدر الذكي (إصلاح المسافات) ================= */
#main-header {
    display: none !important; 
    position: absolute;       
    top: 0;
    right: 0;
    width: 100%;
    z-index: 1050;
    margin: 0 !important;     
    padding: 10px 20px !important; 
    transition: transform 0.4s ease, opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}




/* تنسيقات شاشة التحميل */
#mind-global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f8f9fa; /* لون فاتح مريح */
    z-index: 999999; /* فوق أي حاجة في الشاشة */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader-content {
    text-align: center;
    animation: pulse 1.5s infinite;
}

.spinner-mind {
    width: 4rem;
    height: 4rem;
    border-width: 0.3em;
    color: #800020; /* أحمر مارون */
}

.loader-text {
    color: #c5a059; /* ذهبي ماط */
    font-weight: bold;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
/* تأثير اللمعان بتاع السكيلتون */
.skeleton-box {
    background: #e2e5e7;
    background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    border-radius: 4px;
    display: inline-block;
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* أمثلة لمقاسات السكيلتون */
.sk-text { width: 100%; height: 15px; margin-bottom: 10px; }
.sk-title { width: 60%; height: 20px; margin-bottom: 15px; }
.sk-btn { width: 80px; height: 35px; border-radius: 8px; }






body:has(#set-layout-mode:checked) #main-header,
#set-layout-mode:checked ~ .main-content #main-header { display: flex !important; }
#main-header.header-hidden { transform: translateY(-100%); opacity: 0; }
.main-content { padding-top: 15px !important; position: relative; }

/* ================= إعدادات الطباعة الموحدة ================= */
@media print {
    body > * { display: none !important; }
    .print-active {
        display: block !important; position: absolute; top: 0; left: 0; width: 100%; margin: 0; padding: 0; direction: rtl; background-color: white;
    }
}

/* ================= القائمة الجانبية المطوية (Sidebar Mini) ================= */
#main-sidebar { transition: width 0.25s ease, padding 0.25s ease; }
body.sidebar-mini #main-sidebar {
    width: 62px !important;
    padding: 12px 6px;
}
body.sidebar-mini #main-sidebar h3,
body.sidebar-mini #main-sidebar .sidebar-user-zone,
body.sidebar-mini #main-sidebar .nav-group-title,
body.sidebar-mini #main-sidebar .collapse-label {
    display: none !important;
}
body.sidebar-mini #main-sidebar a {
    justify-content: center;
    font-size: 0;
    padding: 12px 8px;
}
body.sidebar-mini #main-sidebar a i {
    font-size: 1.15rem;
    margin: 0;
}
body.sidebar-mini #main-sidebar .btn {
    padding: 8px 0;
}