/* ============================================================
   App/admin shell layout — body, navbar, sidebar, main, scrollbar.
   Tokens only; no palette hex.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    margin: 0;
}

/* ===== NAVBAR ===== */
/* Non-sticky: lives in normal document flow so page content never scrolls
   underneath it. Trade-off: nav scrolls away with the page; users scroll
   up to reach it. Previously sticky with z-index 1030 — caused content
   (notably bracket round labels on /live and /admin/heats) to be hidden
   behind the navbar on scroll. */
.bb-navbar {
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
    /* #302 — non-sticky (stays in flow, scrolls away) but with its own stacking
       context at the conventional navbar level so an open .dropdown-menu (e.g.
       the language switcher) paints ABOVE page content instead of behind it.
       relative + z-index does NOT reintroduce the old sticky-overlap bug because
       the bar still scrolls away with the page. 1030 < mobile sidebar (1039/1040)
       < offcanvas (1045) < modal (1055), so those still layer correctly. */
    position: relative;
    z-index: 1030;
}
.bb-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--color-brand) !important;
}
.bb-nav-logo {
    height: 28px;
    width: auto;
    display: block;
}

/* Minimal auth shell (layouts/minimal.php) */
.bb-minimal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.bb-minimal-box {
    max-width: 420px;
}

/* ===== ADMIN LAYOUT — Flexbox =====
   The container needs to be at least one viewport tall so a sticky
   sidebar can pin to top:0 with height:100vh without being squeezed
   against the footer when content is short. The extra 56px the layout
   appears to claim past the viewport bottom is harmless — it's offset
   by the (non-sticky) navbar that consumed 56px above. */
.bb-admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR (macOS System Settings style) =====
   Sticky to top:0 with full-viewport height so the rail stays flush
   against the top once the (non-sticky) navbar scrolls away. With the
   navbar still visible at the top of the page, the sidebar's natural
   flex position sits below it (y=56px); only on scroll does sticky
   pin it to viewport top. Avoids the previous geometry that assumed
   a sticky navbar (top: 56; height: calc(100vh - 56px)) and left a
   56-px gap above the rail when the navbar scrolled out of view. */
.bb-sidebar {
    width: var(--layout-sidebar-w);
    min-width: var(--layout-sidebar-w);
    background: var(--color-surface-2);
    border-right: 1px solid var(--color-border);
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}
.bb-sidebar::-webkit-scrollbar { width: 4px; }
.bb-sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* Sidebar items — macOS pill-shaped */
.bb-sidebar .list-group-item {
    padding: 0.5rem 0.85rem;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: var(--radius-sm);
    margin: 1px 8px;
    transition: background 0.15s ease;
}
.bb-sidebar .list-group-item i {
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0.8;
}
.bb-sidebar .list-group-item:hover {
    background: var(--bb-hover) !important;
}
.bb-sidebar .list-group-item.active {
    background: var(--bb-active) !important;
    color: var(--color-accent-text) !important;
    font-weight: 600;
}
.bb-sidebar .list-group-item.active i {
    opacity: 1;
    color: var(--color-accent-hot);
}

/* Sidebar section headers (macOS-style) */
.bb-sidebar-section {
    padding: 1.1rem 1.1rem 0.3rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
}
.bb-sidebar-section:first-child { padding-top: 0.6rem; }

/* Event name in sidebar */
.bb-sidebar-event-name {
    padding: 0.6rem 1.1rem 0.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--bb-border-soft);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Back link */
.bb-sidebar-back {
    font-size: 0.8rem !important;
    padding: 0.65rem 1.1rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-bottom: 1px solid var(--bb-border-soft) !important;
    color: var(--color-muted) !important;
}
.bb-sidebar-back:hover {
    color: var(--color-text) !important;
    background: var(--bb-hover) !important;
}

/* Collapse button */
.bb-sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--color-muted);
    width: 100%;
    padding: 0.35rem 1rem;
    text-align: right;
    cursor: pointer;
    font-size: 0.85rem;
}
.bb-sidebar-collapse-btn:hover { color: var(--color-text); }

