/* ============================================================
   PigeonLink — Shared Sidebar & Layout CSS  v1.0
   /assets/css/pl-sidebar.css

   Single source of truth for sidebar, layout, and responsive
   breakpoints across all authenticated page templates.

   To update the sidebar globally: edit this file only.
   Templates include this via:
     <link rel="stylesheet" href="/assets/css/pl-sidebar.css">
   ============================================================ */

/* ── CSS variables ────────────────────────────────────────── */
:root {
    --pl-primary:      #0d6efd;
    --pl-primary-bg:   #eff6ff;
    --pl-primary-pale: #e8f0fe;
    --pl-primary-dark: #1a56db;
    --pl-bg:           #f8f9fa;
    --pl-sidebar-w:    260px;
    --pl-text-dark:    #212529;
    --pl-text-muted:   #64748b;
    --pl-border:       #e9ecef;
    --pl-border-light: #f1f3f5;
}

/* ── Body ─────────────────────────────────────────────────── */
body {
    background-color: var(--pl-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--pl-text-dark);
    min-height: 100vh;
}

/* ── Sidebar shell ────────────────────────────────────────── */
.sidebar {
    width: var(--pl-sidebar-w);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: #ffffff;
    border-right: 1px solid var(--pl-border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;           /* brand stays pinned; nav scrolls independently */
    transition: transform 0.3s ease;
}

/* ── Brand bar — always visible, never scrolls ────────────── */
.sidebar-brand {
    height: 70px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--pl-border-light);
    color: var(--pl-primary);
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
}
.sidebar-brand:hover {
    color: var(--pl-primary);
    text-decoration: none;
}

/* ── Nav wrapper — scrollable when menu overflows ─────────── */
/*
   Bootstrap's .nav sets flex-wrap:wrap and flex-direction:row which
   breaks the vertical scroll layout. All four overrides below are
   required to defeat those Bootstrap defaults.
*/
.sidebar nav.nav {
    flex: 1 1 0;                /* grow to fill sidebar, shrink to allow scroll */
    min-height: 0;              /* critical — without this flex children won't shrink below content size */
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;     /* override Bootstrap .nav default of row */
    flex-wrap: nowrap;          /* override Bootstrap .nav default of wrap */
    padding: 6px 0 16px;
    /* Thin scrollbar on supporting browsers */
    scrollbar-width: thin;
    scrollbar-color: #dee2e6 transparent;
}
.sidebar nav.nav::-webkit-scrollbar       { width: 4px; }
.sidebar nav.nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav.nav::-webkit-scrollbar-thumb { background: #dee2e6; border-radius: 2px; }

/* ── Standalone nav links (no section — e.g. Dashboard) ───── */
.nav-link {
    color: var(--pl-text-muted);
    padding: 9px 14px;
    font-size: 0.9rem;          /* LOCKED — prevents zoom between pages */
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    text-decoration: none;
    border-right: 3px solid transparent;
    white-space: nowrap;        /* prevent long labels wrapping inside the link */
}
.nav-link:hover  { color: var(--pl-primary); background-color: #f0f5ff; text-decoration: none; }
.nav-link.active {
    color: var(--pl-primary);
    background-color: var(--pl-primary-bg);
    border-right-color: var(--pl-primary);
    font-weight: 500;
}

/* ── Section header bar ───────────────────────────────────── */
/*
   Rendered by Menu.pm for Divider items.
   Floats inside the sidebar with margin so it doesn't span
   hard to the left edge. Uses the 4-square grid icon.
*/
.menu-section-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: var(--pl-primary-pale);
    margin: 8px 8px 2px 8px;
    border-radius: 6px;
    flex-shrink: 0;             /* never compress the section header */
}
.menu-section-bar .menu-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--pl-primary-dark);
}
.menu-section-bar .menu-section-icon svg {
    width: 11px;
    height: 11px;
    fill: var(--pl-primary-dark);
}
.menu-section-bar .menu-section-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pl-primary-dark);
    white-space: nowrap;
}

/* ── Child nav links — indented under section bars ────────── */
.nav-link-child {
    color: var(--pl-text-muted);
    padding: 7px 14px 7px 30px;  /* extra left indent vs standalone */
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    text-decoration: none;
    border-right: 3px solid transparent;
    white-space: nowrap;        /* prevent long labels wrapping inside the link */
    flex-shrink: 0;             /* never compress child links */
}
.nav-link-child:hover  { color: var(--pl-primary); background-color: #f0f5ff; text-decoration: none; }
.nav-link-child.active {
    color: var(--pl-primary);
    background-color: var(--pl-primary-bg);
    border-right-color: var(--pl-primary);
    font-weight: 500;
}
.nav-link-child i,
.nav-link-child svg {
    opacity: 0.65;
}
.nav-link-child.active i,
.nav-link-child.active svg {
    opacity: 1;
}

/* ── Legacy divider label (kept for back-compat) ──────────── */
/* Templates not yet migrated may still emit .menu-divider-label */
.menu-divider-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #adb5bd;
    padding: 14px 24px 4px;
}
.menu-divider {
    border: none;
    border-top: 1px solid var(--pl-border-light);
    margin: 6px 0;
}

/* ── Main content wrapper ─────────────────────────────────── */
/* Used by newer templates (races.html, manage_members.html etc.) */
.main-wrapper {
    margin-left: var(--pl-sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Used by older templates (myprofile.html etc.) */
.main-content {
    margin-left: var(--pl-sidebar-w);
    padding: 30px 40px;
}

/* ── Top header bar ───────────────────────────────────────── */
.top-header {
    height: 70px;
    background: #fff;
    border-bottom: 1px solid var(--pl-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ── Content body ─────────────────────────────────────────── */
.content-body {
    flex: 1;
    padding: 30px 40px;
}

/* ── Site footer ──────────────────────────────────────────── */
.site-footer {
    padding: 32px 40px 16px;
    border-top: 1px solid var(--pl-border);
    background: #fff;
    color: var(--pl-text-muted);
    font-size: 0.85rem;
}

/* ── Mobile overlay backdrop ──────────────────────────────── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1039;
    cursor: pointer;
}
.sidebar-backdrop.show { display: block; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════ */

/* ── Tablet portrait and below (< 992px) ─────────────────── */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1040;
    }
    .sidebar.show      { transform: translateX(0); }
    .main-wrapper      { margin-left: 0; }
    .main-content      { margin-left: 0; padding: 20px; }
    .top-header        { padding: 0 20px; }
    .content-body      { padding: 20px; }
    .site-footer       { padding: 24px 20px 16px; }
}

/* ── Small tablet / large phone (576px–767px) ─────────────── */
@media (max-width: 767px) {
    .sidebar { width: 240px; }
}

/* ── Phone portrait (< 576px) ────────────────────────────── */
@media (max-width: 575px) {
    .sidebar           { width: 85vw; max-width: 280px; }
    .content-body      { padding: 15px; }
    .main-content      { padding: 15px; }
    .site-footer       { padding: 20px 15px 12px; }
    .top-header        { height: auto; min-height: 60px; padding: 10px 15px; flex-wrap: wrap; gap: 8px; }
}
