/*
  css/sidebar.css
  Sidebar chrome: logo, hamburger, theme dropdown, font-size stepper, nav
  list. Colours/borders/shadows come from the active theme file, same
  convention as base.css.
*/

/* ── Shell layout ──────────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
    width: 158px;
    min-width: 158px;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 20px;
    border-bottom-left-radius: var(--border-radius-lg);
    border-bottom-right-radius: var(--border-radius-lg);
}

.sidebar-header {
    position: relative;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
}

.sidebar-header-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Logo placeholder + hover-fade name ───────────────────────────────────── */

.logo-placeholder {
    position: relative;
    width: 70px;
    height: 70px;
}

.logo-img {
    display: block;
    position: absolute;
    top: -25px;
    left: -25px;
    width: 110px;
    height: 110px;
    object-fit: contain;
    pointer-events: none;
}

.logo-placeholder #app-name {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    font-size: 0.95rem;
    font-weight: var(--font-weight-heading, 700);
    color: var(--text-color);
    text-shadow:
        -1px -1px 0 var(--bg-color),
         1px -1px 0 var(--bg-color),
        -1px  1px 0 var(--bg-color),
         1px  1px 0 var(--bg-color);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
}

.logo-placeholder:hover #app-name {
    opacity: 1;
}

/* ── Hamburger button ──────────────────────────────────────────────────────── */

.hamburger-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.hamburger-btn:hover {
    background: var(--card-hover);
}

.hamburger-btn span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-color);
}

/* ── Theme dropdown (custom) ──────────────────────────────────────────────── */

.theme-dropdown {
    position: relative;
    width: 100%;
}

.theme-dropdown-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: var(--font-ui);
    font-size: 0.85em;
    cursor: pointer;
}

.theme-dropdown-trigger:hover {
    background: var(--color-nav-hover-bg);
    color: var(--color-nav-hover-text);
}

.theme-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-dropdown, none);
    z-index: 50;
    overflow: hidden;
}

.theme-dropdown-menu.open {
    display: block;
}

.theme-dropdown-item {
    padding: 8px 12px;
    font-size: 0.85em;
    color: var(--text-color);
    cursor: pointer;
}

.theme-dropdown-item:hover {
    background: var(--color-nav-hover-bg);
    color: var(--color-nav-hover-text);
}

/* ── Font-size stepper ─────────────────────────────────────────────────────── */

.font-size-stepper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.font-size-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.4em;
    line-height: 1;
    padding: 4px 4px;
    transition: color 0.15s ease;
}

.font-size-btn:hover {
    color: var(--primary-color);
}

#font-size-value {
    min-width: 3.5em;
    text-align: center;
    font-size: 1.05em;
    color: var(--text-secondary);
}

/* ── Separator ─────────────────────────────────────────────────────────────── */

.sidebar-separator {
    height: 1px;
    background: var(--border-color);
    margin: 0 1.25rem;
}

/* ── Nav list (populated Patch B; base rules defined now) ─────────────────── */

.sidebar-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--nav-gap, 0);
}

.nav-item {
    padding: 14px 16px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    background: var(--color-bg-raised);
    color: var(--text-color);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.9em;
    text-transform: var(--nav-text-transform, none);
    letter-spacing: var(--nav-letter-spacing, normal);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background: var(--color-nav-hover-bg);
    border-color: var(--primary-color);
    color: var(--color-nav-hover-text);
    box-shadow: var(--shadow-nav-active, none);
    text-shadow: var(--text-shadow-nav-active, none);
}

/* ── Mobile top bar + drawer (#89) ─────────────────────────────────────────── */
/* --breakpoint-mobile is informational only — CSS custom properties
   aren't usable inside @media conditions, so 768px is hardcoded in every
   @media rule below AND in sidebar.js's MOBILE_BREAKPOINT_PX constant.
   If this value ever changes, all three places need to move together. */
:root {
    --breakpoint-mobile: 768px;
    --mobile-topbar-height: 56px;
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    height: var(--mobile-topbar-height);
    flex-shrink: 0;
    padding: 0 16px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
}

.mobile-topbar-title {
    font-weight: var(--font-weight-heading, 700);
    color: var(--text-color);
    font-size: 1.05rem;
}

/* Same visual as .hamburger-btn (sidebar's existing Settings/Export
   menu button) — different element, different job (toggles the sidebar
   drawer itself, not a dropdown menu), so kept as its own class rather
   than reusing .hamburger-btn and risking the two getting entangled
   later. */
.mobile-menu-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.mobile-menu-btn:hover {
    background: var(--card-hover);
}

.mobile-menu-btn span {
    display: block;
    width: 16px;
    height: 2px;
    background: var(--text-color);
}

@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .mobile-topbar {
        display: flex;
    }

    /* Sidebar and content are mutually exclusive full-panels below the
       breakpoint, toggled by #appShell's .mobile-sidebar-open class
       (sidebar.js's toggleMobileSidebar()) — default (no class) shows
       content, matching "selecting a nav item collapses back to
       content" always landing in the same state coming or going. */
    .sidebar {
        display: none;
        width: 100%;
        min-width: 0;
        flex: 1;
        min-height: 0;
        margin-bottom: 0;
        border-right: none;
        border-radius: 0;
    }

    .app-shell.mobile-sidebar-open .sidebar {
        display: flex;
    }

    .app-shell.mobile-sidebar-open .main-content {
        display: none;
    }
}
