/* ── Page layout ───────────────────────────────────────────────────── */
html, body { height: 100%; margin: 0; font-family: sans-serif; }

.app-layout {
    display: flex;
    height: 100%;
}

.app-sidebar {
    width: 240px;
    min-width: 0;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    padding: 0.75rem;
    box-sizing: border-box;
    transition: width 0.25s ease, padding 0.25s ease;
}

.app-layout.sidebar-collapsed .app-sidebar {
    width: 44px;
    padding: 0.4rem;
    overflow: hidden;
}

/* Collapsed sidebar: hide title and accordion chrome, show vertical labels */
.app-layout.sidebar-collapsed .app-sidebar .app-title {
    display: none;
}

.app-layout.sidebar-collapsed .app-sidebar .sidebar-header {
    border-bottom: none;
    padding-bottom: 0;
}

.app-layout.sidebar-collapsed .app-sidebar .view-accordion > summary,
.app-layout.sidebar-collapsed .app-sidebar .accordion-body {
    display: none !important;
}

/* Vertical view labels (hidden when expanded) */
.collapsed-label {
    display: none;
}

.app-layout.sidebar-collapsed .collapsed-label {
    display: flex;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    cursor: pointer;
    padding: 0.6rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    width: 100%;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    transition: color 0.15s;
}

.app-layout.sidebar-collapsed .collapsed-label:hover {
    color: #222;
}

/* Sidebar header: title + hamburger button on one line */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #dee2e6;
}

/* Hamburger button inside the sidebar */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem 0.3rem;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
    background: #e2e6ea;
    color: #222;
}

.app-main {
    flex: 1;
    overflow: auto;
    padding: 0.5rem;
    min-width: 0;
}

/* ── Loading spinner ────────────────────────────────────────────────── */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.loading-overlay.visible {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #dee2e6;
    border-top-color: #555;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── App title ─────────────────────────────────────────────────────── */
.app-title {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.5rem 0;
}

/* ── Accordion ─────────────────────────────────────────────────────── */
.app-sidebar details {
    border-bottom: 1px solid #dee2e6;
}

.app-sidebar summary {
    display: flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.55rem 0.4rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    border-radius: 4px;
    background: #eef0f2;
    margin: 4px 0;
}

.app-sidebar summary:hover {
    background: #e2e6ea;
}

/* Suppress the browser's built-in disclosure triangle */
.app-sidebar summary::-webkit-details-marker { display: none; }
.app-sidebar summary::marker { display: none; }

/* Arrow span inside <summary> — more reliable than ::before inside Bokeh Divs */
.app-sidebar summary .accordion-arrow {
    display: inline-block;
    font-size: 0.6em;
    line-height: 1;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.app-sidebar details[open] > summary .accordion-arrow {
    transform: rotate(90deg);
}

/* ── Accordion body height animation ───────────────────────────────── */
/*
 * CSS Grid trick: grid-template-rows transitions from 0fr → 1fr, giving
 * a height animation proportional to actual content (unlike max-height).
 * display:grid !important overrides the UA stylesheet's `display:none`
 * on closed <details> children, so the transition can actually run.
 * The direct child div needs overflow:hidden + min-height:0 to allow
 * the grid item to collapse below its natural height.
 */
.app-sidebar details > .accordion-body {
    display: grid !important;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.4s ease, opacity 0.3s ease;
}

.app-sidebar details[open] > .accordion-body {
    grid-template-rows: 1fr;
    opacity: 1;
}

.app-sidebar details > .accordion-body > div {
    overflow: hidden;
    min-height: 0;
}

/* ── Sidebar text styles ───────────────────────────────────────────── */
.view-desc {
    font-size: 0.82rem;
    color: #555;
    margin: 0.4rem 0 0.25rem;
    line-height: 1.4;
}

.last-updated {
    font-size: 0.75rem;
    color: #888;
    margin: 0.25rem 0 0.5rem;
}

/* ── Accordion widget slot ─────────────────────────────────────────── */
/* Hidden when its paired <details> is closed; toggled by JS */
.accordion-hidden {
    display: none !important;
}

