/*
    The signed-in sidebar's color coding (Components/Layout/AdminLayout.razor).

    Each menu section has one hue: its header, its links' icons, the hover and active pill and a group's submenu rail
    all read it, so a long menu splits into a few bands the eye can find. The layout decides the hue per element and
    writes it as data-hue (Helpers/Navigation/AdminNavLayouts.Resolve): "By section" gives every link its section's
    hue, "By page" gives each link the hue of the page it opens, and "Off" writes no data-hue at all, which leaves
    the sidebar as the layout's own <style> draws it (its section headers still get the neutral fading rule below). Nothing here touches the sidebar's background.

    One hue is --nav-hue. "couple" is the one two-tone hue (the user's blue into the partner's amber, the couple
    palette of Settle Up and Partner Sharing): it also sets --nav-hue-2, and every wash reads both.
    The section and page hues (--nh-*) are fixed, like the colors that mark each area on its page: the accent slider
    does not move them. Light and dark are separate values, not an inversion. ADMIN is the exception: its links wear
    the accent color ("accent"), as they always have, and its header keeps its shield and dashed rule.
*/

/* The hues and the washes, for the sidebar and for the Menu layout board (css/menu-layout.css) that mirrors it. */
.admin-sidebar,
.ml-board {
    --nh-blue: #2563EB;
    --nh-aqua: #0D9488;
    --nh-sky: #0284C7;
    --nh-amber: #B45309;
    --nh-fuchsia: #C026D3;
    --nh-green: #15803D;
    --nh-rose: #E11D48;
    --nh-gold: #D97706;
    --nh-violet: #7C3AED;
    --nh-indigo: #4F46E5;
    --nh-slate: #5B6475;
    /* What a hue is mixed toward for text, and how strong each wash is. */
    --nav-ink: #14172B;
    --nav-text-hue: 72%;
    --nav-wash-chip: 11%;
    --nav-wash-hover: 8%;
    --nav-rail: 30%;
    /* The menu links' own ink: the neutral rule after a section label ("By page" and "Off") is drawn in it. */
    --nav-link-ink: #2A2F55;
}

[data-bs-theme="dark"] .admin-sidebar,
[data-bs-theme="dark"] .ml-board {
    --nh-blue: #60A5FA;
    --nh-aqua: #2DD4BF;
    --nh-sky: #38BDF8;
    --nh-amber: #F2B557;
    --nh-fuchsia: #E879F9;
    --nh-green: #34D399;
    --nh-rose: #FB7185;
    --nh-gold: #FBBF24;
    --nh-violet: #C4B5FD;
    --nh-indigo: #A5B4FC;
    --nh-slate: #A9AEC4;
    --nav-ink: #FFFFFF;
    --nav-text-hue: 58%;
    --nav-wash-chip: 13%;
    --nav-wash-hover: 9%;
    --nav-rail: 34%;
    --nav-link-ink: rgba(230, 233, 245, .85);
}

:is(.admin-sidebar, .ml-board) [data-hue="blue"] { --nav-hue: var(--nh-blue); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="aqua"] { --nav-hue: var(--nh-aqua); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="sky"] { --nav-hue: var(--nh-sky); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="amber"] { --nav-hue: var(--nh-amber); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="fuchsia"] { --nav-hue: var(--nh-fuchsia); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="green"] { --nav-hue: var(--nh-green); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="rose"] { --nav-hue: var(--nh-rose); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="violet"] { --nav-hue: var(--nh-violet); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="indigo"] { --nav-hue: var(--nh-indigo); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="slate"] { --nav-hue: var(--nh-slate); --nav-hue-2: initial; }
:is(.admin-sidebar, .ml-board) [data-hue="couple"] { --nav-hue: var(--nh-blue); --nav-hue-2: var(--nh-gold); }
/* ADMIN: the accent color, the one hue here that follows the Site Preferences slider. */
:is(.admin-sidebar, .ml-board) [data-hue="accent"] { --nav-hue: var(--chipin-brand-primary); --nav-hue-2: initial; }
[data-bs-theme="dark"] :is(.admin-sidebar, .ml-board) [data-hue="accent"] { --nav-hue: hsl(calc(246.89deg + var(--ci-accent-shift, 0deg)) calc(100% * var(--ci-accent-sat, 1)) calc(88.04% - var(--ci-accent-dim, 0%) * 0.421)); }

/* ------------------------------------------------------------------ Section headers
   The label in its hue, then a hairline that fades out toward the edge, so each section starts on a quiet rule. */
