/* =============================================================
     WIDGET STYLES — move to your stylesheet if you prefer.
     Everything is scoped under .fsb, and the Bootstrap overrides
     are specific enough to beat .nav / .nav-link defaults.
     ============================================================= */
.fsb {
    --fsb-rail: 46px;          /* collapsed icon column width */
    --fsb-open: 236px;         /* expanded body width */
    --fsb-row: 40px;           /* list row height */
    --fsb-av: 30px;            /* avatar diameter (a true circle) */
    --fsb-pad: 8px;
    --fsb-list-max: 46vh;      /* how tall the scroll area may get */
    --fsb-radius: 20px;

    --fsb-bg: rgba(255, 255, 255, 0.94);
    --fsb-ring: #ffffff;
    --fsb-border: rgba(18, 21, 28, 0.055);
    --fsb-line: rgba(18, 21, 28, 0.045);
    --fsb-fg: #4b5261;
    --fsb-fg-strong: #171a21;
    --fsb-fg-dim: #9aa0ab;
    --fsb-hover: rgba(18, 21, 28, 0.038);
    --fsb-field: rgba(18, 21, 28, 0.035);
    --fsb-accent: #3b74ff;
    --fsb-accent-soft: rgba(59, 116, 255, 0.10);
    --fsb-mark: rgba(255, 214, 92, 0.6);
    --fsb-thumb: rgba(18, 21, 28, 0.16);
    --fsb-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.85),
            0 1px 1px rgba(17, 20, 28, 0.035),
            0 4px 8px -2px rgba(17, 20, 28, 0.055),
            0 12px 24px -6px rgba(17, 20, 28, 0.085),
            0 30px 60px -14px rgba(17, 20, 28, 0.16);
    --fsb-shadow-lift:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            0 2px 4px rgba(17, 20, 28, 0.05),
            0 10px 20px -4px rgba(17, 20, 28, 0.09),
            0 24px 44px -10px rgba(17, 20, 28, 0.14),
            0 48px 90px -20px rgba(17, 20, 28, 0.22);

    position: fixed;
    top: 0; left: 0;                     /* JS drives these */
    z-index: 1080;                       /* above Bootstrap's sticky/fixed bars */
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
    padding: var(--fsb-pad);
    border-radius: var(--fsb-radius);
    background: var(--fsb-bg);
    border: 1px solid var(--fsb-border);
    box-shadow: var(--fsb-shadow);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    color: var(--fsb-fg);
    user-select: none;
    transition: left .22s cubic-bezier(.22,.7,.3,1),
    top .22s cubic-bezier(.22,.7,.3,1),
    box-shadow .22s ease,
    transform .22s ease;
}
.fsb *, .fsb *::before, .fsb *::after { box-sizing: border-box; }
.fsb.is-dragging {
    transition: box-shadow .22s ease, transform .22s ease;
    cursor: grabbing;
    transform: scale(1.012);
    box-shadow: var(--fsb-shadow-lift);
}
.fsb.is-measuring, .fsb.is-measuring * { transition: none !important; }

