/* ==========================================================================
   SIDEBAR.CSS — Modern Responsive Left Sidebar System for EV-Program
   Clean, Modern, Anti-Slop Design Architecture (Desktop, Tablet & PWA Mobile)
   ========================================================================== */

:root {
    --sb-width: 260px;
    --sb-width-collapsed: 72px;
    --topbar-height: 56px;
    --bottom-nav-height: 62px;
    --sb-transition: cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Light Theme (Clean Modern Slate) */
    --sb-bg: #0f172a;
    --sb-bg-hover: rgba(255, 255, 255, 0.07);
    --sb-bg-active: #2563eb;
    --sb-text: #e2e8f0;
    --sb-text-muted: #94a3b8;
    --sb-border: rgba(255, 255, 255, 0.08);
    --sb-topbar-bg: #ffffff;
    --sb-topbar-border: #e2e8f0;
    --sb-surface: #ffffff;
    --sb-surface-muted: #f8fafc;
    --sb-body-bg: #f8fafc;
}

/* Soft Theme (Warm Minimal) */
body[data-theme="soft"] {
    --sb-bg: #292524;
    --sb-bg-hover: rgba(255, 255, 255, 0.07);
    --sb-bg-active: #c75b39;
    --sb-text: #f5f5f4;
    --sb-text-muted: #a8a29e;
    --sb-border: rgba(255, 255, 255, 0.08);
    --sb-topbar-bg: #ffffff;
    --sb-topbar-border: #e7e5e4;
    --sb-surface: #ffffff;
    --sb-surface-muted: #fdfaf6;
    --sb-body-bg: #fdfaf6;
}

/* Dark Theme (Midnight Pro) */
body[data-theme="dark"] {
    --sb-bg: #070a12;
    --sb-bg-hover: rgba(255, 255, 255, 0.05);
    --sb-bg-active: #3b82f6;
    --sb-text: #f1f5f9;
    --sb-text-muted: #94a3b8;
    --sb-border: rgba(255, 255, 255, 0.06);
    --sb-topbar-bg: #0f172a;
    --sb-topbar-border: #1e293b;
    --sb-surface: #0f172a;
    --sb-surface-muted: #162032;
    --sb-body-bg: #090d16;
}

/* Base Body Adjustment for Sidebar Layout */
html.with-sidebar,
body.with-sidebar {
    padding: 0 !important;
    display: block !important;
    background-color: var(--sb-body-bg) !important;
    overflow-x: clip !important;
    max-width: 100% !important;
    min-height: 100vh;
}

/* ===== APP SHELL CONTAINER ===== */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    background-color: var(--sb-body-bg);
}

/* ===== SIDEBAR KIRI (DESKTOP) ===== */
.app-sidebar {
    width: var(--sb-width);
    background: var(--sb-bg);
    color: var(--sb-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sb-border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    transition: width 0.28s var(--sb-transition), transform 0.28s var(--sb-transition);
    z-index: 1020;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.app-sidebar::-webkit-scrollbar {
    width: 4px;
}
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

/* Collapsed Sidebar on Desktop (Icon Rail Mode) */
.app-shell.sidebar-collapsed .app-sidebar {
    width: var(--sb-width-collapsed);
}
.app-shell.sidebar-collapsed .app-workspace {
    margin-left: var(--sb-width-collapsed);
    width: calc(100% - var(--sb-width-collapsed));
    max-width: calc(100% - var(--sb-width-collapsed));
}
.app-shell.sidebar-collapsed .sb-hide-collapsed {
    display: none !important;
}
.app-shell.sidebar-collapsed .sb-nav-link {
    justify-content: center;
    padding: 10px 0;
}
.app-shell.sidebar-collapsed .sb-nav-icon {
    margin: 0;
    font-size: 1.25rem;
}
.app-shell.sidebar-collapsed .sb-nav-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 0.6rem;
    padding: 2px 5px;
}
.app-shell.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 1rem 0;
}
.app-shell.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding: 0.5rem 0;
    margin: 0.85rem 0.4rem 0.45rem;
}

