/* ─── Variables ───────────────────────────────────────────────────────────── */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --color-bg: #f0f2f5;
    --color-sidebar: #1e293b;
    --color-sidebar-hover: #334155;
    --color-sidebar-active: #3b82f6;
    --color-sidebar-text: #94a3b8;
    --color-sidebar-text-active: #ffffff;
    --color-topbar: #ffffff;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --radius: 0.5rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 4px 12px rgba(0,0,0,.1);
    --transition: .2s ease;
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── App Layout ──────────────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.app-content {
    flex: 1;
    padding: 24px;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--color-sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
}

/* ─── Sidebar Navigation ─────────────────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

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

.nav-section {
    padding: 16px 20px 6px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(148,163,184,.6);
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}

.nav-item .nav-link:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-sidebar-text-active);
    border-left-color: rgba(59,130,246,.4);
}

.nav-item .nav-link.active {
    background: rgba(59,130,246,.12);
    color: var(--color-sidebar-text-active);
    border-left-color: var(--color-sidebar-active);
}

.nav-item .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* ─── Sidebar Footer ─────────────────────────────────────────────────────── */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar i {
    font-size: 2rem;
    color: var(--color-sidebar-text);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.user-role {
    font-size: 0.7rem;
    color: var(--color-sidebar-text);
}

/* ─── Sidebar Overlay (mobile) ────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--color-topbar);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1020;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-menu {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    display: none;
}

.btn-menu:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

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

.btn-user {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: #374151;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-user:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-user::after {
    font-size: 0.65rem;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.card-header {
    font-weight: 600;
    font-size: 0.875rem;
    background: transparent;
    border-bottom: 1px solid #f1f5f9;
    padding: 14px 20px;
}

.card-body { padding: 20px; }

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table { margin-bottom: 0; font-size: 0.85rem; }

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #64748b;
    white-space: nowrap;
    border-bottom-width: 1px;
}

.table thead { background: #f8fafc; }
.table thead.table-dark { background: var(--color-sidebar) !important; }

.table td {
    vertical-align: middle;
    color: #374151;
}

.table-hover tbody tr:hover { background: #f8fafc; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn { font-size: 0.85rem; font-weight: 500; border-radius: 6px; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-control, .form-select {
    font-size: 0.85rem;
    border-radius: 6px;
    border-color: #e5e7eb;
    padding: 8px 12px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

/* ─── Misc ────────────────────────────────────────────────────────────────── */
code { font-size: 0.8rem; }

.display-6 {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ─── Auth Layout ─────────────────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 20px;
}

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.pagination { gap: 4px; }
.page-link { font-size: 0.8rem; border-radius: 6px; }

/* ─── Alert ───────────────────────────────────────────────────────────────── */
.alert {
    font-size: 0.85rem;
    border-radius: var(--radius);
    border: none;
    margin-bottom: 16px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .btn-menu {
        display: block;
    }

    .app-content {
        padding: 16px;
    }
}

@media (max-width: 575.98px) {
    .app-content { padding: 12px; }
    .display-6 { font-size: 1.5rem; }
    .topbar { padding: 0 12px; }
}
