/* ══════════════════════════════════════════════════════════════
   Aegis ERP — Theme Configuration
   Refined financial dashboard aesthetic
   ══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500;600&display=swap');

:root {
    /* ── Brand ── */
    --primary: #0d5c8f;
    --primary-hover: #083d5e;
    --primary-dark: #052a42;
    --primary-rgb: 13, 92, 143;
    --primary-subtle: #e8f4fd;

    /* ── Accent (gold — for highlights, badges, KPI callouts) ── */
    --accent: #f0a500;
    --accent-subtle: #fef9e7;

    /* ── Sidebar ── */
    --sidebar-width: 256px;
    --sidebar-bg: #0b1e2d;
    --sidebar-surface: #1a3a52;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: #94a3b8;
    --sidebar-active: #2196c4;
    --sidebar-text-active: #f1f5f9;
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);

    /* ── Topbar ── */
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;
    --topbar-height: 60px;

    /* ── Content ── */
    --content-bg: #f0f4f8;
    --surface-0: #ffffff;
    --surface-1: #f8fafc;
    --border-color: #dde4ec;
    --border-subtle: #f0f4f8;

    /* ── Text ── */
    --text-primary: #0b1e2d;
    --text-secondary: #3d5a72;
    --text-muted: #607d93;
    --text-faint: #94a3b8;

    /* ── Shadows ── */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -1px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -2px rgba(0, 0, 0, .04);
    --shadow-card-hover: 0 8px 25px -5px rgba(13, 92, 143, .15), 0 4px 10px -5px rgba(0, 0, 0, .06);

    /* ── Radii ── */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* ── Transitions ── */
    --transition-fast: all 0.15s ease;
    --transition-base: all 0.2s ease;
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* ── Mono font ── */
    --font-mono: 'DM Mono', 'JetBrains Mono', monospace;
}

/* ─────────────────────────────
   BASE
───────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.9375rem;
    background-color: var(--content-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────
   SCROLLBAR
───────────────────────────── */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .15);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .25);
}

/* ─────────────────────────────
   SIDEBAR
───────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: var(--transition-slow);
    border-right: 1px solid var(--sidebar-border);
}

/* Brand */
.sidebar-brand {
    padding: 0 1.25rem;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9375rem;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.4);
    flex-shrink: 0;
}

.brand-text {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nav */
.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section-title {
    padding: 0.875rem 1.25rem 0.375rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0.625rem;
    color: var(--sidebar-text);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    gap: 0.75rem;
}

.sidebar .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar .nav-link:hover i {
    opacity: 1;
}

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

.sidebar .nav-link.active i {
    color: var(--sidebar-active);
    opacity: 1;
}

/* Collapsible submenu */
.nav-section-toggle {
    position: relative;
    padding-right: 2.5rem !important;
    justify-content: flex-start !important;
}

.nav-section-toggle .collapse-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6875rem;
    transition: transform 0.25s ease;
    opacity: 0.5;
}

.nav-section-toggle:not(.collapsed) .collapse-icon {
    transform: translateY(-50%) rotate(180deg);
}

.submenu {
    margin: 0.125rem 0;
}

.submenu .nav-link {
    padding-left: 2.75rem !important;
    font-size: 0.75rem;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

/* ─────────────────────────────
   MAIN CONTENT
───────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────
   TOPBAR
───────────────────────────── */
.topbar {
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-xs);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.25rem;
    gap: 1rem;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

.mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.125rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-toggle:hover {
    background: var(--surface-1);
    color: var(--text-primary);
}

/* Search */
.topbar-search {
    flex: 1;
    max-width: 440px;
    position: relative;
}

.topbar-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: 0.8125rem;
    pointer-events: none;
}

.topbar-search .form-control {
    padding-left: 2.25rem;
    padding-right: 1rem;
    height: 36px;
    font-size: 0.8125rem;
    background: var(--surface-1);
    border-color: var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    transition: var(--transition-base);
}

.topbar-search .form-control::placeholder {
    color: var(--text-faint);
}

.topbar-search .form-control:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

/* Icon buttons */
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.topbar-icon-btn:hover {
    background: var(--surface-1);
    color: var(--text-primary);
}

.topbar-icon-btn .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 0.2em 0.4em;
    font-size: 0.5625rem;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* User menu */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-menu-btn:hover {
    background: var(--surface-1);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.25;
    display: block;
}

.user-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.25;
    display: block;
}

/* ─────────────────────────────
   DROPDOWN
───────────────────────────── */
.dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 0.375rem;
    margin-top: 0.375rem !important;
    min-width: 200px;
}

.dropdown-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-faint);
}

.dropdown-item:hover {
    background: var(--surface-1);
    color: var(--text-primary);
}

.dropdown-item:hover i {
    color: var(--text-secondary);
}

.dropdown-item.text-danger {
    color: #dc2626;
}

.dropdown-item.text-danger i {
    color: #dc2626;
    opacity: 0.7;
}

.dropdown-item.text-danger:hover {
    background: #fef2f2;
}

.dropdown-divider {
    margin: 0.375rem 0;
    border-color: var(--border-color);
}

/* ─────────────────────────────
   PAGE CONTENT
───────────────────────────── */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ─────────────────────────────
   CARDS
───────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    transition: var(--transition-base);
    background: var(--surface-0);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-header {
    background: var(--surface-0);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--surface-1);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ─────────────────────────────
   STAT CARDS
───────────────────────────── */
.stat-card {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: var(--transition-base);
}

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.875rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: white;
}

.stat-icon.success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.stat-icon.warning {
    background: linear-gradient(135deg, #d97706, #fbbf24);
    color: white;
}

.stat-icon.info {
    background: linear-gradient(135deg, #0284c7, #38bdf8);
    color: white;
}

.stat-icon.danger {
    background: linear-gradient(135deg, #dc2626, #f87171);
    color: white;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─────────────────────────────
   FORM CONTROLS
───────────────────────────── */
.form-control,
.form-select {
    font-size: 0.8125rem;
    border-color: var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    background-color: var(--surface-0);
    transition: var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
    background-color: var(--surface-0);
}

/* ─────────────────────────────
   BUTTONS
───────────────────────────── */
.btn {
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 3px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* ─────────────────────────────
   TABLES
───────────────────────────── */
.table {
    margin-bottom: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.table thead th {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

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

.table tbody tr:hover td {
    background: var(--surface-1);
}

.table tfoot td {
    padding: 0.625rem 0.875rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--surface-1);
    border-top: 2px solid var(--border-color);
}

/* ─────────────────────────────
   BADGES / PILLS
───────────────────────────── */
.badge {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.3em 0.65em;
    border-radius: 20px;
}

/* ─────────────────────────────
   UTILITIES — TEXT
───────────────────────────── */
.text-primary {
    color: var(--primary) !important;
}

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

.font-mono {
    font-family: var(--font-mono) !important;
}

/* ─────────────────────────────
   FOOTER
───────────────────────────── */
.main-footer {
    background: var(--surface-0);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    margin-top: auto;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.footer-brand i {
    color: var(--primary);
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--primary);
}

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

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, .15);
    }

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

    .mobile-toggle {
        display: flex;
    }

    .topbar-search {
        display: none;
    }

    .user-info {
        display: none;
    }

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

@media (max-width: 575.98px) {
    :root {
        --topbar-height: 56px;
    }

    .page-content {
        padding: 0.875rem;
    }
}