/* --- drag handle --- */
.fsb__grip {
    position: relative;
    flex: 0 0 18px;
    display: grid; place-items: center;
    margin-right: 2px; padding: 0; border: 0;
    background: transparent; color: inherit;
    opacity: .4; cursor: grab; touch-action: none;
    transition: opacity .15s ease;
}
.fsb__grip::before {
    content: '';
    position: absolute; left: 0; right: 0; top: 50%;
    height: 46px; transform: translateY(-50%);
    border-radius: 9px; background: transparent;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.fsb__grip svg { position: relative; }
.fsb__grip:hover { opacity: .85; }
.fsb__grip:hover::before { background: var(--fsb-hover); }
.fsb__grip:focus-visible { outline: none; opacity: 1; color: var(--fsb-accent); }
.fsb__grip:focus-visible::before {
    background: var(--fsb-accent-soft);
    box-shadow: inset 0 0 0 1.5px var(--fsb-accent);
}
.fsb.is-dragging .fsb__grip { cursor: grabbing; opacity: 1; }

/* --- body --- */
.fsb__body {
    width: var(--fsb-rail);
    display: flex; flex-direction: column;
    min-width: 0; overflow: hidden;
    transition: width .24s cubic-bezier(.22,.7,.3,1);
}
.fsb.is-open .fsb__body { width: var(--fsb-open); }

/* --- search header (also a drag surface) --- */
.fsb__head {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 2px;
    height: var(--fsb-rail);
    touch-action: none;
}
.fsb__searchToggle {
    flex: 0 0 var(--fsb-rail);
    width: var(--fsb-rail); height: var(--fsb-rail);
    display: grid; place-items: center;
    padding: 0; border: 0; border-radius: 13px;
    background: transparent; color: inherit; cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.fsb__searchToggle:hover { background: var(--fsb-hover); color: var(--fsb-fg-strong); }
.fsb__searchToggle:focus-visible { outline: 2px solid var(--fsb-accent); outline-offset: -2px; }
.fsb__searchToggle svg { width: 19px; height: 19px; display: block; }

.fsb__input {
    flex: 1 1 auto; min-width: 0; width: 0;
    height: 34px; padding: 0; border: 0; outline: 0;
    border-radius: 10px;
    background: transparent; color: var(--fsb-fg-strong);
    font: 500 14px/1 inherit;
    opacity: 0; pointer-events: none;
    transition: opacity .16s ease, padding .24s ease, background-color .15s ease;
    -webkit-appearance: none; appearance: none;
}
.fsb__input::-webkit-search-cancel-button { display: none; }
.fsb__input::placeholder { color: var(--fsb-fg-dim); font-weight: 400; }
.fsb.is-open .fsb__input {
    opacity: 1; pointer-events: auto;
    padding: 0 8px; background: var(--fsb-field);
}
.fsb.is-open .fsb__input:focus { box-shadow: 0 0 0 2px var(--fsb-accent-soft) inset; }

.fsb__clear {
    flex: 0 0 26px; width: 26px; height: 26px;
    margin-right: 4px; padding: 0; border: 0;
    display: none; place-items: center;
    border-radius: 8px; background: transparent; color: var(--fsb-fg-dim);
    cursor: pointer;
}
.fsb.is-open .fsb__clear.is-shown { display: grid; }
.fsb__clear:hover { background: var(--fsb-hover); color: var(--fsb-fg-strong); }
.fsb__clear svg { width: 14px; height: 14px; display: block; }

.fsb__rule { height: 1px; margin: 2px 0 4px; flex: 0 0 auto; background: var(--fsb-line); }

/* --- the scrolling <ul> (works with or without Bootstrap's .nav) --- */
.fsb__list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: var(--fsb-list-max);
    margin: 0; padding: 0;
    list-style: none;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: var(--fsb-thumb) transparent;
    scroll-padding: 4px 0;
    --fade-t: 0px;
    --fade-b: 0px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-t),
    #000 calc(100% - var(--fade-b)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-t),
    #000 calc(100% - var(--fade-b)), transparent 100%);
}
.fsb__list.has-up   { --fade-t: 16px; }
.fsb__list.has-down { --fade-b: 16px; }
.fsb__list::-webkit-scrollbar { width: 8px; }
.fsb__list::-webkit-scrollbar-track { background: transparent; }
.fsb__list::-webkit-scrollbar-thumb {
    background: var(--fsb-thumb); border-radius: 99px;
    border: 2px solid transparent; background-clip: content-box;
}

/* --- Bootstrap nav overrides (scoped, and specific enough to win) --- */
.fsb .fsb__list.nav { flex-wrap: nowrap; }
.fsb .nav-item { width: 100%; }
.fsb .nav-item + .nav-item { margin-top: 2px; }
.fsb .nav-item.fsb-hidden { display: none; }

.fsb .fsb__list .nav-link {
    display: flex; align-items: center;
    width: 100%; height: var(--fsb-row);
    padding: 0; border: 0;
    border-radius: 11px;
    background-color: transparent;
    color: var(--fsb-fg);
    font: inherit; font-size: 13.5px;
    text-align: left; text-decoration: none;
    overflow: hidden; cursor: pointer;
    transition: background-color .13s ease, color .13s ease;
}
.fsb .fsb__list .nav-link:hover,
.fsb .fsb__list .nav-link.is-cursor {
    background-color: var(--fsb-hover);
    color: var(--fsb-fg-strong);
}
.fsb .fsb__list .nav-link.active,
.fsb .fsb__list .nav-link.show {
    background-color: var(--fsb-accent-soft);
    color: var(--fsb-fg-strong);
    font-weight: 600;
}
.fsb .fsb__list .nav-link.active .fsb__avatar { box-shadow: 0 0 0 2px var(--fsb-accent); }
.fsb .fsb__list .nav-link:focus-visible {
    outline: 2px solid var(--fsb-accent); outline-offset: -2px;
    box-shadow: none;
}
.fsb .fsb__list .nav-link.disabled { opacity: .45; pointer-events: none; }

