/* الدليل الأساسي للمتغيرات - لوحة ألوان احترافية */
:root {
    --primary-color: #4361ee;
    --primary-dark: #3a0ca3;
    --secondary-color: #4cc9f0;
    --accent-color: #f72585;
    --success-color: #059669;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --gray-color: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius: 12px;
    --font-family: 'Droid Arabic Kufi', 'Droid Arabic Kufi', Tahoma, Geneva, Verdana, sans-serif;
    --transition: all 0.3s ease;
}

/* استيراد الخط */
@import url('https://fonts.googleapis.com/earlyaccess/droidarabickufi.css');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
}

body {
    direction: rtl;
    text-align: right;
    font-family: var(--font-family);
    background-color: #f1f5f9;
    color: var(--dark-color);
    line-height: 1.6;
    font-size: 15px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

ul {
    list-style: none;
}

/* تحسين السكرول بار */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    transition: var(--transition);
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(67, 97, 238, 0.4);
}

.btn-secondary {
    background-color: white;
    color: var(--dark-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #f8fafc;
    border-color: var(--gray-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #047857;
}

/* حقول الإدخال */
.form-control,
select.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--font-family);
    transition: var(--transition);
    background-color: white;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

/* تسجيل الدخول */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f6f8fd 0%, #eef2f9 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-box h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-weight: 800;
}

/* التخطيط العام */
.wrapper {
    display: flex;
}

/* القائمة الجانبية */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    min-height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.05);
    border-left: 1px solid var(--border-color);
}

.brand {
    padding: 25px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.brand i {
    font-size: 1.8rem;
}

.sidebar-menu {
    padding: 20px 15px;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--gray-color);
    border-radius: var(--radius);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-menu li a i {
    font-size: 1.3rem;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background-color: #eff3ff;
    color: var(--primary-color);
    font-weight: 700;
}

/* المحتوى الرئيسي */
.main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 99;
}

.top-header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-header .user-avatar {
    width: 40px;
    height: 40px;
    background: #e0e7ff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.page-content {
    padding: 40px;
}

/* البطاقات والإحصائيات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    border: 1px solid #f0f2f5;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-left: 20px;
}

.stat-icon.blue {
    background-color: #eff6ff;
    color: #3b82f6;
}

.stat-icon.green {
    background-color: #ecfdf5;
    color: #10b981;
}

.stat-icon.orange {
    background-color: #fff7ed;
    color: #f97316;
}

.stat-icon.purple {
    background-color: #f5f3ff;
    color: #8b5cf6;
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: var(--dark-color);
    line-height: 1;
}

.stat-info p {
    color: var(--gray-color);
    font-size: 0.95rem;
    font-weight: 500;
}

/* الجداول */
.table-responsive {
    background: white;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: right;
    padding: 16px;
    color: var(--gray-color);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid #f1f5f9;
}

td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--dark-color);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* العناوين */
h2 {
    font-size: 1.8rem;
    margin-bottom: 25px;
    color: var(--dark-color);
    font-weight: 800;
    position: relative;
    padding-bottom: 10px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* التنبيهات */
.alert {
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 25px;
    border: 1px solid transparent;
    font-weight: 500;
}

.alert-danger {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.alert-success {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

/* Grid for Dashboard Extra */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

/* Responsive Design - Mobile & Tablet */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    :root {
        --sidebar-width: 240px;
    }
}

@media (max-width: 768px) {

    /* إخفاء القائمة الجانبية على الموبايل */
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* تعديل المحتوى الرئيسي */
    .main-content {
        margin-right: 0;
        width: 100%;
    }

    /* زر القائمة للموبايل */
    .mobile-menu-btn {
        display: block !important;
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 9999;
        background: var(--primary-color);
        color: white;
        border: none;
        width: 45px;
        height: 45px;
        border-radius: 10px;
        font-size: 1.5rem;
        cursor: pointer;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    }

    /* تعديل الهيدر */
    .top-header {
        padding: 0 60px 0 20px;
    }

    /* تعديل المحتوى */
    .page-content {
        padding: 20px;
    }

    /* تعديل الجداول */
    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 10px 8px;
    }

    /* تعديل الأزرار */
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    /* تعديل بطاقات الإحصائيات */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card {
        padding: 20px;
    }

    /* تعديل النماذج */
    .form-control {
        font-size: 16px;
        /* لمنع التكبير التلقائي في iOS */
    }

    /* تعديل العناوين */
    h2 {
        font-size: 1.5rem;
    }

    /* تعديل لوحة التحكم */
    .welcome-banner {
        padding: 25px;
    }

    .welcome-banner h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {

    /* تعديلات إضافية للشاشات الصغيرة جداً */
    .page-content {
        padding: 15px;
    }

    .top-header {
        height: 60px;
        padding: 0 50px 0 15px;
    }

    .top-header .user-info {
        font-size: 0.85rem;
    }

    .top-header .user-avatar {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }

    /* إخفاء بعض الأعمدة في الجداول على الشاشات الصغيرة */
    table th:nth-child(n+6),
    table td:nth-child(n+6) {
        display: none;
    }

    /* تعديل الأزرار */
    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* تعديل النماذج */
    .row {
        grid-template-columns: 1fr !important;
    }

    h2 {
        font-size: 1.3rem;
    }

    .welcome-banner h1 {
        font-size: 1.5rem;
    }

    .welcome-banner p {
        font-size: 0.95rem;
    }
}

/* تحسين الطباعة */
@media print {

    .sidebar,
    .top-header,
    .mobile-menu-btn,
    button,
    .btn,
    a[href*="delete"],
    a[href*="edit"] {
        display: none !important;
    }

    .main-content {
        margin: 0;
        width: 100%;
    }

    .page-content {
        padding: 0;
    }

    table {
        page-break-inside: avoid;
    }
}

/* زر القائمة المخفي افتراضياً */
.mobile-menu-btn {
    display: none;
}

/* تحسين الأيقونات */
.stat-icon.teal {
    background-color: #ccfbf1;
    color: #0f766e;
}

.stat-icon.red {
    background-color: #fee2e2;
    color: #dc2626;
}