/* ═══════════════════════════════════════════════════════════════
   Sidebar — Collapsible Dark Theme Navigation
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar Container ───────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
    transition: transform var(--transition-base);
    overflow: hidden;
}

/* ── Sidebar Header (Logo area) ──────────────────────────────── */
.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sidebar-brand-tagline {
    font-size: 10px;
    color: var(--sidebar-text);
    font-weight: 400;
    margin-top: 1px;
}

/* ── Navigation Section ──────────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 10px;
}

.sidebar-section-label {
    font-size: 9px;
    font-weight: 800;
    color: rgba(148, 163, 184, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 16px 12px 6px;
    user-select: none;
}

/* ── Menu Item ───────────────────────────────────────────────── */
.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 2px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
}

.sidebar-menu-item:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-hover);
}

.sidebar-menu-item.active {
    background: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
}

.sidebar-menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--sidebar-text-active);
    border-radius: 0 4px 4px 0;
}

.sidebar-menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-menu-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: var(--primary);
    letter-spacing: 0.02em;
}

/* ── Document Type Color Coding ──────────────────────────────── */
.sidebar-menu-item[data-doc="quotation"].active {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}
.sidebar-menu-item[data-doc="quotation"].active::before {
    background: #3b82f6;
}

.sidebar-menu-item[data-doc="billing"].active {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
}
.sidebar-menu-item[data-doc="billing"].active::before {
    background: #8b5cf6;
}

.sidebar-menu-item[data-doc="receipt"].active {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}
.sidebar-menu-item[data-doc="receipt"].active::before {
    background: #f59e0b;
}

/* ── Sidebar Footer ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-footer-text {
    font-size: 10px;
    color: rgba(148, 163, 184, 0.4);
    text-align: center;
    font-weight: 500;
}

/* ── Mobile Hamburger Button ─────────────────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: calc(var(--z-sidebar) + 10);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--sidebar-bg);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid var(--sidebar-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--sidebar-bg-hover);
}

.sidebar-toggle.is-open {
    left: calc(var(--sidebar-width) + 14px);
}

/* ── Overlay for mobile ──────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Mobile Top Header Bar ───────────────────────────────────── */
.mobile-top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(15, 23, 42, 0.85); /* Slate 900 translucent */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: var(--z-sticky);
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.mobile-top-bar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 54px; /* Leave space for hamburger */
}

.mobile-top-bar-logo {
    height: 32px;
    width: 32px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.mobile-top-bar-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    letter-spacing: -0.02em;
}

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

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
    }

    .mobile-top-bar {
        display: flex;
    }

    .app-content {
        margin-top: 60px !important; /* Push content down below top bar */
    }

    .sidebar-toggle {
        display: flex;
        position: absolute; /* Place relative to top bar */
        top: 9px;
        left: 12px;
        width: 42px;
        height: 42px;
        box-shadow: none; /* Flatten button on top bar */
    }

    .sidebar-toggle.is-open {
        position: fixed; /* Go back to fixed to align with open drawer */
        left: calc(var(--sidebar-width) + 14px);
        top: 14px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}