.admin-sidebar .admin-nav-section[data-hue] {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .85rem;
    color: color-mix(in srgb, var(--nav-hue) 82%, var(--nav-ink));
}

[data-bs-theme="dark"] .admin-sidebar .admin-nav-section[data-hue] { color: color-mix(in srgb, var(--nav-hue) 86%, transparent); }

.admin-sidebar .admin-nav-section[data-hue]::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) 32%, transparent), transparent);
}

/* "By page" and "Off" leave the headers uncolored but keep the same fading hairline after each label, drawn in the
   menu links' own ink, so the sections still start on a quiet rule. */
.admin-sidebar .admin-nav-section[data-rule="neutral"] {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .85rem;
}

.admin-sidebar .admin-nav-section[data-rule="neutral"]::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--nav-link-ink) 30%, transparent), transparent);
}

.admin-sidebar .admin-nav-section[data-hue="couple"] .admin-nav-section-label {
    background: linear-gradient(90deg, var(--nav-hue), var(--nav-hue-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ------------------------------------------------------------------ Links
   At rest only the icon carries the hue (the label stays the sidebar's ink). A top-level link's icon sits on a soft
   chip of the same hue when the icon style is "With tile" (.admin-nav[data-icons="tile"], Menu layout > Icons; the
   default, with Colors Off, since 2026-11-22); with "Icon only" the chip keeps its size but has no fill. A submenu
   link's icon is always the bare glyph. */
.admin-sidebar .admin-nav-link[data-hue] > i.bx { color: var(--nav-hue); }

.admin-sidebar .admin-nav-link[data-hue]:not(.admin-nav-sublink) { padding-top: .32rem; padding-bottom: .32rem; padding-left: .5rem; }

.admin-sidebar .admin-nav-link[data-hue]:not(.admin-nav-sublink) > i.bx {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    margin-right: .6rem !important;
    border-radius: .55rem;
    font-size: 1.05rem;
    transition: background-color .15s ease, color .15s ease;
}

.admin-sidebar .admin-nav[data-icons="tile"] .admin-nav-link[data-hue]:not(.admin-nav-sublink) > i.bx {
    background: linear-gradient(135deg, color-mix(in srgb, var(--nav-hue) var(--nav-wash-chip), transparent), color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) var(--nav-wash-chip), transparent));
}

/* "With tile" while Colors is Off: the same chip in a neutral wash of the link's own ink. */
.admin-sidebar .admin-nav[data-icons="tile"] .admin-nav-link:not([data-hue]):not(.admin-nav-sublink):not(.admin-nav-arrange) > i.bx {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    margin-right: .6rem !important;
    border-radius: .55rem;
    background: color-mix(in srgb, currentColor 10%, transparent);
    font-size: 1.05rem;
    vertical-align: middle;
}

.admin-sidebar .admin-nav-link.admin-nav-link-sub[data-hue] { padding-left: 2.15rem; }

.admin-sidebar .admin-nav-link.admin-nav-sublink[data-hue] > i.bx { color: color-mix(in srgb, var(--nav-hue) 82%, transparent); }

.admin-sidebar .admin-nav-link[data-hue]:hover {
    background: linear-gradient(90deg, color-mix(in srgb, var(--nav-hue) var(--nav-wash-hover), transparent), color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) var(--nav-wash-hover), transparent));
    color: color-mix(in srgb, var(--nav-hue) var(--nav-text-hue), var(--nav-ink)) !important;
}

.admin-sidebar .admin-nav-link[data-hue]:hover > i.bx { color: var(--nav-hue); }

/* The page you are on: a quiet neutral wash fading to the right, the same in every color mode. No ring, no inner
   shadow, no glow, no hue wash. The label goes to full ink and the icon keeps its hue, so color still says where you are. */
.admin-sidebar,
.ml-board {
    --nav-well: linear-gradient(90deg, rgba(20, 23, 43, .075) 0%, rgba(20, 23, 43, .025) 100%);
    --nav-well-shade: none;
    --nav-wash-chip-active: 20%;
}

[data-bs-theme="dark"] .admin-sidebar,
[data-bs-theme="dark"] .ml-board {
    --nav-well: linear-gradient(90deg, rgba(255, 255, 255, .085) 0%, rgba(255, 255, 255, .025) 100%);
    --nav-well-shade: none;
    --nav-wash-chip-active: 24%;
}

.admin-sidebar .admin-nav-link[data-hue].active {
    background: var(--nav-well);
    color: var(--nav-ink) !important;
    font-weight: 600;
    box-shadow: var(--nav-well-shade);
}

