:root {
    --alburaq-primary: #1a4d8f;
    --alburaq-primary-dark: #133a6b;
    --alburaq-primary-light: #2a6cb0;
    --alburaq-accent: #f5a623;
    --sidebar-width: 270px;
    --sidebar-width-collapsed: 70px;
    --header-height: 60px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background-color: #f4f6f9;
    font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}

/* ============== LAYOUT ============== */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin .3s ease;
}

/* ============== SIDEBAR ============== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--alburaq-primary) 0%, var(--alburaq-primary-dark) 100%);
    color: #fff;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    transition: width .3s ease, transform .3s ease;
    z-index: 1030;
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-shrink: 0;
    min-height: var(--header-height);
}

.sidebar-logo { height: 36px; width: auto; filter: brightness(0) invert(1); flex-shrink: 0; }
.sidebar-brand { line-height: 1.1; white-space: nowrap; }

.sidebar-toggle {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
}

.sidebar-nav {
    padding: .5rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-link,
.sidebar-nav .nav-section-toggle {
    color: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: .9rem;
    transition: all .2s;
    border: 0;
    background: transparent;
    width: 100%;
    text-align: start;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-section-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-link i,
.sidebar-nav .nav-section-toggle > i:first-child {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link.sub {
    padding-inline-start: 2rem;
    font-size: .85rem;
    color: rgba(255,255,255,0.65);
}

.sidebar-nav .nav-link.sub i {
    font-size: .9rem;
    width: 18px;
}

.sidebar-nav .nav-section {
    margin: .25rem 0;
}

.sidebar-nav .nav-section-toggle .chev {
    margin-inline-start: auto;
    font-size: .75rem;
    transition: transform .2s;
    width: auto;
}

.sidebar-nav .nav-section-toggle[aria-expanded="true"] .chev {
    transform: rotate(180deg);
}

/* Collapsed sidebar (desktop) */
.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-section-toggle span,
.sidebar.collapsed .nav-section-toggle .chev,
.sidebar.collapsed .nav-section .collapse,
.sidebar.collapsed .nav-section .collapsing {
    display: none !important;
}
.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-section-toggle {
    justify-content: center;
    padding: .6rem;
}

/* ============== TOPBAR ============== */
.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 1.25rem;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-toggle {
    background: transparent;
    border: 0;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--alburaq-primary);
    padding: .25rem .5rem;
    border-radius: 6px;
}
.topbar-toggle:hover { background: #f0f4f9; }

.topbar-title {
    font-weight: 600;
    color: var(--alburaq-primary);
}

.topbar-actions {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar .user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #333;
    text-decoration: none;
    padding: .4rem .75rem;
    border-radius: 6px;
}
.topbar .user-dropdown .dropdown-toggle:hover { background: #f0f4f9; }

/* ============== MAIN CONTENT ============== */
.main-content {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
}

.footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: .75rem 1.25rem;
    color: #6b7280;
    font-size: .85rem;
}

/* ============== COMPONENTS ============== */
.btn-primary {
    background-color: var(--alburaq-primary);
    border-color: var(--alburaq-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--alburaq-primary-dark);
    border-color: var(--alburaq-primary-dark);
}

.text-primary { color: var(--alburaq-primary) !important; }
.bg-primary { background-color: var(--alburaq-primary) !important; }

.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 10px;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    padding: .85rem 1.1rem;
}

.page-title {
    color: var(--alburaq-primary);
    padding-bottom: .5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--alburaq-primary);
    font-weight: 700;
}

table.table thead th {
    background-color: var(--alburaq-primary);
    color: white;
    font-weight: 600;
    border-color: var(--alburaq-primary);
    padding: .65rem .75rem;
}

table.table tbody td { padding: .65rem .75rem; vertical-align: middle; }

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

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card .logo { max-height: 70px; margin-bottom: 1.5rem; }

/* ============== RESPONSIVE ============== */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        inset-inline-start: 0;
        transform: translateX(-100%);
        box-shadow: 4px 0 12px rgba(0,0,0,.15);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.show { transform: translateX(0); }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1025;
        display: none;
    }
    .sidebar-backdrop.show { display: block; }

    .main-content { padding: 1rem; }
}

@media print {
    .sidebar, .topbar, .footer { display: none !important; }
    .main-content { padding: 0; }
}
