/* ===== CSS Variables ===== */
:root {
    --primary: #1a56db;
    --primary-light: #e8eefb;
    --primary-dark: #1346b5;
    --secondary: #6b7280;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --dark: #1f2937;
    --light: #f9fafb;
    
    --sidebar-width: 260px;
    --topbar-height: 60px;
    
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #334155;
    --sidebar-active: #3b82f6;
    --topbar-bg: #ffffff;
    --topbar-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    direction: rtl;
}

/* Topbar (.topbar) */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    z-index: 1030;
    background: var(--topbar-bg);
    box-shadow: var(--topbar-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary);
}

.topbar-logo {
    height: 36px;
}

.topbar-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
}

.topbar-icon {
    position: relative;
    padding: 0.5rem;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}

/* Sidebar (.sidebar) */
.sidebar {
    position: fixed;
    right: 0;
    top: var(--topbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header img {
    width: 50px;
}

.sidebar-header h6 {
    color: white;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.sidebar-nav {
    padding: 1rem 0;
    list-style: none;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
    border-right: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: white;
}

.sidebar-link.active {
    background: rgba(59,130,246,0.15);
    color: var(--sidebar-active);
    border-right-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-link .badge {
    margin-left: auto;
}

/* Main Content (.main-content) */
.main-content {
    margin-right: var(--sidebar-width);
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

.content-wrapper {
    padding: 1.5rem;
}

/* Page Header (.page-header) */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h4 {
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

/* Stat Cards (.stat-card) */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: fadeIn 0.3s ease;
    animation-fill-mode: both;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: rgba(5,150,105,0.15); color: var(--success); }
.stat-icon.warning { background: rgba(217,119,6,0.15); color: var(--warning); }
.stat-icon.danger { background: rgba(220,38,38,0.15); color: var(--danger); }
.stat-icon.info { background: rgba(8,145,178,0.15); color: var(--info); }

.stat-info {
    flex: 1;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    margin: 0;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    margin-bottom: 0;
}

/* Cards (.card) */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
    animation: fadeIn 0.3s ease;
    margin-bottom: 1.5rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* Data Tables (.data-table) */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--body-bg);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
    text-align: right;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
    opacity: 0.95;
}

/* Action Buttons (.action-btn) */
.action-btn {
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.action-btn:hover { background: rgba(0,0,0,0.05); }
.action-btn-edit { color: var(--primary); }
.action-btn-delete { color: var(--danger); }
.action-btn-view { color: var(--info); }

/* Status Badges */
.badge-present { background-color: var(--success); color: white; }
.badge-absent { background-color: var(--danger); color: white; }
.badge-late { background-color: var(--warning); color: white; }
.badge-excused { background-color: var(--info); color: white; }

.badge-pending { background-color: var(--warning); color: white; }
.badge-approved { background-color: var(--success); color: white; }
.badge-rejected { background-color: var(--danger); color: white; }

.badge-completed { background-color: var(--success); color: white; }
.badge-in_progress { background-color: var(--primary); color: white; }
.badge-postponed { background-color: var(--secondary); color: white; }

.badge-active { background-color: var(--success); color: white; }
.badge-inactive { background-color: var(--secondary); color: white; }

.badge-normal { background-color: var(--secondary); color: white; }
.badge-important { background-color: var(--warning); color: white; }
.badge-urgent { background-color: var(--danger); color: white; }

/* Filter Section (.filter-section) */
.filter-section {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* Empty State (.empty-state) */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.empty-state p {
    font-size: 1rem;
    margin: 0;
}

/* Quick Actions (.quick-actions) */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.quick-action-btn i {
    font-size: 1.8rem;
    color: var(--primary);
}

.quick-action-btn span {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

/* Today Status Card (.today-status) */
.today-status {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    color: white;
}

.today-status h5 {
    font-weight: 700;
    margin: 0;
}

.today-status .status-info {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Notifications Dropdown (.notifications-dropdown) */
.notifications-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.notifications-dropdown .dropdown-header {
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin: 0;
}

.notification-item {
    display: block;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: var(--text-primary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--primary-light);
}

.notification-item.unread {
    border-right: 3px solid var(--primary);
    background: rgba(26,86,219,0.03);
}

/* Modal Customization */
.modal-content {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

/* Loading Overlay (.loading-overlay) */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-overlay .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
}

@keyframes spin { 
    to { transform: rotate(360deg); } 
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem; /* RTL places it on the left */
    z-index: 9999;
}

/* Form Styles */
.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
    outline: none;
}

/* Animations */
@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #c3d2f2;
}

/* Print styles */
@media print {
    .sidebar, .topbar, .action-btn, .quick-actions, .filter-section, .btn {
        display: none !important;
    }
    .main-content {
        margin-right: 0 !important;
        margin-top: 0 !important;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
