/* --- أساسيات الصفحة --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    direction: rtl;
}

.login-container {
    width: 360px;
    margin: 100px auto;
    padding: 30px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: right;
}

h2 {
    text-align: center;
    color: #1c1e21;
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #606770;
    font-weight: bold;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    box-sizing: border-box;
}

button {
    width: 100%;
    padding: 12px;
    background-color: #1877f2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #166fe5;
}

.error-message {
    color: #d8000c;
    background-color: #ffbaba;
    border: 1px solid #d8000c;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 20px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 20px;
}

.alert-error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 20px;
}

/* --- ترويسة الصفحة المحسنة --- */
.main-header {
    background: linear-gradient(135deg, #004a7c 0%, #0066a0 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    min-height: 70px;
}

/* قسم الشعار والعنوان */
.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    color: #004a7c;
    font-size: 1.5em;
}

.title-section {
    color: white;
}

.main-title {
    margin: 0;
    font-size: 1.4em;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.subtitle {
    margin: 0;
    font-size: 0.8em;
    opacity: 0.9;
    font-weight: 300;
}

/* القائمة الرئيسية */
.main-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    gap: 0;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

.main-nav a:hover {
    background-color: rgba(255,255,255,0.1);
    transform: translateY(-1px);
}

.main-nav a i {
    font-size: 1.1em;
}

/* قسم المستخدم */
.user-section {
    display: flex;
    align-items: center;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.user-dropdown-toggle:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.user-dropdown-toggle i {
    font-size: 1.2em;
}

.user-dropdown-menu {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    min-width: 200px;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    list-style: none;
    padding: 8px 0;
    margin: 0;
    margin-top: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.user-dropdown.active .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.user-dropdown-menu a:hover {
    background-color: #f8f9fa;
    color: #004a7c;
}

.user-dropdown-menu a i {
    color: #666;
    width: 16px;
}

/* زر القائمة المحمولة */
.mobile-menu-toggle {
    display: none;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(255,255,255,0.2);
}

/* --- القائمة المنسدلة للإدارة --- */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex !important;
    align-items: center;
    gap: 5px;
}

.dropdown-menu {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 220px;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    list-style: none;
    padding: 8px 0;
    margin: 0;
    margin-top: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.dropdown-menu a:hover {
    background-color: #f8f9fa;
    color: #004a7c;
}

.dropdown-menu a i {
    color: #666;
    width: 16px;
}

/* --- المحتوى الرئيسي --- */
.main-content {
    padding: 20px;
    background-color: #f4f7f6;
    min-height: calc(100vh - 100px);
}

/* --- الاستجابة المحمولة --- */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 15px;
    }

    .main-title {
        font-size: 1.2em;
    }

    .subtitle {
        font-size: 0.7em;
    }

    .main-nav ul {
        gap: 5px;
    }

    .main-nav a {
        padding: 12px 15px;
        font-size: 0.9em;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-wrap: wrap;
        gap: 10px;
    }

    .logo-section {
        order: 1;
        flex: 1;
    }

    .main-nav {
        order: 3;
        width: 100%;
        display: none; /* مخفي افتراضيًا */
    }

    .main-nav.active {
        display: block;
    }

    .main-nav ul {
        flex-direction: column;
        background: rgba(255,255,255,0.95);
        border-radius: 8px;
        padding: 10px;
        margin-top: 10px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }

    .main-nav a {
        color: #004a7c;
        padding: 12px 15px;
        border-radius: 6px;
    }

    .main-nav a:hover {
        background-color: #f8f9fa;
        transform: none;
    }

    .user-section {
        order: 2;
    }

    .mobile-menu-toggle {
        display: block;
        order: 4;
    }

    .dropdown-menu {
        position: static;
        opacity: 0;
        visibility: hidden;
        background: #f8f9fa;
        box-shadow: none;
        border: none;
        margin-top: 5px;
    }

    .dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
    }

    .user-dropdown-menu {
        right: auto;
        left: 0;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .main-title {
        font-size: 1em;
    }

    .logo {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    .user-dropdown-toggle {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .user-dropdown-toggle span {
        display: none; /* إخفاء الاسم في الشاشات الصغيرة جدًا */
    }
}

.page-title h1 {
    color: #333;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

/* --- تذييل --- */
.main-footer {
    background-color: #333;
    color: #aaa;
    text-align: center;
    padding: 10px;
    font-size: 0.9em;
}

/* --- Widgets --- */
.dashboard-widgets {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.widget {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 20px;
    flex-grow: 1;
    min-width: 200px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.widget h3 {
    margin-top: 0;
    color: #555;
}

.widget-data {
    font-size: 2.5em;
    font-weight: bold;
    color: #004a7c;
}

/* === تنسيقات صفحات الإدارة === */

.page-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.add-form-container, .data-table-container {
    margin-bottom: 30px;
}

.add-form-container h2, .data-table-container h2 {
    color: #004a7c;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.separator {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 40px 0;
}

/* --- تنسيق النماذج --- */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.btn-primary:hover {
    background-color: #0056b3;
}


/* --- تنسيق الجداول --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    direction: ltr;
}

.data-table th, .data-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

.data-table thead {
    background-color: #f2f2f2;
    color: #333;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tbody tr:hover {
    background-color: #f1f1f1;
}

.data-table .actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.data-table .actions a {
    margin: 0 5px;
    padding: 5px 10px;
    border-radius: 4px;
    text-decoration: none;
    color: white;
}

.btn-edit {
    background-color: #ffc107; /* أصفر */
}

.btn-delete {
    background-color: #dc3545; /* أحمر */
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 4px;
    background-color: #ffc107;
    border: none;
    border-radius: 4px;
    color: #333;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-icon i {
    font-size: 14px;
}

.btn-icon:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-icon:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.5);
}

.btn-icon-danger {
    background-color: #dc3545;
    color: #fff;
}

.btn-icon-danger:hover {
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.4);
}

/* --- تنسيقات النافذة المنبثقة --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal .modal-content {
    background-color: #fff;
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    padding: 25px;
    position: relative;
}

.modal .close {
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
}

.modal .close:hover {
    color: #000;
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: left;
}

.modal .form-group label {
    color: #333;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions .btn-muted {
    background-color: #f1f3f5;
    color: #333;
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.modal-actions .btn-muted:hover {
    background-color: #e2e6ea;
}

.modal .btn-primary {
    min-width: 140px;
}

/* --- تنسيقات رسائل الحالة --- */
.success-message {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 20px;
}

/* نحن نستخدم نفس تنسيق .error-message الموجود مسبقًا */

.btn-secondary {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    margin-right: 10px;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

/* --- تنسيقات إضافية للنماذج المعقدة --- */

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1; /* يجعل الحقول تأخذ مساحة متساوية */
    margin-bottom: 0;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    background-color: #f9f9f9;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    cursor: pointer;
}
