:root {
    --dark: #1e293b;
    --primary: #3b82f6; /* Corporate Blue */
    --light: #f1f5f9;
    --white: #ffffff;
    --text: #334155;
    --success: #10b981;
    --danger: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Tajawal', sans-serif; }
body { background: var(--light); color: var(--text); height: 100vh; overflow: hidden; }

/* Login Screen */
.login-container {
    height: 100vh; display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, var(--dark), #0f172a);
}
.login-box {
    background: white; padding: 40px; border-radius: 15px; width: 400px; text-align: center;
}
.login-box h1 { color: var(--dark); margin-bottom: 10px; }
.login-box h1 span { color: var(--primary); }
.login-box input {
    width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ddd; border-radius: 8px;
}
.login-box button {
    width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; font-size: 1rem;
}
.hint { font-size: 0.8rem; color: #888; margin-top: 10px; }

/* App Layout */
.app-layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: 260px; background: var(--dark); color: white; display: flex; flex-direction: column; }
.sidebar .brand { padding: 20px; font-size: 1.5rem; font-weight: bold; text-align: center; border-bottom: 1px solid #334155; }
.sidebar .brand span { color: var(--primary); }

.user-profile { padding: 20px; display: flex; align-items: center; gap: 10px; background: #28364a; }
.avatar { width: 40px; height: 40px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; }

nav ul { list-style: none; padding: 10px; flex: 1; }
nav li {
    padding: 12px 15px; margin-bottom: 5px; cursor: pointer; border-radius: 8px; transition: 0.3s; display: flex; gap: 10px; align-items: center;
}
nav li:hover, nav li.active { background: var(--primary); }
.logout-btn { background: var(--danger); color: white; border: none; padding: 15px; cursor: pointer; text-align: right; }

/* Main Content */
main { flex: 1; padding: 30px; overflow-y: auto; background: var(--light); }

/* Generic Dashboard Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border-right: 4px solid var(--primary); }
.stat-card h3 { font-size: 0.9rem; color: #64748b; }
.stat-card .val { font-size: 1.8rem; font-weight: bold; margin-top: 5px; }

/* Modules Sections */
.module-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { padding: 15px; text-align: right; border-bottom: 1px solid #e2e8f0; }
.data-table th { background: #f8fafc; font-weight: 600; color: #475569; }
/* =========================================
   التجاوب مع الشاشات (Responsive Design)
   ========================================= */

/* للشاشات المتوسطة والصغيرة (التابلت والموبايل) */
@media (max-width: 768px) {
    /* تعديل شاشة تسجيل الدخول */
    .login-box {
        width: 90%; /* بدلاً من 400px ثابتة */
        padding: 30px 20px;
    }

    /* تعديل الهيكل الأساسي للتطبيق */
    .app-layout {
        flex-direction: column; /* تحويل التخطيط لعمودي */
        overflow-y: auto; /* السماح بالتمرير العمودي للصفحة كلها */
    }

    /* تعديل الشريط الجانبي (Sidebar) */
    .sidebar {
        width: 100%;
        height: auto;
        border-bottom: 2px solid #e2e8f0;
    }

    .user-profile {
        justify-content: center;
    }

    /* تحويل القائمة الجانبية لأزرار بجانب بعضها */
    nav ul {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    nav li {
        flex: 1 1 45%; /* كل زرين في صف */
        justify-content: center;
        font-size: 0.9rem;
        padding: 10px;
    }

    .logout-btn {
        text-align: center;
    }

    /* ترتيب العناوين داخل الصفحات */
    .module-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .module-header button {
        width: 100%;
    }

    /* إعداد حاوية الجداول للتمرير الأفقي */
    .table-container {
        overflow-x: auto;
        width: 100%;
        background: white;
        border-radius: 10px;
    }
}

/* للشاشات الصغيرة جداً (الموبايلات الرفيعة) */
@media (max-width: 480px) {
    nav li {
        flex: 1 1 100%; /* زر واحد في كل صف */
    }
    
    .stats-grid {
        grid-template-columns: 1fr; /* كارت واحد في الصف للداشبورد */
    }
}