/**
 * HRMS - Main Stylesheet
 * Brand Colors: #002165 (Primary), #FF5C22 (Accent)
 * Font: Rubik (Google Fonts)
 */

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

/* ============ CSS Variables ============ */
:root {
    --primary: #002165;
    --primary-dark: #001548;
    --primary-light: #0a3494;
    --accent: #FF5C22;
    --accent-dark: #e54a15;
    --accent-light: #ff7a4a;
    
    --success: #28a745;
    --info: #17a2b8;
    --warning: #ffc107;
    --danger: #dc3545;
    
    --gray-50: #F4F6FB;
    --gray-100: #E8ECF4;
    --gray-200: #D1D9E6;
    --gray-300: #B0BCD0;
    --gray-400: #8B98AE;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    --bg: #F4F6FB;
    --bg-card: #FFFFFF;
    --border: #E8ECF4;
    --text: #1F2937;
    --text-muted: #6B7280;
    
    --sidebar-width: 250px;
    --header-height: 64px;
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,33,101,0.06);
    --shadow-lg: 0 8px 24px rgba(0,33,101,0.10);
    
    --transition: all 0.2s ease;
}

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

/* SVG Default Size - مهم جداً */
svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: middle;
    display: inline-block;
}

/* أيقونات أصغر داخل عناصر معينة */
.sidebar-link svg { width: 18px; height: 18px; }
.header-btn svg { width: 18px; height: 18px; }
.btn svg { width: 16px; height: 16px; }
.icon-btn svg { width: 14px; height: 14px; }
.stat-icon svg { width: 20px; height: 20px; }
.alert svg { width: 18px; height: 18px; }
.empty-state svg { width: 60px; height: 60px; }


html { scroll-behavior: smooth; }

body {
    font-family: 'Rubik', sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent); }

/* ============ Layout ============ */
.app-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    width: 100%;
}

/* ============ Sidebar ============ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    margin-top: 2px;
}

.sidebar-section {
    padding: 14px 20px 6px;
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-menu { list-style: none; padding: 0; margin: 0; }

.sidebar-item { margin: 0; }

.sidebar-link {
    padding: 11px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 400;
    border-right: 3px solid transparent;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidebar-link.active {
    background: var(--accent);
    border-right-color: var(--accent-dark);
    color: #fff;
    font-weight: 600;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 14px;
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    text-align: center;
}

/* ============ Main Content ============ */
.main-content {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============ Header ============ */
.app-header {
    background: var(--bg-card);
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-50);
    padding: 8px 14px;
    border-radius: var(--radius);
    width: 320px;
    color: var(--text-muted);
    font-size: 12px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.header-search:focus-within {
    border-color: var(--primary);
    background: #fff;
}

.header-search input {
    border: 0;
    outline: 0;
    background: transparent;
    font-family: inherit;
    flex: 1;
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 0;
    transition: var(--transition);
    position: relative;
}

.header-btn:hover { background: var(--gray-100); color: var(--primary); }

.header-btn .badge-dot {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid #fff;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.header-user:hover { background: var(--gray-50); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 12px;
    flex-shrink: 0;
}

.user-info { line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 500; color: var(--primary); }
.user-role { font-size: 10px; color: var(--text-muted); }

/* ============ Page Content ============ */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: 0.4; }

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

