/* === إعادة تعيين أساسية وتحسينات عامة === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4A90E2; 
    --primary-color-rgb: 74,144,226; /* لتسهيل استخدامه في rgba */
    --secondary-color: #50E3C2; 
    --accent-color: #F5A623; 
    --text-color: #4A4A4A; 
    --light-text-color: #9B9B9B; 
    --bg-color: #F7F9FC; 
    --surface-color: #FFFFFF; 
    --border-color: #E0E6ED; 
    --font-family: 'Inter', 'Cairo', sans-serif;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --box-shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --box-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    /* متغيرات Bootstrap احتياطية إذا لم تكن مستخدمة بالكامل */
    --bs-primary: #0d6efd; --bs-success: #198754; --bs-danger: #dc3545;
    --bs-info: #0dcaf0; --bs-warning: #ffc107; --bs-light: #f8f9fa;
    --bs-dark: #212529; --bs-secondary: #6c757d;
}

body {
    font-family: var(--font-family);
    line-height: 1.65;
    background-color: var(--bg-color);
    color: var(--text-color);
    direction: rtl;
    font-size: 15px; /* حجم الخط الأساسي للصفحة */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out, opacity 0.2s ease-in-out;
}
a:hover {
    color: #357ABD; /* لون أغمق من --primary-color */
    opacity: 0.85;
}
img { max-width: 100%; height: auto; display: block; }

/* === الحاوية الرئيسية === */
.container { width: 92%; max-width: 1280px; margin-left: auto; margin-right: auto; padding-left: 15px; padding-right: 15px; } /* تقليل padding قليلاً */

