@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-light: #2563a8;
    --primary-dark: #0f2240;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0284c7;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-w: 260px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

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

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: rgba(245,158,11,0.08);
    border-radius: 50%;
    top: -200px; left: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    bottom: -100px; right: -100px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    width: 440px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(30,58,95,0.3);
}

.login-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.login-logo p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--primary-dark);
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,0.2);
}

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

.sidebar-header .logo-sm {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 10px;
}

.sidebar-header h2 { color: white; font-size: 1rem; font-weight: 700; }
.sidebar-header small { color: rgba(255,255,255,0.5); font-size: 0.78rem; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section { margin-bottom: 24px; }
.nav-section-title {
    color: rgba(255,255,255,0.35);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0 8px 8px;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-link.active { background: var(--primary-light); color: white; box-shadow: 0 4px 12px rgba(37,99,168,0.4); }
.nav-link .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.main-content {
    margin-right: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: white;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.topbar h1 { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.topbar .breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

.page-body { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.card-header h3 { font-size: 1rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ===== STATS CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.amber { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.purple { background: #ede9fe; }

.stat-info h3 { font-size: 1.7rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-info p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== FORMS ===== */
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.form-row.col-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.col-1 { grid-template-columns: 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.form-group small { font-size: 0.78rem; color: var(--text-muted); }

.form-control {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    color: var(--text);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    direction: rtl;
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37,99,168,0.12);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-section {
    margin-bottom: 28px;
    padding-bottom: 28px;
    border-bottom: 1px dashed var(--border);
}

.form-section:last-child { border-bottom: none; margin-bottom: 0; }

.form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0369a1; }
.btn-light { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-light:hover { background: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: right;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.92rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== EMPLOYEE PROFILE ===== */
.profile-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 32px;
    color: white;
    display: flex;
    align-items: center;
    gap: 24px;
}

.profile-avatar {
    width: 80px; height: 80px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    flex-shrink: 0;
    border: 3px solid rgba(255,255,255,0.3);
}

.profile-info h2 { font-size: 1.5rem; font-weight: 800; }
.profile-info p { opacity: 0.8; font-size: 0.9rem; margin-top: 4px; }
.profile-meta { display: flex; gap: 20px; margin-top: 12px; flex-wrap: wrap; }
.profile-meta span { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; opacity: 0.85; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.info-item { background: #f8fafc; border-radius: 10px; padding: 14px 16px; border: 1px solid var(--border); }
.info-item .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.info-item .value { font-size: 0.95rem; font-weight: 600; color: var(--text); }

.salary-box {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    border-radius: var(--radius);
    padding: 20px 24px;
}

.salary-box .total {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--success);
}

.leave-stat {
    text-align: center;
    padding: 16px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.leave-stat .num { font-size: 2rem; font-weight: 800; }
.leave-stat .lbl { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== SEARCH ===== */
.search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-input input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    direction: rtl;
}

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding-top: 16px; }
.page-btn {
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: white;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    font-family: 'Tajawal', sans-serif;
    transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 0.85rem; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.close-modal { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); }

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar, .topbar, .btn, .no-print { display: none !important; }
    .main-content { margin: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: white; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    :root { --sidebar-w: 0px; }
    .sidebar { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
    .login-card { width: 95%; padding: 32px 24px; }
}

/* ===== FILE UPLOAD ===== */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.file-drop:hover { border-color: var(--primary-light); background: #f0f7ff; }
.file-drop input[type=file] { display: none; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 0.9rem; }
