@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

:root { 
    --primary: #0f172a; 
    --secondary: #3b82f6; 
    --success: #10b981; 
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc; 
    --sidebar-width: 260px; 
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Cairo', sans-serif; }
body { background-color: var(--bg); display: flex; min-height: 100vh; direction: rtl; color: #334155; overflow-x: hidden; }

/* ---------------------------------------------------
   تخصيص شريط التمرير (Scrollbar) لستايل البرامج
----------------------------------------------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------------------------------------------------
   السايد بار (القائمة الجانبية)
----------------------------------------------------- */
.sidebar { width: var(--sidebar-width); background: var(--primary); color: #fff; position: fixed; right: 0; top: 0; bottom: 0; padding-top: 20px; z-index: 1000; box-shadow: -4px 0 15px rgba(0,0,0,0.05); transition: 0.3s; }
.sidebar-brand { text-align: center; margin-bottom: 30px; font-weight: 900; font-size: 22px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); color: #fff; }
.sidebar-menu { display: flex; flex-direction: column; gap: 5px; padding: 0 10px; }
.sidebar-menu a { display: flex; align-items: center; padding: 12px 15px; color: #94a3b8; text-decoration: none; border-radius: 8px; transition: 0.3s; font-size: 15px; font-weight: 600; }
.sidebar-menu a:hover, .sidebar-menu a.active { background: var(--secondary); color: #fff; }
.sidebar-menu a i { margin-left: 12px; width: 20px; text-align: center; font-size: 18px; }

/* ---------------------------------------------------
   المحتوى الرئيسي وأنيميشن الدخول
----------------------------------------------------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.main-content { 
    flex: 1; 
    margin-right: var(--sidebar-width); 
    padding: 30px 40px; 
    width: calc(100% - var(--sidebar-width)); 
    min-height: 100vh; 
    animation: fadeIn 0.4s ease-out; 
}

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid #e2e8f0; padding-bottom: 15px; }
.page-header h2 { color: var(--primary); font-weight: 800; font-size: 24px; margin: 0; }

/* ---------------------------------------------------
   الكروت (Cards)
----------------------------------------------------- */
.card { background: #fff; padding: 25px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; margin-bottom: 25px; }
.card-title { font-size: 18px; font-weight: 700; color: var(--primary); margin-bottom: 20px; border-right: 4px solid var(--secondary); padding-right: 10px; }

/* ---------------------------------------------------
   الجداول
----------------------------------------------------- */
.table-responsive { width: 100%; overflow-x: auto; background: #fff; border-radius: 12px; border: 1px solid #e2e8f0; box-shadow: 0 4px 6px rgba(0,0,0,0.02); margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 15px 10px; border-bottom: 1px solid #e2e8f0; text-align: right; font-size: 14px; }
th { background: #f8fafc; color: #475569; font-weight: 700; white-space: nowrap; }
tr:hover { background-color: #f1f5f9; }

/* ---------------------------------------------------
   النماذج (Forms)
----------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 15px; }
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 8px; font-weight: 600; color: #475569; font-size: 13px; }
input, select, textarea { width: 100%; padding: 10px 15px; border: 1px solid #cbd5e1; border-radius: 8px; outline: none; transition: 0.3s; font-size: 14px; font-family: 'Cairo'; font-weight: 600;}
input:focus, select:focus, textarea:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

/* ---------------------------------------------------
   الزراير الأساسية وأزرار الإجراءات
----------------------------------------------------- */
.btn { padding: 10px 15px; border-radius: 8px; cursor: pointer; font-weight: 700; border: none; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: 0.3s; font-family: 'Cairo'; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.btn-primary { background: var(--secondary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

.action-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: bold; text-decoration: none; border: none; cursor: pointer; color: #fff; margin-left: 5px; transition: 0.3s; }
.action-btn:hover { filter: brightness(0.9); }
.btn-view { background: #3b82f6; }
.btn-edit { background: #f59e0b; }
.btn-delete { background: #ef4444; }

/* ---------------------------------------------------
   البادجات (Badges) للحالات
----------------------------------------------------- */
.badge { padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: bold; display: inline-block;}
.badge.waiting { background: #fef08a; color: #854d0e; }
.badge.scheduled { background: #e0f2fe; color: #0369a1; }
.badge.completed { background: #d1fae5; color: #065f46; }
.badge.cancelled { background: #fee2e2; color: #b91c1c; }

/* ---------------------------------------------------
   شاشة تسجيل الدخول
----------------------------------------------------- */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100vw; background: var(--bg); margin: 0; padding: 15px; box-sizing: border-box;}
.login-card { background: #fff; padding: 40px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); width: 100%; max-width: 400px; border: 1px solid #e2e8f0; text-align: center; }
.login-icon { font-size: 50px; color: var(--secondary); margin-bottom: 15px; }
.login-title { font-size: 24px; font-weight: 900; color: var(--primary); margin-bottom: 5px; }
.login-subtitle { font-size: 14px; color: #64748b; margin-bottom: 25px; }

/* ---------------------------------------------------
   التجاوب مع الشاشات الأصغر (Laptops)
----------------------------------------------------- */
@media (max-width: 1024px) {
    :root { --sidebar-width: 200px; } 
    .main-content { padding: 20px; }
}

/* ===================================================
   تصميم الموبايل الاحترافي (Hamburger Menu)
====================================================== */
@media (max-width: 768px) {
    body { flex-direction: column; display: block; overflow-x: hidden; }

    /* إخفاء القائمة الجانبية وسحبها لليمين خارج الشاشة */
    .sidebar { 
        position: fixed !important; 
        top: 0; 
        right: -300px; /* مخفية برا الشاشة */
        width: 260px !important; 
        height: 100vh !important; 
        z-index: 10000 !important; 
        transition: 0.4s ease-in-out !important; 
        box-shadow: -5px 0 20px rgba(0,0,0,0.5) !important;
        padding-top: 60px !important;
    }
    
    /* الكلاس ده اللي الجافاسكريبت هيضيفه عشان يظهر القائمة */
    .sidebar.show-sidebar { right: 0 !important; }

    .sidebar-brand { font-size: 18px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,0.1); }
    .sidebar-menu { display: flex; flex-direction: column; overflow-y: auto; padding: 0 15px; gap: 10px; }
    .sidebar-menu a { padding: 12px 15px; font-size: 15px; white-space: normal; display: block; width: 100%;}

    /* المحتوى الرئيسي ياخد عرض الشاشة */
    .main-content { margin-right: 0 !important; width: 100% !important; padding: 15px !important; padding-top: 70px !important; }

    /* رص الكروت تحت بعضها */
    .stats-grid, .bottom-grid, .form-grid { display: flex !important; flex-direction: column !important; gap: 15px; }
    div[style*="display: flex; gap:"] { flex-direction: column !important; gap: 15px !important; }
    
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .card { padding: 15px; margin-bottom: 15px; width: 100% !important; box-sizing: border-box;}
    
    /* الجداول تسمح بالسحب بالعرض */
    .table-responsive { width: 100%; border: none; box-shadow: none; border-radius: 0; overflow-x: auto;}
    table { min-width: 500px; } 
}