/* === الترويسة (Header) === */
.site-header {
    background-color: var(--surface-color);
    box-shadow: var(--box-shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.header-top-bar { /* حاوية العنوان الرئيسي */
    padding: 0.7rem 0; /* حشو علوي وسفلي للعنوان */
    border-bottom: 1px solid var(--border-color); /* خط فاصل */
}
.header-top-bar .container { /* للتأكد أن الحاوية داخل هذا الشريط لا تضيف padding إضافي غير مرغوب فيه إذا كان .container له padding عام */
    padding-left: 15px;
    padding-right: 15px;
}

.site-branding {
    text-align: right; /* أو center إذا أردت التوسيط */
}
.site-branding h1 {
    font-size: 1.4rem; /* ****** تصغير حجم خط العنوان الرئيسي ****** */
    margin: 0;
    font-weight: 600; /* يمكن جعله 500 لخط أخف */
}
.site-branding h1 a {
    color: var(--text-color); /* لون النص الافتراضي للعنوان */
    text-decoration: none;
}
.site-branding h1 a:hover {
    color: var(--primary-color);
}

/* شريط القائمة الرئيسي */
.main-navigation {
    background-color: var(--surface-color); /* يمكن تغييرها إذا أردت خلفية مختلفة للقائمة */
    padding: 0.25rem 0; /* حشو عمودي صغير لشريط القائمة */
    /* box-shadow: 0 1px 3px rgba(0,0,0,0.02); ظل أخف إذا لزم الأمر */
}
.main-navigation .container { /* للتأكد أن الحاوية داخل هذا الشريط لا تضيف padding إضافي غير مرغوب فيه */
    padding-left: 15px;
    padding-right: 15px;
}

.main-navigation ul {
    list-style: none;
    display: flex;
    justify-content: flex-start; /* يبدأ من اليمين في RTL */
    align-items: center;
    gap: 6px; /* ****** تقليل المسافة بين عناصر القائمة ****** */
    margin: 0; 
    padding: 0; 
    flex-wrap: wrap; /* السماح بالتفاف العناصر إذا لم تكن هناك مساحة كافية */
}

.main-navigation ul li a,
.main-navigation .dropdown .dropbtn {
    padding: 0.5rem 0.8rem; /* ****** تعديل الحشو ليناسب الخط الأصغر ****** */
    display: block; 
    color: var(--text-color);
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    text-transform: capitalize;
    font-size: 0.85rem; /* ****** تصغير حجم خط عناصر القائمة ****** */
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap; 
}
.main-navigation .dropdown .dropbtn { 
    background-color: transparent; border: none; cursor: pointer; line-height: inherit; 
    display: inline-flex; /* لضمان محاذاة الأيقونة والنص */
    align-items: center;
}
.main-navigation ul li a:hover,
.main-navigation ul li.current-menu-item a,
.main-navigation .dropdown:hover .dropbtn { 
    background-color: var(--primary-color);
    color: var(--surface-color);
    text-decoration: none;
}
.main-navigation .nav-caret { margin-right: 4px; font-size: 0.65em; opacity: 0.6; vertical-align: middle; }

/* Dropdown Navigation */
.main-navigation .dropdown { position: relative; }
.main-navigation .dropdown-content {
    display: none; position: absolute; background-color: var(--surface-color);
    min-width: 200px; box-shadow: var(--box-shadow-md); z-index: 1000;
    border-radius: var(--border-radius-md); top: calc(100% + 3px); /* مسافة طفيفة من الزر */
    border: 1px solid var(--border-color); padding: 6px 0; /* تقليل الحشو */
}
.main-navigation .user-dropdown .dropdown-content { left: 0; right: auto; min-width: 220px; }
.main-navigation .user-dropdown .dropbtn .fa-user-circle { margin-left: 7px; font-size: 1em; } /* تعديل حجم أيقونة المستخدم */

.main-navigation .dropdown:hover .dropdown-content { display: block; animation: fadeInDropdown 0.15s ease-out; }
@keyframes fadeInDropdown { from { opacity: 0.6; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
.main-navigation .dropdown-content a {
    color: var(--text-color); padding: 8px 15px; /* تقليل الحشو */ display: block; width: 100%;
    text-align: right; font-weight: normal; font-size: 0.82rem; /* تصغير خط القائمة المنسدلة */
    white-space: nowrap;
    display: flex; /* لمحاذاة الأيقونة مع النص */
    align-items: center;
}
.main-navigation .dropdown-content a:hover { background-color: var(--primary-color); color: var(--surface-color); }
.dropdown-content i.fa-fw { width: 1.5em; text-align: center; opacity: 0.7; } /* زيادة عرض الأيقونة قليلاً */
.dropdown-content a .me-2 { margin-left: 0.4rem !important; margin-right: 0 !important; }


/* === المحتوى الرئيسي === */
.site-main { padding-top: 25px; padding-bottom: 25px; } /* تقليل الحشو */
.content-area { background-color: var(--surface-color); padding: 20px; border-radius: var(--border-radius-md); box-shadow: var(--box-shadow-md); }
.content-area-full { margin-top: 15px; }

/* === التذييل (Footer) === */
.site-footer { background-color: #343a40; color: #adb5bd; padding: 1.5rem 0; text-align: center; margin-top: 25px; font-size: 0.85rem; }
.site-footer p { margin-bottom: 0; }

/* === الجداول === */
table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 20px; margin-bottom: 20px; background-color: var(--surface-color); border-radius: var(--border-radius-md); overflow: hidden; box-shadow: var(--box-shadow-sm); font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border-color); } /* تقليل الحشو */
td:not(:last-child), th:not(:last-child) { border-left: 1px solid var(--border-color); }
thead th { background-color: #f1f3f5; color: var(--text-color); font-weight: 600; text-transform: capitalize; border-top: 1px solid var(--border-color); }
tbody tr:hover { background-color: #e9f2fc; }
td .actions a { margin-left: 6px; font-size: 0.85em; opacity: 0.7; }
td .actions a:hover { opacity: 1; }
td .actions a.edit { color: var(--accent-color); } td .actions a.delete { color: #e74c3c; } td .actions a.view { color: var(--secondary-color); }
.table-sm th, .table-sm td { padding: 0.4rem 0.5rem; font-size: 0.875rem; } 

/* === النماذج (Forms) === */
.form-group { margin-bottom: 1rem; } /* تقليل الهامش */
label, .form-label { display: block; margin-bottom: 0.4rem; font-weight: 500; color: #343a40; font-size: 0.9rem; }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
    width: 100%; padding: 0.65rem 0.9rem; border: 1px solid var(--border-color); border-radius: var(--border-radius-sm);
    font-size: 0.9rem; line-height: 1.5; background-color: var(--surface-color); color: var(--text-color);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
input::placeholder, textarea::placeholder { color: var(--light-text-color); opacity: 0.8; }
input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="search"]:focus, select:focus, textarea:focus {
    border-color: var(--primary-color); outline: 0; box-shadow: 0 0 0 0.15rem rgba(var(--primary-color-rgb), 0.25);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%234A4A4A' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 0.6rem center; background-size: 14px 10px; padding-left: 2.2rem; }
select::-ms-expand { display: none; }
textarea { resize: vertical; min-height: 100px; }
.form-control-sm, .form-select-sm { font-size: 0.875rem; padding: .3rem .6rem; height: auto; }
.form-label-sm { font-size: 0.8rem; margin-bottom: 0.2rem; }
.invalid-feedback { display: block; width: 100%; margin-top: .25rem; font-size: .8em; color: #dc3545; } /* تصغير خط رسالة الخطأ */
.text-danger { color: #dc3545 !important; }

/* === الأزرار === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; font-weight: 500; color: var(--surface-color);
    text-align: center; vertical-align: middle; cursor: pointer; user-select: none; background-color: var(--primary-color);
    border: 1px solid var(--primary-color); padding: 0.6rem 1.1rem; font-size: 0.9rem; line-height: 1.4; /* تعديل line-height */
    border-radius: var(--border-radius-sm); transition: all 0.2s ease-in-out; box-shadow: var(--box-shadow-sm);
}
.btn:hover { background-color: #357ABD; border-color: #2A679E; text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.08); }
.btn:focus { outline: 0; box-shadow: 0 0 0 0.2rem rgba(var(--primary-color-rgb), 0.35); }
.btn:active { transform: translateY(0px); box-shadow: var(--box-shadow-sm); }
.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); } .btn-primary:hover { background-color: #357ABD; border-color: #2A679E; }
.btn-secondary { background-color: var(--bs-secondary); border-color: var(--bs-secondary); } .btn-secondary:hover { background-color: #5a6268; border-color: #545b62; }
.btn-success { background-color: var(--secondary-color); border-color: var(--secondary-color); color: #fff; } .btn-success:hover { background-color: #38C1A5; border-color: #38C1A5;}
.btn-danger { background-color: #e74c3c; border-color: #e74c3c; } .btn-danger:hover { background-color: #c0392b; border-color: #c0392b; }
.btn-warning { background-color: var(--accent-color); border-color: var(--accent-color); color: #fff; } .btn-warning:hover { background-color: #D48E1A; border-color: #D48E1A;}
.btn-info { background-color: var(--bs-info); border-color: var(--bs-info); color: #000;} .btn-info:hover { background-color: #0a95a9; border-color: #0a95a9; color: #000;}
.btn-light { background-color: #f0f4f8; border-color: #d8e1ea; color: var(--text-color); } .btn-light:hover { background-color: #e2e9f0; border-color: #c8d3df; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; border-radius: .2rem; } /* تصغير الأزرار الصغيرة أكثر */
.btn i.me-1 { margin-left: 0.3rem !important; margin-right: 0 !important; font-size: 0.9em; } /* تصغير الأيقونة داخل الزر */


/* === ترويسة الصفحة الداخلية === */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border-color); }
.page-header h2 { margin: 0; font-size: 1.6rem; color: var(--text-color); font-weight: 600; } /* تصغير عنوان الصفحة */
.page-header .btn i { margin-right: 0; margin-left: 0.3rem; }

/* === رسائل التنبيه === */
.alert { position: relative; padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; border-radius: var(--border-radius-md); font-size: 0.9rem; display: flex; align-items: center; } /* تصغير خط التنبيهات */
.alert i { margin-left: 8px; font-size: 1.1em; }
.alert-success { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; } .alert-danger { color: #842029; background-color: #f8d7da; border-color: #f5c2c7; } .alert-warning { color: #664d03; background-color: #fff3cd; border-color: #ffeeba; } .alert-info { color: #055160; background-color: #cff4fc; border-color: #bee5eb; }

/* Input Group for Search */
.input-group { display: flex; position: relative; border-radius: var(--border-radius-sm); box-shadow: var(--box-shadow-sm); overflow: hidden; }
.input-group input[type="search"] { border-radius: 0; border: none; border-left: 1px solid var(--border-color); flex-grow: 1; }
.input-group input[type="search"]:focus { box-shadow: none; z-index: 2; }
.input-group .btn { border-radius: 0; box-shadow: none; }

/* === Bootstrap Utility Classes (إذا لم تكن مستخدمة بالكامل) === */
.row { display: flex; flex-wrap: wrap; margin-top: calc(-1 * var(--bs-gutter-y, 1rem)); margin-right: calc(-.5 * var(--bs-gutter-x, 1rem)); margin-left: calc(-.5 * var(--bs-gutter-x, 1rem)); }
.row > * { flex-shrink: 0; width: 100%; max-width: 100%; padding-right: calc(var(--bs-gutter-x, 1rem) * .5); padding-left: calc(var(--bs-gutter-x, 1rem) * .5); margin-top: var(--bs-gutter-y, 1rem); }
.col { flex: 1 0 0%; } .g-3 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
.row-cols-1 > * { flex: 0 0 auto; width: 100%; } .row-cols-sm-2 > * { flex: 0 0 auto; width: 50%; } .row-cols-md-2 > * { flex: 0 0 auto; width: 50%; } .row-cols-lg-4 > * { flex: 0 0 auto; width: 25%; }
.text-end { text-align: end !important; } .fw-bold { font-weight: bold !important; }
.mt-1 { margin-top: .25rem !important; } .mt-3 { margin-top: 1rem !important; } .mt-4 { margin-top: 1.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; } .mb-4 { margin-bottom: 1.5rem !important; }
.p-3 { padding: 1rem !important; } .w-100 { width: 100% !important; }
.text-muted { color: #6c757d !important; } .small { font-size: .875em; }
.fs-3 { font-size: 1.75rem !important; } .fs-5 { font-size: 1.25rem !important; }.fs-6 { font-size: 1rem !important; }
.d-flex { display: flex !important; } .justify-content-between { justify-content: space-between !important; } .align-items-center { align-items: center !important; }


/* === استعلامات الوسائط للتجاوب (Media Queries) === */
@media (max-width: 992px) { /* شاشات أصغر من lg */
    .site-header { position: static; }
    .header-top-bar { padding-top: 0.6rem; padding-bottom: 0.4rem; text-align: right;}
    .site-branding h1 { font-size: 1.3rem; }
    .main-navigation { padding: 0.25rem 0; border-top: 1px solid var(--border-color); }
    .main-navigation ul { flex-direction: column; width: 100%; gap: 2px; }
    .main-navigation ul li { width: 100%; }
    .main-navigation ul li a, .main-navigation .dropdown .dropbtn { text-align: right; padding: 0.5rem 0.7rem; font-size: 0.82rem; }
    .main-navigation .dropdown-content { position: static; box-shadow: none; border: none; border-top: 1px solid var(--border-color); border-radius: 0; padding: 0; background-color: #f8f9fa; }
    .main-navigation .dropdown-content a { padding: 7px 10px; font-size: 0.78rem; }
    .main-navigation .user-dropdown { margin-right: 0 !important; margin-left: 0 !important; width: 100%; }
}

@media (max-width: 768px) { /* شاشات أصغر من md */
    body { font-size: 13.5px; } /* تصغير إضافي للخط الأساسي */
    .container { width: 96%; padding-left: 8px; padding-right: 8px; }
    .content-area { padding: 12px; }
    .page-header { margin-bottom: 0.8rem; padding-bottom: 0.6rem;}
    .page-header h2 { font-size: 1.35rem; margin-bottom: 8px; }
    .page-header .btn { width: 100%; margin-top: 8px; font-size: 0.85rem; padding: 0.4rem 0.8rem;}
    .table-responsive { border: 1px solid var(--border-color); border-radius: var(--border-radius-md); }
    th, td { font-size: 0.8rem; padding: 6px 8px; }
    .filter-form-compact .filter-grid, .filter-form-very-compact .filter-grid-lcr { grid-template-columns: 1fr; }
    .filter-form-very-compact .filter-actions-lcr { flex-direction: row; gap: 0.5rem; }
    .filter-form-very-compact .filter-actions-lcr .btn { flex-grow: 1; margin-top: 0 !important;}
    .summary-cards-compact .card-text.display-6 { font-size: 1.1rem !important; }
    .summary-cards-compact .card-title { font-size: 0.6rem; }
}

/* أنماط إضافية لصفحة تسجيل الدخول */
body.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: var(--bg-color); }
.login-container { background-color: #fff; padding: 2rem 1.8rem; border-radius: var(--border-radius-md, 8px); box-shadow: var(--box-shadow-lg, 0 1rem 3rem rgba(0,0,0,.175)); width: 100%; max-width: 400px; }
.login-container h2 { text-align: center; margin-bottom: 1.2rem; color: var(--primary-color, #0d6efd); font-weight: 600; font-size: 1.5rem;}
.login-container .form-control-lg { padding: .6rem 1rem; font-size: 0.95rem; }
.login-container .btn-login { font-size: 1rem; padding: 0.65rem 1.2rem; }
.login-container .alert-login { font-size: 0.85rem; padding: 0.6rem 0.9rem; }