/* ═══════════════════════════════════════════════════
   Team Portal — Shared Sidebar Navigation
   Shipped by js/team-sidebar.js. Keep colors/fonts
   aligned with existing per-page :root variables.
═══════════════════════════════════════════════════ */

:root {
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 64px;
    --sidebar-header-h: 70px;
}

/* Remove the old horizontal nav wrapper when sidebar is present */
body.has-sidebar .nav-wrapper { display: none !important; }

/* Slim the sticky header so sidebar slots beneath it */
body.has-sidebar .header { z-index: 110; }

/* ── Sidebar container ──
   Floating popover: sized to its content, not the viewport. Hidden by default
   and slid in via `.open` when the hamburger toggles. Page layout never
   shifts — main content keeps its full width.
   Sits just under the header with a small inset, has rounded corners + drop
   shadow, and caps at the viewport height so long menus scroll internally. */
.team-sidebar {
    position: fixed;
    top: calc(var(--sidebar-header-h) + 8px);
    left: 12px;
    width: var(--sidebar-w);
    max-height: calc(100vh - var(--sidebar-header-h) - 20px);
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    z-index: 90;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0;
    transform: translateX(calc(-100% - 16px));
    transition: transform 0.24s ease, opacity 0.24s ease;
    opacity: 0;
    -webkit-overflow-scrolling: touch;
}

.team-sidebar.open {
    transform: translateX(0);
    opacity: 1;
}

.team-sidebar::-webkit-scrollbar { width: 6px; }
.team-sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ── Grouped sections ── */
.sidebar-group { margin-bottom: 14px; }
.sidebar-group:last-child { margin-bottom: 0; }

.sidebar-group-title {
    font-family: 'Titillium Web', Helvetica, Arial, sans-serif;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #8a9bb0;
    padding: 0 20px 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 20px;
    margin: 2px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease;
    position: relative;
    white-space: nowrap;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #1a2535;
}

.sidebar-link.active {
    background: rgba(2, 101, 161, 0.1);
    color: #0265a1;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #0265a1;
    border-radius: 0 3px 3px 0;
}

.sidebar-link .sidebar-badge {
    margin-left: auto;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-link .sidebar-badge:empty { display: none; }

/* The HTML `hidden` attribute defaults to `display:none`, but our
   `.sidebar-link { display:flex }` rule above has the same specificity and
   wins the cascade — so without this override role-gated items stay visible.
   Explicit rule ensures hidden items actually disappear. */
.sidebar-link[hidden] { display: none !important; }

/* Coming-soon items: visible but unclickable, with a Soon pill */
.sidebar-link.coming-soon {
    pointer-events: none;
    cursor: default;
    opacity: 0.55;
}
.sidebar-link .sidebar-badge.coming-soon {
    background: #94a3b8;
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 7px;
}

/* ── Hamburger toggle (visible on every viewport) ── */
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: 8px;
    margin-right: 8px;
    color: #1a2535;
    cursor: pointer;
    border-radius: 4px;
}

.sidebar-toggle:hover { background: #f3f4f6; }

/* Animated hamburger → X. The three bars are absolute-positioned inside a
   fixed-size box, so we can rotate top/bottom into an X and fade the middle
   when the button reports aria-expanded="true". */
.sidebar-toggle .sidebar-toggle-bars {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 18px;
}
.sidebar-toggle .bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.25s ease, top 0.25s ease, opacity 0.2s ease;
}
.sidebar-toggle .bar-top { top: 2px; }
.sidebar-toggle .bar-mid { top: 8px; }
.sidebar-toggle .bar-bot { top: 14px; }

.sidebar-toggle[aria-expanded="true"] .bar-top {
    top: 8px;
    transform: rotate(45deg);
}
.sidebar-toggle[aria-expanded="true"] .bar-mid {
    opacity: 0;
}
.sidebar-toggle[aria-expanded="true"] .bar-bot {
    top: 8px;
    transform: rotate(-45deg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 89;
}

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

@media print {
    .team-sidebar, .sidebar-overlay, .sidebar-toggle { display: none !important; }
}

/* ─── Site-wide page transitions ───
   Every portal page (and the React SPAs) load this file, so adding here
   guarantees a consistent feel between tab/page navigations.

   Chromium 126+: cross-document View Transitions auto-fade between pages.
   All other browsers: the body fade-in runs on every page load. Both can
   coexist (VT handles the between-pages crossfade; the body fade gives the
   new page a soft entrance). Skipped under prefers-reduced-motion. */
@view-transition {
    navigation: auto;
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes portal-page-fade-in {
        from { opacity: 0; }
        to   { opacity: 1; }
    }
    body {
        animation: portal-page-fade-in 200ms ease-out;
    }
}

/* Tune the View Transition crossfade duration so it feels quick, not slow. */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 180ms;
    animation-timing-function: ease-out;
}
