/* =============================================================================
   admin-operator-rail.css — DA front-end revamp Phase 4: Operator Rebuild
   -----------------------------------------------------------------------------
   Persistent, permission-aware admin sub-navigation (research/03 §2.1, fixes
   audit offender #8: ~130 admin screens with no lateral nav). Token-only —
   every color/spacing value below resolves to an existing site.css/
   v2-primitives.css token. No new hex, no gradients (flat only, per the PO's
   locked-palette ruling).

   Structure rendered by Views/Shared/Components/OperatorRail/Default.cshtml,
   wrapped by Views/Shared/_AdminLayout.cshtml as three siblings inside
   .admin-shell: <aside class="operator-rail">, <nav class="admin-rail-breadcrumb">,
   <div class="admin-shell-content">. Below 1024px they stack (mobile-safe,
   no second fixed sidebar competing with the app's own bottom-nav); at
   1024px+ they form a 210px-rail + content CSS grid (DAPS-Studio precedent:
   same tokens as the 240px consumer sidebar, narrower + denser).
   ============================================================================= */

.admin-shell {
    display: flex;
    flex-direction: column;
    gap: var(--space-4, 16px);
}

.admin-shell-content {
    min-width: 0; /* allow child tables/pre to shrink instead of overflowing the grid track */
}

/* -----------------------------------------------------------------------------
   Rail — native <details>/<summary> disclosure. Zero JS, keyboard-operable
   (research/03 §2.1: "DAPS pattern: native disclosure, zero JS").
   ----------------------------------------------------------------------- */
.operator-rail {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    padding: var(--space-3, 12px);
}

.operator-rail-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1, 4px);
}

.operator-rail-group {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-1, 4px);
    margin-bottom: var(--space-1, 4px);
}

.operator-rail-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.operator-rail-group-summary {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    min-height: 44px;
    padding: var(--space-2, 8px) var(--space-2, 8px);
    border-radius: 8px;
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
    font-family: 'Sora', sans-serif;
    font-size: 14px;
    font-weight: 600;
    user-select: none;
}

.operator-rail-group-summary::-webkit-details-marker {
    display: none;
}

.operator-rail-group-summary::after {
    content: '\25BE';
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.15s ease;
}

.operator-rail-group[open] > .operator-rail-group-summary::after {
    transform: rotate(180deg);
}

.operator-rail-group-summary:hover {
    background: var(--bg-tertiary);
}

.operator-rail-group-summary:focus-visible,
.operator-rail-link:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.operator-rail-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: var(--space-6, 24px);
    margin-top: var(--space-1, 4px);
}

.operator-rail-link {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    min-height: 44px;
    padding: var(--space-2, 8px) var(--space-2, 8px);
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: 'Open Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    position: relative;
}

.operator-rail-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
}

.operator-rail-link.active {
    background: var(--info-surface);
    color: var(--text-primary);
    font-weight: 600;
}

.operator-rail-link.active::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--rail-color);
    border-radius: 0 3px 3px 0;
}

/* Top-level "Overview" link — no disclosure, no indent, matches a rail group summary's size/weight. */
.operator-rail-link--top {
    min-height: 44px;
    padding: var(--space-2, 8px);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Sora', sans-serif;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: var(--space-2, 8px);
}

.operator-rail-link--top:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.operator-rail-link--top.active {
    background: var(--info-surface);
}

/* -----------------------------------------------------------------------------
   Breadcrumb — second wayfinding layer (research/03 line 129: "Admin / Money
   & Ledger / External Funds"). Mirrors the existing .prov-breadcrumb pattern
   (admin.css) so the two don't visually disagree.
   ----------------------------------------------------------------------- */
.admin-rail-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2, 8px);
    font-family: 'Open Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
}

.admin-rail-breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.admin-rail-breadcrumb a:hover {
    color: var(--accent-primary);
}

.admin-rail-breadcrumb-sep {
    color: var(--text-muted);
}

.admin-rail-breadcrumb-current {
    color: var(--text-primary);
}

@media (prefers-reduced-motion: reduce) {
    .operator-rail-group-summary::after {
        transition: none;
    }
}

/* -----------------------------------------------------------------------------
   Desktop (1024px+): rail becomes a sticky 210px column, breadcrumb sits
   above the content column, content fills the remaining width. The app's
   own 240px consumer sidebar (desktop.css .desktop-sidebar) stays untouched
   to its left — this rail is a SECOND, nested rail scoped to /Admin, not a
   replacement for the app shell.
   ----------------------------------------------------------------------- */
@media (min-width: 1024px) {
    .admin-shell {
        display: grid;
        grid-template-columns: 210px 1fr;
        grid-template-rows: auto 1fr;
        align-items: start;
        gap: var(--space-3, 12px) var(--space-6, 24px);
    }

    .operator-rail {
        grid-column: 1;
        grid-row: 1 / span 2;
        position: sticky;
        top: calc(60px + var(--space-4, 16px));
        max-height: calc(100vh - 60px - var(--space-6, 24px));
        overflow-y: auto;
    }

    .admin-rail-breadcrumb {
        grid-column: 2;
        grid-row: 1;
    }

    .admin-shell-content {
        grid-column: 2;
        grid-row: 2;
    }
}