/* --- avatar: flex-basis, width and height all agree, so it stays round --- */
.fsb__avatar {
    position: relative;
    flex: 0 0 var(--fsb-av);
    width: var(--fsb-av); height: var(--fsb-av);
    aspect-ratio: 1 / 1;
    margin: 0 calc((var(--fsb-rail) - var(--fsb-av)) / 2);
    display: grid; place-items: center;
    border-radius: 50%;
    font: 650 11.5px/1 ui-sans-serif, system-ui, sans-serif;
    letter-spacing: .3px; text-transform: uppercase;
    background: var(--av-bg, #eceef3);
    color: var(--av-fg, #4a505c);
    box-shadow: inset 0 0 0 1px rgba(18, 21, 28, 0.05);
}
.fsb__status {
    position: absolute; right: -1px; bottom: -1px;
    width: 7px; height: 7px; border-radius: 50%;
    border: 2px solid var(--fsb-ring);
    background: var(--fsb-fg-dim);
    box-sizing: content-box;
}
.fsb__status[data-status="active"]   { background: #16a34a; }
.fsb__status[data-status="pending"]  { background: #f59e0b; }
.fsb__status[data-status="archived"] { background: #9aa1ae; }

.fsb__name {
    flex: 1 1 auto; min-width: 0;
    padding-right: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0;
    transition: opacity .18s ease;
}
.fsb.is-open .fsb__name { opacity: 1; }
.fsb__name mark {
    background: var(--fsb-mark); color: inherit;
    border-radius: 3px; padding: 0 1px;
}

/* --- empty state + count --- */
.fsb__empty {
    display: none; margin: 0;
    padding: 14px 10px 16px;
    font-size: 13px; color: var(--fsb-fg-dim); text-align: center;
}
.fsb.is-open.is-empty .fsb__empty { display: block; }
.fsb__count {
    flex: 0 0 auto;
    height: 0; opacity: 0; overflow: hidden;
    padding: 0 4px;
    font-size: 11px; letter-spacing: .02em; color: var(--fsb-fg-dim);
    transition: opacity .16s ease;   /* height must NOT animate: JS measures it */
}
.fsb.is-open .fsb__count { height: 22px; opacity: 1; padding-top: 6px; }

/* --- dark palette: opt in with data-fsb-theme="dark" (or "auto") --- */
.fsb[data-fsb-theme="dark"] {
    color-scheme: dark;
    --fsb-bg: rgba(28, 31, 38, 0.92);
    --fsb-ring: #24272e;
    --fsb-border: rgba(255, 255, 255, 0.09);
    --fsb-line: rgba(255, 255, 255, 0.08);
    --fsb-fg: #c0c7d2;
    --fsb-fg-strong: #f4f6f9;
    --fsb-fg-dim: #838b96;
    --fsb-hover: rgba(255, 255, 255, 0.065);
    --fsb-field: rgba(255, 255, 255, 0.06);
    --fsb-accent: #6d9aff;
    --fsb-accent-soft: rgba(109, 154, 255, 0.18);
    --fsb-mark: rgba(255, 205, 80, 0.3);
    --fsb-thumb: rgba(255, 255, 255, 0.2);
    --fsb-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.06),
            0 2px 4px rgba(0, 0, 0, .3),
            0 16px 32px -8px rgba(0, 0, 0, .45),
            0 40px 72px -18px rgba(0, 0, 0, .55);
    --fsb-shadow-lift:
            inset 0 1px 0 rgba(255, 255, 255, 0.08),
            0 4px 8px rgba(0, 0, 0, .35),
            0 24px 48px -10px rgba(0, 0, 0, .5),
            0 60px 100px -24px rgba(0, 0, 0, .65);
}
.fsb[data-fsb-theme="dark"] .fsb__avatar { filter: saturate(.9) brightness(.95); }

@media (prefers-color-scheme: dark) {
    .fsb[data-fsb-theme="auto"] {
        color-scheme: dark;
        --fsb-bg: rgba(28, 31, 38, 0.92);
        --fsb-ring: #24272e;
        --fsb-border: rgba(255, 255, 255, 0.09);
        --fsb-line: rgba(255, 255, 255, 0.08);
        --fsb-fg: #c0c7d2;
        --fsb-fg-strong: #f4f6f9;
        --fsb-fg-dim: #838b96;
        --fsb-hover: rgba(255, 255, 255, 0.065);
        --fsb-field: rgba(255, 255, 255, 0.06);
        --fsb-accent: #6d9aff;
        --fsb-accent-soft: rgba(109, 154, 255, 0.18);
        --fsb-mark: rgba(255, 205, 80, 0.3);
        --fsb-thumb: rgba(255, 255, 255, 0.2);
    }
    .fsb[data-fsb-theme="auto"] .fsb__avatar { filter: saturate(.9) brightness(.95); }
}
@media (prefers-reduced-motion: reduce) {
    .fsb, .fsb * { transition: none !important; }
}