/* المسار: assets/style.css */
:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --secondary: #10b981;
    --bg-body: #f3f4f6;
    --surface: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 16px;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --nav-height: 70px;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    direction: rtl;
    /* مساحة علوية للشريط العلوي، وسفلية للقائمة السفلية في الموبايل */
    padding-top: 75px; 
    padding-bottom: calc(var(--nav-height) + 25px); 
    overflow-x: hidden;
    line-height: 1.5;
}

/* =========================================
   الشريط العلوي للموبايل (لوجو + خروج)
   ========================================= */
.mobile-top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    z-index: 9999;
}

/* =========================================
   تخطيط الموبايل (الأساسي - Mobile First)
   ========================================= */
.app-container {
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    overflow-x: hidden; /* لمنع ظهور شريط التمرير الأفقي المزعج */
}

main {
    flex: 1;
    min-width: 0; /* ضروري جداً لكي لا تتمدد الجداول وتكسر الـ Grid */
    width: 100%;
}

.desktop-sidebar {
    display: none;
}

/* القوائم السفلية للموبايل */
.mobile-nav, .admin-mobile-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    z-index: 9999;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-link, .mobile-nav-item {
    display: flex; flex-direction: column; align-items: center;
    color: #94a3b8; text-decoration: none; font-size: 0.75rem; font-weight: 600;
    padding: 6px 10px; border-radius: 12px; transition: all 0.3s ease;
}

.nav-link.active, .mobile-nav-item.active {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

.nav-link svg, .mobile-nav-item svg { margin-bottom: 4px; }

/* =========================================
   الشاشات الكبيرة (Desktop & Tablets)
   ========================================= */
@media (min-width: 992px) {
    /* إلغاء هوامش الموبايل تماماً */
    body { padding-top: 0; padding-bottom: 0; }
    
    .app-container {
        max-width: 1200px;
        grid-template-columns: 260px 1fr;
        padding: 40px;
        gap: 30px;
    }
    
    /* إخفاء أشرطة الموبايل العلوية والسفلية */
    .mobile-nav, .admin-mobile-nav, .mobile-top-bar {
        display: none !important; 
    }
    
    .desktop-sidebar {
        display: block;
        background: white;
        height: calc(100vh - 80px);
        position: sticky;
        top: 40px;
        border-radius: var(--radius);
        padding: 30px;
        box-shadow: var(--shadow-md);
        overflow-y: auto; /* للسماح بتمرير القائمة الجانبية إذا صغرت الشاشة */
    }
    
    .desktop-sidebar .btn { 
        width: 100%; justify-content: flex-start; margin-bottom: 10px; text-align: right; 
    }
}

/* =========================================
   البطاقات والجداول والأزرار 
   ========================================= */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid #f1f5f9;
    transition: 0.2s;
    overflow-wrap: break-word;
}

.wallet-card { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border: none; }

.table-container {
    width: 100%; 
    overflow-x: auto; /* السماح بسحب الجدول يميناً ويساراً في الموبايل */
    -webkit-overflow-scrolling: touch; 
    border-radius: var(--radius); 
    background: white; 
    border: 1px solid #e2e8f0; 
    margin-top: 15px;
}

table { width: 100%; border-collapse: collapse; white-space: nowrap; min-width: 600px; }
thead tr { background-color: #f8fafc; border-bottom: 2px solid #e2e8f0; }
th, td { padding: 15px; text-align: right; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #f9fafb; }

.btn {
    padding: 12px 20px; border-radius: 12px; border: none; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s;
    font-family: inherit; text-decoration: none; font-size: 0.95rem;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3); }
.btn-outline { background: transparent; border: 2px solid #e5e7eb; color: var(--text-muted); }
.btn-danger { background: #fee2e2; color: #b91c1c; }

input, select {
    width: 100%; padding: 14px; border: 2px solid #e5e7eb; border-radius: 12px; font-family: inherit;
    font-size: 1rem; outline: none; background: #f9fafb; transition: border 0.3s;
}
input:focus, select:focus { border-color: var(--primary); background: white; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; display: inline-block; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }

/* =========================================
   النوافذ المنبثقة (Modals)
   ========================================= */
.custom-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); display: none; align-items: center; justify-content: center;
    z-index: 9999; backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s ease;
}
.custom-modal.show { opacity: 1; }
.modal-content {
    background: white; padding: 25px; border-radius: 16px; width: 92%; max-width: 420px;
    text-align: center; transform: scale(0.9); transition: transform 0.3s ease; box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-height: 90vh; overflow-y: auto;
}
.custom-modal.show .modal-content { transform: scale(1); }