@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --dark: #1e293b;
    --bg: #f8fafc;
    --text: #334155;
    --sidebar-width: 250px; /* عرض السايدبار الثابت */
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }
body { font-family: 'Cairo', sans-serif; background: var(--bg); margin: 0; color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; padding: 0; margin: 0; }

/* --- Layout --- */
.wrapper { display: flex; min-height: 100vh; position: relative; }

/* --- Sidebar (ثابت دائماً) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark);
    color: #94a3b8;
    position: fixed; 
    top: 0; bottom: 0; left: 0;
    z-index: 1000;
    display: flex; flex-direction: column;
    overflow-y: auto; /* لتمكين التمرير إذا كانت القائمة طويلة */
}
body[dir="rtl"] .sidebar { left: auto; right: 0; }

.sidebar .logo {
    min-height: 70px; display: flex; align-items: center; padding: 0 20px;
    font-size: 1.3rem; font-weight: 700; color: white; background: rgba(0,0,0,0.2);
}
.sidebar nav { padding: 15px; }

.nav-link {
    display: flex; align-items: center; padding: 12px 15px; margin-bottom: 5px;
    border-radius: var(--radius); color: #cbd5e1; font-weight: 600;
}
.nav-link:hover, .nav-link.active { background: var(--primary); color: white; }
.nav-link i { width: 25px; text-align: center; font-size: 1.1rem; }

/* إخفاء زر الموبايل نهائياً */
.menu-toggle { display: none !important; }

/* --- Main Content --- */
.main-content {
    flex: 1; 
    margin-left: var(--sidebar-width); 
    padding: 20px;
    width: calc(100% - var(--sidebar-width)); 
    /* لا يوجد transition أو media query لتغيير الهامش */
}
body[dir="rtl"] .main-content { margin-left: 0; margin-right: var(--sidebar-width); }

/* --- Components --- */
.card, .form-card, .search-box { background: white; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; border: 1px solid #e2e8f0; }
input, select { width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95rem; outline: none; background: #fff; height: 45px; }
input:focus, select:focus { border-color: var(--primary); }

.btn { display: inline-flex; justify-content: center; align-items: center; padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; border: none; font-size: 0.9rem; text-align: center; color: white !important; }
.btn-primary { background: var(--primary) !important; }
.btn-danger { background: #ef4444 !important; }
.btn-warning { background: #f59e0b !important; }
.btn-success { background: #10b981 !important; }
.btn-dark { background: var(--dark) !important; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th { background: #f8fafc; padding: 12px; text-align: inherit; border-bottom: 2px solid #e2e8f0; color: #475569; font-weight: 700; }
td { padding: 12px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }

/* في الموبايل، الجدول يصبح قابل للتمرير أفقياً لكي لا يخرب التصميم */
@media (max-width: 768px) {
    .card { overflow-x: auto; } /* السماح بالتمرير داخل البطاقة */
    table { min-width: 600px; } /* ضمان عرض أدنى للجدول */
}

/* Grids - تحويل الأعمدة لسطر واحد في الموبايل للحفاظ على المقروئية داخل المساحة الضيقة */
.grid-2, .booking-grid, .edit-grid, .dashboard-grid, .charts-row, .alert-section { 
    display: grid; 
    gap: 20px; 
}

/* التخطيط الافتراضي (حاسوب) */
.grid-2, .booking-grid, .charts-row, .alert-section { grid-template-columns: 1fr 1fr; }
.dashboard-grid { grid-template-columns: repeat(4, 1fr); }
.edit-grid { grid-template-columns: 3fr 2fr; }

/* التخطيط للموبايل (تحت بعض) لكي تتناسب مع المساحة المتبقية */
@media (max-width: 900px) {
    .grid-2, .booking-grid, .dashboard-grid, .charts-row, .alert-section, .edit-grid { 
        grid-template-columns: 100% !important; 
    }
}

/* Upload Box & Alerts */
.file-box { border: 2px dashed #cbd5e1; padding: 15px; text-align: center; border-radius: 8px; background: #f8fafc; margin-bottom: 15px; cursor: pointer; position: relative; }
.file-box input[type="file"] { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.stat-card { background: white; padding: 20px; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid #e2e8f0; }
.stat-card h3 { margin: 0; font-size: 1.5rem; color: var(--dark); }
.alert-box { background: white; padding: 15px; border-radius: 12px; box-shadow: var(--shadow); border-left: 5px solid; border: 1px solid #e2e8f0; }
.alert-box.returns { border-left-color: #ef4444; } 
.alert-box.pickups { border-left-color: #10b981; }
.alert-box.insurance { border-left-color: #3498db; }
.alert-box.maintenance { border-left-color: #f59e0b; }
.alert-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 0.85rem; }