/* ============ Stat Cards ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    transition: var(--transition);
}

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

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.primary { background: rgba(0,33,101,0.1); color: var(--primary); }
.stat-icon.accent { background: rgba(255,92,34,0.1); color: var(--accent); }
.stat-icon.success { background: rgba(40,167,69,0.1); color: var(--success); }
.stat-icon.warning { background: rgba(255,193,7,0.12); color: #d68f00; }
.stat-icon.danger { background: rgba(220,53,69,0.1); color: var(--danger); }
.stat-icon.info { background: rgba(23,162,184,0.1); color: var(--info); }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-trend {
    font-size: 11px;
    margin-top: 8px;
    font-weight: 500;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--accent); }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 0;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #218838; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c82333; color: #fff; }

.btn-secondary { background: var(--gray-100); color: var(--text); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn svg { width: 16px; height: 16px; }

/* ============ Forms ============ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-label .required { color: var(--accent); }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    transition: var(--transition);
}

.form-control:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,33,101,0.08);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-error {
    font-size: 11px;
    color: var(--danger);
    margin-top: 4px;
}

.form-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

/* ============ Tables ============ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--gray-50);
    padding: 12px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: 0; }

.table tr:hover td { background: var(--gray-50); }
.table tr.totals-row td,
.table tr.totals-row:hover td { background: var(--primary) !important; color: #fff !important; }

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-start;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    color: var(--text-muted);
    cursor: pointer;
    border: 0;
    transition: var(--transition);
}

.icon-btn:hover { background: var(--gray-100); color: var(--primary); }
.icon-btn.edit:hover { color: var(--info); }
.icon-btn.delete:hover { color: var(--danger); background: rgba(220,53,69,0.1); }
.icon-btn.view:hover { color: var(--success); }

.icon-btn svg { width: 14px; height: 14px; }

/* ============ Badges ============ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

.badge-success { background: rgba(40,167,69,0.1); color: var(--success); }
.badge-warning { background: rgba(255,193,7,0.12); color: #c08600; }
.badge-danger { background: rgba(220,53,69,0.1); color: var(--danger); }
.badge-info { background: rgba(23,162,184,0.1); color: var(--info); }
.badge-primary { background: rgba(0,33,101,0.1); color: var(--primary); }
.badge-accent { background: rgba(255,92,34,0.1); color: var(--accent); }
.badge-secondary { background: var(--gray-100); color: var(--gray-700); }

/* ============ Alerts ============ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    border-right: 3px solid;
    border-radius: 0;
    border-radius: var(--radius);
}

.alert-success { background: rgba(40,167,69,0.08); color: #1e7e34; border-color: var(--success); }
.alert-danger  { background: rgba(220,53,69,0.08); color: #a71d2a; border-color: var(--danger); }
.alert-warning { background: rgba(255,193,7,0.1); color: #806100; border-color: #ffc107; }
.alert-info    { background: rgba(23,162,184,0.08); color: #117a8b; border-color: var(--info); }

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============ Pagination ============ */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 18px;
    list-style: none;
    padding: 0;
}

.pagination a, .pagination span {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    transition: var(--transition);
    min-width: 34px;
    text-align: center;
}

.pagination a:hover { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled span { opacity: 0.5; cursor: not-allowed; }

/* ============ Modal ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.show { display: flex; }

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--primary); margin: 0; }

.modal-close {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--gray-50);
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--danger); }

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}

/* ============ Filters Bar ============ */
.filters-bar {
    background: #fff;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* ديسكتوب: الفلاتر بجانب بعض */
.filters-bar .form-control {
    padding: 7px 10px;
    width: auto;
    flex: 1;
    min-width: 150px;
    max-width: 280px;
}

.filters-bar .btn { flex-shrink: 0; }

/* موبايل: الفلاتر تحت بعض (يحافظ على السلوك الحالي) */
@media (max-width: 767px) {
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filters-bar .form-control {
        width: 100%;
        flex: none;
        min-width: unset;
        max-width: unset;
    }
    .filters-bar .btn { width: 100%; justify-content: center; }
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* ============ Helpers ============ */
.text-primary { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: #c08600 !important; }
.text-muted { color: var(--text-muted) !important; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }

.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }

.w-100 { width: 100%; }

/* ============ Responsive ============ */
@media (max-width: 992px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar { 
        position: fixed;
        right: -260px;
        transition: right 0.3s ease;
    }
    .sidebar.open { right: 0; }
    .header-search { display: none; }
}

@media (max-width: 576px) {
    .page-content { padding: 14px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .header-user .user-info { display: none; }
}

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

.fade-in { animation: fadeIn 0.3s ease; }

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

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
