/* Centralized sidebar styles to keep UI consistent across pages */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --sidebar-width: 260px;
    --sidebar-z: 1100;
}

body {
    min-height: 100vh;
    background-color: #f3f6f4;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    /* Modern clear / glass style sidebar */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-right: 1px solid rgba(15, 23, 42, 0.06);
    color: #111827;
    padding: 20px;
    overflow-y: auto;
    z-index: var(--sidebar-z);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: calc(var(--sidebar-z) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.sidebar-header i { font-size: 28px; color: #6366f1; }
.sidebar-header h4 { margin: 0; font-size: 18px; font-weight: 700; color: #111827; }
.sidebar-header div { flex: 1; }
.sidebar-header small { display: block; margin-top: 4px; color: #6b7280; }

.nav-menu { list-style: none; padding: 0; margin: 0; }
.nav-item { margin-bottom: 6px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.nav-link:hover { background-color: rgba(129, 140, 248, 0.08); color: #4c1d95; }
.nav-link.active { background-color: rgba(129, 140, 248, 0.15); color: #4338ca; font-weight: 600; }

.nav-link i { width: 20px; text-align: center; color: #6366f1; }

.sidebar-budget-info {
    background: rgba(129, 140, 248, 0.06);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 12px;
    border: 1px solid rgba(129, 140, 248, 0.2);
    color: #374151;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin 0.3s ease, padding 0.3s ease;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: calc(var(--sidebar-z) + 1);
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    color: #111827;
}

.sidebar-toggle i {
    font-size: 18px;
}

.sidebar-close {
    margin-left: auto;
    display: none;
    border: none;
    background: rgba(148, 163, 184, 0.18);
    color: #111827;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
}

.sidebar-close i { font-size: 14px; }

@media (max-width: 992px) {
    .sidebar {
        width: min(82vw, 320px);
        transform: translateX(-100%);
        box-shadow: 0 12px 30px rgba(0,0,0,0.2);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-close {
        display: inline-flex;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .content-section {
        padding: 18px !important;
    }
}

@media (max-width: 576px) {
    .content-section {
        padding: 15px !important;
    }

    .topbar {
        gap: 8px;
    }
}

/* Hide sidebar and related UI when printing */
@media print {
    .sidebar, .sidebar-header, .nav-menu { display: none !important; }
    .main-content { margin: 0 !important; padding: 6px !important; width: 100% !important; }
}
