/* filepath: /assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&display=swap');

/* ==========================================
   1. المتغيرات الأساسية (Design Tokens)
========================================== */
:root {
    /* ألوان الخلفيات */
    --bg-main: #0a0a0a;
    --bg-card: #141414;
    --bg-sidebar: #0d0d0d;
    --bg-glass: rgba(255, 255, 255, 0.04);
    
    /* ألوان الحدود والتأثيرات */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* الألوان الوظيفية (Accents) */
    --accent: #D62828;
    --accent-hover: #b81f1f;
    --accent-dim: rgba(214, 40, 40, 0.15);
    
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.12);
    
    --yellow: #f59e0b;
    --yellow-dim: rgba(245, 158, 11, 0.12);
    
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.12);
    
    /* ألوان النصوص */
    --text-main: #f0f0f0;
    --text-muted: #888888;
    
    /* الحواف الدائرية */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* الخط */
    --font-primary: 'Cairo', sans-serif;
}

/* ==========================================
   2. الإعدادات العامة (Reset & Basics)
========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-primary);
    direction: rtl; /* اتجاه عربي */
    min-height: 100vh;
    overflow: hidden; /* لمنع السكرول المزدوج */
    -webkit-font-smoothing: antialiased;
}

/* شريط التمرير (Custom Scrollbar) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ==========================================
   3. الهيكل الرئيسي (Layout Architecture)
========================================== */
.app-layout { 
    display: flex; 
    width: 100vw; 
    height: 100vh; 
}

.main-wrapper { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

.main-content { 
    flex: 1; 
    overflow-y: auto; 
    padding: 24px; 
    scroll-behavior: smooth;
}

/* ==========================================
   4. المكونات المشتركة (UI Components)
========================================== */
/* الكروت الزجاجية */
.card, .glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: transform 0.2s, border-color 0.2s;
}

/* كروت المؤشرات */
.kpi-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.2s;
}
.kpi-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

/* الجداول الحديثة */
.table-modern { width: 100%; border-collapse: collapse; }
.table-modern th {
    padding: 12px 16px; font-size: 12px; font-weight: 800;
    color: var(--text-muted); text-align: right;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.02);
}
.table-modern td {
    padding: 12px 16px; font-size: 13px; color: var(--text-main);
    border-bottom: 1px solid var(--border-color); transition: background 0.15s;
    vertical-align: middle;
}
.table-modern tr:hover td { background: rgba(255,255,255,0.02); }

/* الشارات (Badges) */
.badge {
    border-radius: 6px; padding: 4px 10px; font-size: 12px;
    font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

/* التبويبات (Tabs) */
.tab-btn {
    background: transparent; color: var(--text-muted); border: none;
    padding: 8px 16px; font-size: 13px; font-weight: 700; border-radius: 8px;
    cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.tab-btn.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.tab-btn:hover:not(.active) { color: var(--text-main); }
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

/* ==========================================
   5. النماذج والمدخلات (Forms & Inputs)
========================================== */
.custom-input, .custom-select, .modal-input, .modal-select, .modal-textarea, .form-control {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    width: 100%;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
    margin-bottom: 16px;
}
.custom-input:focus, .custom-select:focus, .modal-input:focus, .modal-select:focus { 
    border-color: var(--accent); 
    background: rgba(255,255,255,0.06);
}
.custom-select option, .modal-select option { background: #161616; color: white; }
.modal-label, .form-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 700; }

/* ==========================================
   6. النوافذ المنبثقة (Modals)
========================================== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    display: none; justify-content: center; align-items: center; z-index: 1000; padding: 20px;
}
.modal-content-box {
    background: #161616; border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 28px; width: 100%;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    position: relative; animation: slideUp 0.3s ease-out;
}

/* ==========================================
   7. الإشعارات والتحميل (Toasts & Loaders)
========================================== */
#toast-container { position: fixed; bottom: 20px; left: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: rgba(20, 20, 20, 0.95); backdrop-filter: blur(10px);
    border-right: 4px solid var(--green); color: white; padding: 15px 20px;
    border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700;
    animation: slideRight 0.3s ease-out forwards; min-width: 250px; direction: rtl;
}
.toast.error { border-right-color: var(--accent); }
.toast.warning { border-right-color: var(--yellow); }
.toast.fade-out { animation: fadeOut 0.3s ease-in forwards; }

.global-loader {
    position: fixed; inset: 0; background: rgba(10, 10, 10, 0.8); backdrop-filter: blur(5px);
    display: none; justify-content: center; align-items: center; z-index: 10000;
}
.spinner {
    width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite;
}

/* ==========================================
   8. الرسوم المتحركة (Animations)
========================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideRight { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-pulse { animation: pulseGlow 2.5s infinite; }
@keyframes pulseGlow {
    0% { text-shadow: 0 0 10px rgba(168, 85, 247, 0.4); transform: scale(1); }
    50% { text-shadow: 0 0 25px rgba(168, 85, 247, 0.9), 0 0 40px rgba(168, 85, 247, 0.6); transform: scale(1.05); }
    100% { text-shadow: 0 0 10px rgba(168, 85, 247, 0.4); transform: scale(1); }
}

/* ==========================================
   9. التجاوب مع الشاشات (Responsive Mobile)
========================================== */
@media (max-width: 1024px) {
    /* للتابلت */
    .pos-container { grid-template-columns: 1fr; height: auto; overflow-y: auto; }
    .cart-panel { min-height: 500px; }
}

@media (max-width: 768px) {
    /* للموبايل */
    .app-layout { flex-direction: column; overflow: auto; }
    
    /* إخفاء القائمة الجانبية أو جعلها بأزرار سفلية */
    .sidebar { display: none; } 
    
    .main-content { padding: 16px; overflow: visible; }
    
    /* ترتيب الجريد ليصبح عمودي */
    div[style*="display: grid"] { grid-template-columns: 1fr !important; }
    
    /* تظبيط الجداول للموبايل (Horizontal Scroll) */
    .table-modern { min-width: 600px; }
    .card { overflow-x: auto; padding: 16px; }

    /* تكبير أزرار الإدخال لتسهيل اللمس */
    .custom-input, .custom-select, .btn-action, .btn-submit, .tab-btn {
        min-height: 48px;
        font-size: 14px;
    }

    /* تعديل الإشعارات لتملأ الشاشة أدنى الموبايل */
    #toast-container { left: 5%; right: 5%; bottom: 15px; width: 90%; }
    .toast { width: 100%; min-width: unset; justify-content: center; }
}

/* ==========================================
   10. تنسيقات الطباعة (Print Styles)
========================================== */
@media print {
    body, .app-layout { background: #fff !important; color: #000 !important; height: auto !important; overflow: visible !important; }
    .sidebar, .topbar-container, button, .action-buttons, .filters, .modal-overlay { display: none !important; }
    .main-wrapper, .main-content { width: 100% !important; padding: 0 !important; margin: 0 !important; overflow: visible !important;}
    .card, .kpi-card, .glass-panel { background: #fff !important; border: 1px solid #ddd !important; box-shadow: none !important; color: #000 !important; break-inside: avoid; }
    .table-modern th { background: #f0f0f0 !important; color: #000 !important; border-bottom: 2px solid #000 !important; }
    .table-modern td { border-bottom: 1px solid #eee !important; color: #000 !important; }
    * { text-shadow: none !important; box-shadow: none !important; }
    a { text-decoration: none !important; color: #000 !important; }
}