:root {
    --primary: #0056b3;
    --primary-dark: #004494;
    --secondary: #c5a059;
    --bg-body: #f4f6f9;
    --white: #ffffff;
    --text-dark: #333;
    --success: #28a745;
    --success-light: #d4edda;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --gray: #6c757d;
    --border-radius: 8px;
    --font-main: 'Cairo', sans-serif;
    
    /* ألوان القائمة الجانبية الحديثة */
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active-border: #f0d90c;
    --sidebar-icon: #f5d105;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-main); background-color: var(--bg-body); color: var(--text-dark); height: 100vh; overflow: hidden; }

/* Login Screen */
.login-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.login-box {
    background: var(--white); padding: 40px; border-radius: 15px;
    width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); text-align: center;
}
.login-header img { width: 80px; margin-bottom: 15px; }
.login-header h2 { margin-bottom: 5px; color: var(--primary); }
.login-header p { color: var(--gray); font-size: 0.9rem; margin-bottom: 25px; }

.form-group { margin-bottom: 15px; text-align: right; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
.form-group input, .form-group select {
    width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 5px;
    font-family: inherit; font-size: 1rem; transition: border-color 0.3s;
}
.form-group input:focus { border-color: var(--primary); outline: none; }
.error-msg { color: var(--danger); font-size: 0.9rem; margin-top: 10px; min-height: 20px; }
.security-note { font-size: 0.8rem; color: #888; margin-top: 15px; display: flex; align-items: center; justify-content: center; gap: 5px; }

.form-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 0.9rem; }
.remember-me { display: flex; align-items: center; gap: 5px; cursor: pointer; color: var(--text-dark); }
.forgot-password-link { color: var(--primary); text-decoration: none; font-weight: 600; transition: 0.3s; cursor: pointer; }
.forgot-password-link:hover { color: var(--secondary); text-decoration: underline; }

/* Dashboard Layout */
.dashboard-layout { display: flex; height: 100vh; }

/* Sidebar (تم تحديث التصميم بناءً على التعديلات المضمنة سابقاً) */
.sidebar {
    width: 260px; background: var(--sidebar-bg); border-left: 1px solid #1a252f;
    display: flex; flex-direction: column; padding: 20px 0; color: var(--sidebar-text);
}
.sidebar-header {
    display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 30px;
    font-weight: 700; font-size: 1.3rem; padding: 0 20px;
}
.sidebar-header img { width: 40px; }
.sidebar-menu { list-style: none; flex-grow: 1; padding: 0; }
.sidebar-menu li { margin-bottom: 5px; }
.sidebar-menu a {
    display: flex; align-items: center; gap: 15px; padding: 12px 25px;
    color: var(--sidebar-text); text-decoration: none; transition: 0.3s; border-right: 4px solid transparent;
}
.sidebar-menu a i { color: var(--sidebar-icon); width: 20px; text-align: center; opacity: 0.9; }
.sidebar-menu li.active a, .sidebar-menu a:hover {
    background-color: var(--sidebar-hover); border-right-color: var(--sidebar-active-border);
}

/* User Info Sidebar Box (تم سحب الستايلات من الـ HTML) */
.user-info-mini {
    background-color: rgba(0, 0, 0, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px; margin: 10px 15px; border-radius: 8px; display: flex; align-items: center; gap: 12px;
}
.avatar-box {
    width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.user-details { flex-grow: 1; overflow: hidden; }
.user-details span { display: block; font-weight: bold; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details small { color: #cccccc; font-size: 0.8rem; }
.user-actions { display: flex; gap: 5px; }
.btn-icon { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 5px; transition: 0.2s; }
.btn-icon:hover { transform: scale(1.1); }
.text-danger { color: #ff6b6b !important; }

/* Main Content */
.main-content { flex-grow: 1; padding: 30px; overflow-y: auto; background-color: var(--bg-body); }
.content-section { display: none; }
.content-section.active { display: block; animation: fadeIn 0.3s; }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.top-bar h1 { font-size: 1.8rem; color: var(--primary-dark); }
.actions { display: flex; gap: 10px; }

/* Buttons */
.btn-primary {
    background-color: var(--primary); color: white; border: none; padding: 10px 20px;
    border-radius: 5px; cursor: pointer; font-weight: 600; font-family: inherit; transition: 0.3s;
}
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-outline {
    background-color: white; color: var(--primary); border: 1px solid var(--primary);
    padding: 10px 20px; border-radius: 5px; cursor: pointer; font-weight: 600; display: inline-block; transition: 0.3s;
}
.btn-outline:hover { background: #f8f9fa; }
.full-width { width: 100%; }

.btn-danger-outline {
    background-color: white; color: var(--danger); border: 1px solid var(--danger);
    padding: 10px 20px; border-radius: 5px; cursor: pointer; font-weight: 600;
    transition: 0.3s; display: none; align-items: center; gap: 8px;
}
.btn-danger-outline:hover { background-color: var(--danger); color: white; }

/* Stats Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.stat-card {
    background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex; align-items: center; gap: 20px; transition: transform 0.3s;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-card .icon {
    width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.icon.blue { background: #e3f2fd; color: var(--primary); }
.icon.orange { background: #fff3cd; color: #d39e00; }
.icon.purple { background: #e2d9f3; color: #6f42c1; }
.icon.green { background: var(--success-light); color: var(--success); }
.stat-card .info h3 { font-size: 0.9rem; color: var(--gray); margin-bottom: 5px; }
.stat-card .info span { font-size: 1.8rem; font-weight: 800; color: var(--text-dark); }

/* Tables */
.table-container { background: white; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { background: #f8f9fa; padding: 15px; text-align: right; color: var(--gray); font-size: 0.9rem; border-bottom: 2px solid #ddd; }
.data-table td { padding: 15px; border-bottom: 1px solid #eee; vertical-align: middle; }
.data-table tr:hover { background-color: #f9fbfd; }
.status-badge { padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.status-badge.active { background: var(--success-light); color: var(--success); }
.status-badge.expired { background: var(--danger-light); color: var(--danger); }
.status { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 20px; font-size: 0.85rem; font-weight: 700; }
.status.active { background-color: #e6f4ea; color: #1e7e34; border: 1px solid #c3e6cb; }
.status.expired { background-color: #fde8e8; color: #c53030; border: 1px solid #f5c6cb; }

.checkbox-col { width: 40px; text-align: center !important; }
.custom-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.action-btn { border: none; background: none; cursor: pointer; margin-left: 10px; font-size: 1.1rem; transition: 0.2s; }
.edit-btn { color: var(--primary); }
.delete-btn { color: var(--danger); }
.action-btn:hover { transform: scale(1.2); }

/* Modals */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 10000;
}
.modal-content {
    background: white; width: 500px; padding: 30px; border-radius: 12px; position: relative;
    animation: slideUp 0.3s; max-height: 90vh; overflow-y: auto;
}
.modal-sm { width: 400px; }
.modal-md { width: 500px; }
.large-modal { width: 800px; }
.close-modal { position: absolute; left: 20px; top: 20px; font-size: 1.5rem; cursor: pointer; color: #888; transition: 0.2s; }
.close-modal:hover { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.modal-desc { margin-bottom: 20px; color: #666; font-size: 0.95rem; }
.modal-divider { margin: 15px 0; border: 0; border-top: 1px solid #eee; }
.small-text { font-size: 0.8rem; }

/* Custom Elements Inside Modals */
.file-input-custom { padding: 10px; border: 1px dashed #ccc; width: 100%; border-radius: 5px; }
.textarea-custom { width: 100%; padding: 10px; border-radius: 5px; border: 1px solid #ddd; font-family: inherit; }
.category-form { display: flex; gap: 10px; margin-bottom: 20px; }
.category-form input { flex: 1; padding: 10px; border-radius: 5px; border: 1px solid #ccc; font-family: inherit; }
.categories-table-wrapper { max-height: 250px; overflow-y: auto; border: 1px solid #eee; border-radius: 5px; }
.permissions-box { background: #f9f9f9; padding: 15px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #ddd; }
.permissions-title { font-weight: bold; display: block; margin-bottom: 10px; color: var(--text-dark); }
.checkbox-group { margin-bottom: 8px; font-size: 0.9rem; }

/* Profile Image Upload (نظيفة ومدمجة) */
.profile-upload-container { position: relative; width: 120px; height: 120px; margin: 0 auto 20px auto; }
.profile-img-preview {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    border: 3px solid #ddd; box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.camera-btn {
    position: absolute; bottom: 5px; right: 5px; background: #007bff; color: white;
    width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: 2px solid white; transition: 0.3s; z-index: 10;
}
.camera-btn:hover { background: #0056b3; transform: scale(1.1); }

/* Global Utilities */
input[type="date"] {
    direction: ltr; text-align: right; font-family: inherit;
}
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; margin-right: 10px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 768px) {
    .dashboard-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-bottom: 1px solid #ddd; border-left: none; }
    .sidebar-menu { display: flex; overflow-x: auto; white-space: nowrap; padding: 10px; }
    .sidebar-menu a { padding: 10px; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar h1 { font-size: 1.4rem; }
    .actions { flex-direction: column; width: 100%; }
    .actions button, .actions label { width: 100%; text-align: center; }
}