/* Event-name row stacks the title and the status badge so the badge
   stays inside the rail (instead of floating off into the content area). */
.bb-sidebar-event-name {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.bb-sidebar-event-title { display: inline-flex; align-items: center; gap: 0.35rem; }
.bb-sidebar-event-status .badge { font-size: 0.65rem; }

/* <details>-driven section grouping — gives status-driven default-collapse
   for free with no JS, no per-user persistence. <summary> wears the same
   class as the legacy <div class="bb-sidebar-section"> headers so the
   existing .collapsed { display: none } rule still hides them. */
.bb-sidebar-group { margin: 0; }
.bb-sidebar-group > summary.bb-sidebar-section {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.bb-sidebar-group > summary.bb-sidebar-section::-webkit-details-marker { display: none; }
.bb-sidebar-group > summary.bb-sidebar-section::marker { display: none; }
.bb-sidebar-group > summary.bb-sidebar-section::after {
    content: '\F282'; /* bi-chevron-down */
    font-family: 'bootstrap-icons';
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-left: 0.5rem;
    transition: transform 0.15s ease;
}
.bb-sidebar-group:not([open]) > summary.bb-sidebar-section::after { transform: rotate(-90deg); }

/* "View Recap →" primary pill — only rendered when the event is
   finished/archived. Gives the user their job-to-be-done up top. */
.bb-sidebar-primary {
    margin: 0.4rem 0.6rem !important;
    padding: 0.55rem 0.9rem !important;
    border-radius: var(--radius-sm) !important;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--color-accent) 18%, transparent),
        color-mix(in srgb, var(--color-accent) 18%, transparent)
    ) !important;
    color: var(--color-text) !important;
    font-weight: 600;
}
.bb-sidebar-primary:hover {
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--color-accent) 28%, transparent),
        color-mix(in srgb, var(--color-accent) 28%, transparent)
    ) !important;
    color: var(--scb-chalk) !important;
}
.bb-sidebar-primary.active {
    background: linear-gradient(135deg, var(--color-accent), color-mix(in srgb, var(--color-accent) 70%, var(--color-accent-hot))) !important;
    color: var(--color-on-accent) !important;
}

/* Collapsed state */
.bb-sidebar.collapsed {
    width: var(--layout-sidebar-collapsed-w);
    min-width: var(--layout-sidebar-collapsed-w);
}
.bb-sidebar.collapsed .bb-sidebar-text { display: none; }
.bb-sidebar.collapsed .bb-sidebar-section { display: none; }
.bb-sidebar.collapsed .bb-sidebar-event-name span { display: none; }
.bb-sidebar.collapsed .bb-sidebar-back span { display: none; }
.bb-sidebar.collapsed .list-group-item {
    justify-content: center;
    padding: 0.55rem 0;
    margin: 1px 4px;
}
.bb-sidebar.collapsed .list-group-item i { width: auto; font-size: 1.1rem; }
.bb-sidebar.collapsed .bb-sidebar-collapse-btn { text-align: center; padding: 0.35rem 0; }
/* When the rail is collapsed, hide the section disclosure summaries —
   the icon-only nav links underneath stay reachable because the
   collapse JS force-opens every <details> group while collapsed. */
.bb-sidebar.collapsed .bb-sidebar-group > summary { display: none; }

/* ===== MAIN CONTENT ===== */
.bb-admin-main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2rem;
    /* #1295 — no overflow-x: hidden. It cut off anything wider than the
       column with no scrollbar; wide content scrolls in its own
       .table-responsive instead (min-width: 0 keeps the column honest). */
}

/* Event header (replaces old pill nav) */
.bb-event-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

/* ===== HERO ===== */
.bb-hero-title { font-size: 2.5rem; font-weight: 700; }

/* ===== MOBILE SIDEBAR ===== */
.bb-mobile-sidebar-bar {
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem;
}
.bb-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, black 50%, transparent);
    z-index: 1039;
}
.bb-sidebar-overlay.open { display: block; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 991.98px) {
    .bb-admin-main { padding: 1.25rem; }
    .nav-pills .nav-link { font-size: 0.8rem; padding: 0.35rem 0.6rem; }
    .bb-hero-title { font-size: 2rem; }
}

