/* ===========================
   Navigation & Sidebar
=========================== */

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    transition: background-color 0.3s ease;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

/* Sidebar Title */
.sidebar h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

/* Navigation Links Groups */
.sidebar .nav-links-top,
.sidebar .nav-links-bottom {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.sidebar .nav-links-top {
    gap: 2px;
}

/* Sidebar search (PostHog-style command palette trigger) */
.sidebar-search-wrapper {
    width: 100%;
    margin-bottom: 12px;
}

.sidebar-search-inner {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 8px 10px;
    gap: 8px;
}

.sidebar-search-icon {
    color: var(--text-ui-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.sidebar-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    min-width: 0;
}

.sidebar-search-input::placeholder {
    color: var(--text-ui-muted);
}

.sidebar-search-kbd {
    font-size: 10px;
    color: var(--text-ui-muted);
    background: var(--bg-quaternary);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Section label (uppercase) and collapsible section header */
.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-ui-muted);
    padding: 0 12px;
    margin-top: 20px;
    margin-bottom: 4px;
}

.nav-section-label:first-child {
    margin-top: 0;
}

/* Clickable section header with chevron (PostHog-style) */
.nav-section-toggle {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    margin: 0;
    margin-top: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-ui-muted);
    text-align: left;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-section-toggle:first-child {
    margin-top: 0;
}

.nav-section-toggle:hover {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
}

/* DATA section: card wrapper (upload/control data) */
.nav-section-data-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    padding: 4px 6px 8px;
    margin-top: 10px;
    margin-bottom: 6px;
}

.nav-section-toggle-data {
    background: transparent;
    border: none;
    color: var(--brand-purple);
    margin-top: 0;
}
.nav-section-toggle-data:hover {
    background: rgba(180, 100, 255, 0.06);
    color: var(--brand-purple-hover);
}

.nav-section-label-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-section-chevron {
    font-size: 11px;
    transition: transform 0.2s ease;
    margin-left: 8px;
}

.nav-section-collapsible:has(.nav-section-items:not(.collapsed)) .nav-section-chevron {
    transform: rotate(90deg);
}

/* Flat nav section container */
.nav-section {
    width: 100%;
    margin-bottom: 2px;
}

.nav-section-items {
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.nav-section-items.collapsed {
    max-height: 0;
    opacity: 0.95;
    overflow: hidden;
}

/* Bottom section divider and pinning */
.sidebar-divider {
    height: 1px;
    background-color: var(--border-primary);
    margin: 12px 0;
    width: 100%;
}

.nav-section-label-bottom {
    margin-top: 8px;
}

.sidebar .nav-links-bottom {
    margin-top: auto;
    padding-top: 8px;
    gap: 2px;
}

/* Nav items (flat, no indent) - allow text to wrap so full labels are visible */
.nav-subitem {
    padding: 6px 12px !important;
    font-size: 15px;
    border-radius: 6px;
    min-width: 0;
}

/* Purple card - hidden */
.sidebar .nav-links-middle {
    display: none;
}


/* Sidebar Links - min-width: 0 allows flex child to shrink on narrow sidebars */
.sidebar a {
    text-decoration: none;
    font-size: 15px;
    font-weight: 400;
    color: var(--text-semi-dark);
    padding: 6px 12px;
    border-radius: 6px;
    width: 100%;
    min-width: 0;
    text-align: left;
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease-in-out;
}

/* Allow nav link text to wrap so full labels are visible (no truncation) */
.sidebar a > span {
    min-width: 0;
    white-space: normal;
}

.sidebar i {
    font-weight: 900;
    margin-right: 10px;
}

/* Nav icons: grey by default, show true color on hover/active */
.sidebar a .nav-icon-colored {
    filter: grayscale(1) opacity(0.5);
    transition: filter 0.2s ease;
}
.sidebar a:hover .nav-icon-colored,
.sidebar a.active .nav-icon-colored {
    filter: none;
}
/* Data section icons always show their color */
.nav-section-data-card .nav-icon-colored {
    filter: none !important;
}

/* Hover: light gray only */
.sidebar a:hover {
    background-color: var(--bg-hover);
    color: var(--text-semi-dark);
}

/* Active: purple text + subtle purple background */
.sidebar a.active {
    font-weight: 600;
    color: var(--brand-purple);
    background-color: var(--brand-purple-light);
}

/* Page Content */
.page-content {
    flex: 1;
    overflow-y: auto;
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, margin-left 0.3s ease;
    margin-left: 210px;
}

/* Mobile Navigation Tabs */
.mobile-nav-tabs {
    display: none;
}

.mobile-nav-tab {
    text-decoration: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    text-align: center;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    font-weight: 500;
}

.mobile-nav-tab:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.mobile-nav-tab.active {
    background-color: var(--brand-purple);
    color: white;
    border-color: var(--brand-purple);
}

.mobile-nav-tab.active:hover {
    background-color: var(--brand-purple-hover);
    color: white;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

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

/* Logo - swap between light and dark variants based on theme */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

/* ===========================
   Mobile Bottom Tab Bar
=========================== */

/* Fixed bottom tab bar - hidden on desktop */
.mobile-bottom-tab-bar {
    display: none;
}

/* More menu overlay - hidden by default */
.more-menu-overlay {
    display: none;
}