/* Sidebar Brand Header */
.sidebar-brand {
    padding: 1.15rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--sb-border);
    position: sticky;
    top: 0;
    background: var(--sb-bg);
    z-index: 3;
}
.sidebar-brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    background: transparent;
}
.sidebar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}
.sidebar-brand-meta {
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-brand-title {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.3px;
    color: #ffffff;
    display: block;
}
.sidebar-brand-sub {
    font-size: 0.72rem;
    color: var(--sb-text-muted);
    font-weight: 500;
    display: block;
}

/* User Profile Card */
.sidebar-user {
    padding: 0.85rem 1rem;
    margin: 0.75rem 0.75rem 0.35rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sb-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-sidebar > .sidebar-user:first-child {
    margin-top: 1rem;
}
.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.sidebar-user-details {
    overflow: hidden;
    line-height: 1.3;
}
.sidebar-user-name,
.sidebar-user .navbar-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--sb-text, #ffffff) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.sidebar-user-role {
    font-size: 0.7rem;
    font-weight: 600;
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Navigation List & Sections */
.sidebar-menu {
    flex: 1 1 auto;
    padding: 0.4rem 0.6rem;
    list-style: none;
    margin: 0;
}
.sb-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--sb-text-muted);
    padding: 0.85rem 0.65rem 0.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sb-nav-item {
    margin-bottom: 2px;
}
.sb-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 9px;
    color: var(--sb-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
    user-select: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}
.sb-nav-link:hover {
    background: var(--sb-bg-hover);
    color: #ffffff;
}
.sb-nav-link.active {
    background: var(--sb-bg-active) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.sb-nav-icon {
    font-size: 1.1rem;
    line-height: 1;
    width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sb-nav-text {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sb-nav-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}
.sb-nav-badge.tint-emerald {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
}
.sb-nav-badge.tint-amber {
    background: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
}

/* Sidebar Footer / Utilities */
.sidebar-footer {
    padding: 0.75rem 0.65rem;
    border-top: 1px solid var(--sb-border);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
a.sb-tool-btn { text-decoration: none; }

.sb-tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 0.81rem;
    font-weight: 600;
    color: var(--sb-text-muted);
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: all 0.15s ease;
}
.sb-tool-btn:hover {
    color: #ffffff;
    background: var(--sb-bg-hover);
}
.sb-tool-btn.logout {
    color: #f87171;
}
.sb-tool-btn.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* ===== APP WORKSPACE (RIGHT OF SIDEBAR) ===== */
.app-workspace {
    margin-left: var(--sb-width);
    width: calc(100% - var(--sb-width));
    max-width: calc(100% - var(--sb-width));
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--sb-body-bg);
    min-height: 100vh;
    transition: margin-left 0.28s var(--sb-transition), width 0.28s var(--sb-transition), max-width 0.28s var(--sb-transition);
}

/* Workspace Topbar */
.workspace-topbar {
    height: var(--topbar-height);
    background: var(--sb-topbar-bg);
    border-bottom: 1px solid var(--sb-topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1010;
    transition: background 0.3s ease;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-toggle-btn {
    background: rgba(15, 23, 42, 0.06);
    border: 1.5px solid rgba(15, 23, 42, 0.16);
    color: #0f172a;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    transition: all 0.18s ease;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.topbar-toggle-btn:hover {
    background: rgba(15, 23, 42, 0.12);
    border-color: rgba(15, 23, 42, 0.28);
    transform: scale(1.03);
}
.topbar-toggle-btn:active {
    transform: scale(0.95);
}
body[data-theme="dark"] .topbar-toggle-btn {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.2);
    color: #f1f5f9;
}
body[data-theme="soft"] .topbar-toggle-btn {
    background: rgba(61, 44, 30, 0.08);
    border-color: rgba(61, 44, 30, 0.22);
    color: #3d2c1e;
}
.topbar-toggle-btn svg {
    display: block;
    pointer-events: none;
}
.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}
.topbar-breadcrumb .crumb-parent {
    color: var(--sb-text-muted);
    font-weight: 500;
}
.topbar-breadcrumb .crumb-sep {
    color: var(--sb-topbar-border);
    font-size: 0.75rem;
}
.topbar-breadcrumb .crumb-active {
    font-weight: 700;
    color: inherit;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Topbar Brand Header (Pindah ke Kanan Atas) */
.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.topbar-brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.topbar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}
.topbar-brand-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.topbar-brand-title {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.2px;
    color: #0f172a;
}
.topbar-brand-sub {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.02em;
}
body[data-theme="dark"] .topbar-brand-title {
    color: #f8fafc;
}
body[data-theme="dark"] .topbar-brand-sub {
    color: #94a3b8;
}
body[data-theme="soft"] .topbar-brand-title {
    color: #292524;
}
body[data-theme="soft"] .topbar-brand-sub {
    color: #78716c;
}

/* Workspace Main Content Area */
.workspace-main {
    padding: 1.5rem;
    flex: 1 1 auto;
}

/* Clean Modern Card Styles (Anti-Slop: crisp, purposeful, accessible) */
.workspace-main .modern-card {
    background: var(--sb-surface);
    border: 1px solid var(--sb-topbar-border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: background 0.3s ease, border-color 0.3s ease;
}
.workspace-main .modern-card-header {
    padding: 1rem 1.3rem;
    border-bottom: 1px solid var(--sb-topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--sb-surface);
}
.workspace-main .modern-card-title {
    font-size: 0.98rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.workspace-main .modern-card-body {
    padding: 1.3rem;
}

/* ===== MOBILE & PWA ADAPTATIONS ===== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1024;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--sb-topbar-bg);
    border-top: 1px solid var(--sb-topbar-border);
    z-index: 1020;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.07);
}
.mobile-nav-grid {
    display: flex;
    align-items: stretch;
    height: 100%;
}
.mobile-nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--sb-text-muted);
    font-size: 0.69rem;
    font-weight: 600;
    gap: 3px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease, transform 0.12s ease;
    user-select: none;
    padding: 4px 2px;
}
.mobile-nav-btn:active {
    transform: scale(0.92);
}
.mobile-nav-btn.active {
    color: var(--sb-bg-active) !important;
}
.mobile-nav-btn i {
    font-size: 1.25rem;
    line-height: 1;
}
.mobile-nav-btn svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.15s ease, transform 0.15s ease;
    display: block;
}
.mobile-nav-btn.active svg {
    stroke: var(--sb-bg-active) !important;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1030;
        box-shadow: 0 0 35px rgba(0, 0, 0, 0.45);
    }
    .app-sidebar.show-drawer {
        transform: translateX(0);
    }
    .app-workspace {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .sidebar-backdrop.show-drawer {
        display: block;
        opacity: 1;
    }
    .mobile-bottom-nav {
        display: block;
    }
    .workspace-main {
        padding: 1rem 0.85rem;
        padding-bottom: calc(var(--bottom-nav-height) + 24px + env(safe-area-inset-bottom, 0px));
    }
    .workspace-topbar {
        padding: 0 1rem;
    }
}