/* Mobile + Tablet */
@media (max-width: 991.98px) {
    .bb-admin-layout { display: block; }
    .bb-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        z-index: 1040;
        padding-top: 0.75rem;
        box-shadow: 4px 0 24px color-mix(in srgb, black 60%, transparent);
    }
    .bb-sidebar.open { display: block !important; }
    .bb-sidebar.collapsed { width: 280px; min-width: 280px; }
    .bb-sidebar.collapsed .bb-sidebar-text { display: inline; }
    .bb-sidebar.collapsed .bb-sidebar-section { display: block; }
    .bb-sidebar.collapsed .list-group-item { justify-content: flex-start; padding: 0.5rem 0.85rem; margin: 1px 8px; }
    .bb-admin-main { padding: 1rem; }
    .bb-hero-title { font-size: 1.75rem; }
    .table-responsive { font-size: 0.85rem; }
    .bb-card .card-body { padding: 0.85rem; }
}

@media (min-width: 992px) {
    .bb-mobile-sidebar-bar { display: none; }
}

/* Small phones */
@media (max-width: 575.98px) {
    .bb-admin-main { padding: 0.75rem; }
    .nav-pills .nav-link { font-size: 0.75rem; padding: 0.3rem 0.5rem; }
}

/* ===== PARTICIPANT STATUS TIMELINE ===== */
.bb-status-timeline {
    max-width: 500px;
}
.bb-timeline-step {
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease;
}
.bb-timeline-step.current {
    transform: scale(1.1);
}
.bb-timeline-step .bi {
    transition: color 0.3s ease, text-shadow 0.3s ease;
}
.bb-timeline-connector {
    height: 2px;
    background: color-mix(in srgb, var(--color-text) 20%, transparent);
    position: relative;
    z-index: 1;
    transition: background 0.3s ease;
}
.bb-timeline-connector.completed {
    background: var(--bs-success);
}
.bb-timeline-connector.completed::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--bs-success), color-mix(in srgb, var(--bs-success) 80%, transparent));
    animation: timeline-glow 2s ease-in-out infinite alternate;
}
@keyframes timeline-glow {
    0% { box-shadow: 0 0 5px color-mix(in srgb, var(--bs-success) 50%, transparent); }
    100% { box-shadow: 0 0 10px color-mix(in srgb, var(--bs-success) 80%, transparent); }
}
.bb-next-action {
    border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
    background: color-mix(in srgb, var(--color-accent) 10%, transparent);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.bb-next-action.competing {
    border-color: color-mix(in srgb, var(--bs-danger) 50%, transparent);
    background: color-mix(in srgb, var(--bs-danger) 10%, transparent);
    animation: pulse-competing 2s ease-in-out infinite;
}
.bb-next-action.champion {
    border-color: color-mix(in srgb, var(--color-warn) 50%, transparent);
    background: color-mix(in srgb, var(--color-warn) 10%, transparent);
    animation: pulse-champion 3s ease-in-out infinite;
}
@keyframes pulse-competing {
    0%, 100% { box-shadow: 0 0 5px color-mix(in srgb, var(--bs-danger) 30%, transparent); }
    50% { box-shadow: 0 0 15px color-mix(in srgb, var(--bs-danger) 60%, transparent); }
}
@keyframes pulse-champion {
    0%, 100% { box-shadow: 0 0 8px color-mix(in srgb, var(--color-warn) 40%, transparent); }
    50% { box-shadow: 0 0 20px color-mix(in srgb, var(--color-warn) 70%, transparent); }
}

/* #294 — legibility fix. The admin/auth theme is dark (body bg var(--color-bg)) but
   Bootstrap's default .text-muted / .text-body-secondary (~#6c757d) is too dark
   to read on it, and .text-dark / .text-black are near-invisible. Remap to the
   theme's legible secondary/primary text tokens. All admin surfaces (cards,
   modals via .modal-content) are dark-themed, so this is safe everywhere here. */
.text-muted,
.text-body-secondary {
    color: var(--color-muted) !important;
}
.text-dark,
.text-black {
    color: var(--color-text) !important;
}