.admin-sidebar .admin-nav-link[data-hue].active > i.bx { color: var(--nav-hue); }

/* An open group's parent is a signpost, not a second selection: plain link, no wash. The page under it carries the mark.
   Folded shut, the parent keeps the mark so the page you are on stays visible. */
.admin-sidebar .admin-nav-group-toggle:checked ~ .admin-nav-group-header .admin-nav-link.admin-nav-parent[data-hue].active:not(:hover) { background: transparent; box-shadow: none; font-weight: 500; color: var(--nav-link-ink) !important; }
.admin-sidebar .admin-nav[data-icons="tile"] .admin-nav-group-toggle:checked ~ .admin-nav-group-header .admin-nav-link.admin-nav-parent[data-hue].active:not(:hover) > i.bx { background: linear-gradient(135deg, color-mix(in srgb, var(--nav-hue) var(--nav-wash-chip), transparent), color-mix(in srgb, var(--nav-hue-2, var(--nav-hue)) var(--nav-wash-chip), transparent)); }

/* The active top-level chip deepens a step instead of filling solid. */
.admin-sidebar .admin-nav[data-icons="tile"] .admin-nav-link[data-hue].active:not(.admin-nav-sublink) > i.bx {
    background: color-mix(in srgb, var(--nav-hue) var(--nav-wash-chip-active), transparent);
}

/* ------------------------------------------------------------------ Groups: the submenu rail and its ticks */
.admin-sidebar .admin-nav-group[data-hue] .admin-nav-group-toggle:checked ~ .admin-nav-submenu { border-left-color: color-mix(in srgb, var(--nav-hue) var(--nav-rail), transparent); margin-left: 1.35rem; }
.admin-sidebar .admin-nav-group[data-hue] .admin-nav-submenu { margin-left: 1.35rem; }
.admin-sidebar .admin-nav-group[data-hue] .admin-nav-sublink::before { background: color-mix(in srgb, var(--nav-hue) var(--nav-rail), transparent); }
.admin-sidebar .admin-nav-group[data-hue] .admin-nav-group-caret:hover { background-color: color-mix(in srgb, var(--nav-hue) 14%, transparent); }

/* ------------------------------------------------------------------ Arrange menu (the small button beside the plan badge) */
.admin-sidebar-plan { align-items: center; justify-content: space-between; gap: .5rem; }

.admin-nav-arrange {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: .6rem;
    color: rgba(42, 47, 85, .55);
    font-size: 1.1rem;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.admin-nav-arrange:hover,
.admin-nav-arrange.active { background-color: hsl(calc(247.83deg + var(--ci-accent-shift, 0deg)) calc(76.3% * var(--ci-accent-sat, 1)) calc(58.63% - var(--ci-accent-dim, 0%) * 0.97) / .1); color: var(--chipin-brand-primary); }
.admin-nav-arrange:focus-visible { outline: 2px solid var(--chipin-brand-primary); outline-offset: 2px; }

[data-bs-theme="dark"] .admin-nav-arrange { color: rgba(230, 233, 245, .5); }
[data-bs-theme="dark"] .admin-nav-arrange:hover,
[data-bs-theme="dark"] .admin-nav-arrange.active { background-color: rgba(255, 255, 255, .08); color: hsl(calc(246.89deg + var(--ci-accent-shift, 0deg)) calc(100% * var(--ci-accent-sat, 1)) calc(88.04% - var(--ci-accent-dim, 0%) * 0.421)); }

/* High contrast (Settings > Site Preferences): the hue stays on the icon, the words go closer to the ink. */
html[data-a11y-high-contrast="on"] .admin-sidebar { --nav-text-hue: 42%; --nav-rail: 55%; }
html[data-a11y-high-contrast="on"] .admin-sidebar .admin-nav-link[data-hue].active:not(.admin-nav-parent) { box-shadow: inset 3px 0 0 var(--nav-hue); }
html[data-a11y-high-contrast="on"] .admin-shell .admin-sidebar .admin-nav-section[data-hue] { color: color-mix(in srgb, var(--nav-hue) 55%, var(--nav-ink)) !important; }
html[data-a11y-high-contrast="on"] .admin-shell .admin-sidebar .admin-nav-section[data-hue="couple"] .admin-nav-section-label { background: none; color: inherit; }

@media (prefers-reduced-motion: reduce) {
    .admin-sidebar .admin-nav-link[data-hue] > i.bx, .admin-nav-arrange { transition: none; }
}
