@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Accent colors are pulled from the topbar's animated palette so links,
   buttons, and other accent surfaces all read as the same family. Both
   --client-accent and --client-accent-hover are theme-aware (defined in
   the :root blocks further down). The dark/light-prefixed selectors are
   needed to beat the shared component CSS, which sets a more specific
   [data-bs-theme="dark"] a { color: #79c0ff } rule. */
a, .btn-link,
[data-bs-theme="dark"] a,  [data-bs-theme="dark"]  .btn-link,
[data-bs-theme="light"] a, [data-bs-theme="light"] .btn-link {
    color: var(--client-accent);
}
a:hover, .btn-link:hover,
[data-bs-theme="dark"] a:hover,  [data-bs-theme="dark"]  .btn-link:hover,
[data-bs-theme="light"] a:hover, [data-bs-theme="light"] .btn-link:hover {
    color: var(--client-accent-hover);
}

.btn-primary {
    --bs-btn-color: var(--client-on-accent);
    --bs-btn-bg: var(--client-accent);
    --bs-btn-border-color: var(--client-accent);
    --bs-btn-hover-color: var(--client-on-accent);
    --bs-btn-hover-bg: var(--client-accent-hover);
    --bs-btn-hover-border-color: var(--client-accent-hover);
    --bs-btn-active-color: var(--client-on-accent);
    --bs-btn-active-bg: var(--client-accent-hover);
    --bs-btn-active-border-color: var(--client-accent-hover);
    --bs-btn-disabled-color: var(--client-on-accent);
    --bs-btn-disabled-bg: var(--client-accent);
    --bs-btn-disabled-border-color: var(--client-accent);
}
/* Defensive overrides: the local bootstrap.min.css declares the idle,
   hover, active, and disabled states with explicit background-color /
   border-color, bypassing the variable approach above. Re-state directly. */
.btn-primary,
.btn-primary:disabled,
.btn-primary.disabled {
    background-color: var(--client-accent);
    border-color: var(--client-accent);
    color: var(--client-on-accent);
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
    background-color: var(--client-accent-hover);
    border-color: var(--client-accent-hover);
    color: var(--client-on-accent);
}

/* Form controls: radios, checkboxes, switches. Bootstrap's local
   bootstrap.min.css hardcodes a blue checked-state in these rules, so we
   override the checked colour to match the accent. The white check-mark
   SVG inside the input is supplied by Bootstrap; only the input's bg
   colour needs adjusting. */
.form-check-input:checked {
    background-color: var(--client-accent);
    border-color: var(--client-accent);
}
.form-check-input:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--client-accent);
    box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--client-accent) 25%, transparent);
}

/* In mono dark, the form-switch's ON-state track is light gray and the
   default thumb SVG fills white — the two merge. Override --bs-form-switch-bg
   (the data-URI Bootstrap reads as the thumb) with a dark-filled circle so
   the thumb pops against the light track. Same idea as buttons using
   --client-on-accent on accent surfaces. */
:root[data-accent="mono"][data-bs-theme="dark"] .form-switch .form-check-input:checked {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%231f2333'/%3e%3c/svg%3e");
}
/* Native fallback (browser-rendered input/select widgets, range, etc.) */
input, select, textarea, progress {
    accent-color: var(--client-accent);
}

/* Accent-coloured badge — used for the My Requests counter pills in both
   the sidebar and the access-requests tabs. */
.badge.bg-accent {
    background-color: var(--client-accent) !important;
    color: var(--client-on-accent) !important;
}

/* .text-bg-primary defaults to white text on --bs-primary; under mono
   dark that's white on light-gray and unreadable. Reroute the foreground
   through --client-on-accent so the primary-owner badge stays legible
   in every preset/theme combination. */
.text-bg-primary {
    background-color: var(--client-accent) !important;
    color: var(--client-on-accent) !important;
}

/* Audit-log badges. Bootstrap's text-bg-info defaults to cyan and
   text-bg-warning to amber, both of which clash with the accent palette
   (the rest of the chrome is pink/purple). Re-theme so every audit
   badge sits in the same family as --client-accent. Three semantic
   axes: lifecycle (neutral-tinted), content (accent), request (warning
   pulled toward accent). */
.text-bg-secondary {
    background-color: color-mix(in srgb, var(--client-accent) 18%, var(--bs-tertiary-bg)) !important;
    color: var(--bs-body-color) !important;
}

.text-bg-info {
    background-color: color-mix(in srgb, var(--client-accent) 65%, transparent) !important;
    color: var(--client-on-accent) !important;
}

.text-bg-warning {
    background-color: color-mix(in srgb, var(--client-accent) 35%, #b58a00) !important;
    color: var(--client-on-accent) !important;
}

/* Owner row pending removal on the ManageS2SApp page — show the existing
   row struck through and dimmed so the user can see what will be removed
   without losing the original context. The X button toggles the state. */
.owner-row-removed .form-control,
.owner-row-removed .form-select { text-decoration: line-through; opacity: .55; }
.owner-row-removed .form-label { opacity: .55; }

/* Accent-preset chips use Bootstrap-icons: bi-circle-half for Mono and
   bi-circle-fill for Vivid / Blue. Fill colour mirrors the accent the
   preset will actually apply in the current theme, so what you see in
   the swatch matches what you'll get after picking it. */
.swatch-vivid { color: #c85ab4; }          /* vivid magenta (dark theme) */
[data-bs-theme="light"] .swatch-vivid { color: #5a3eed; }  /* vivid indigo (light theme) */
.swatch-blue  { color: #2a78d6; }          /* blue (same in both themes) */
[data-bs-theme="light"] .swatch-blue  { color: #2a78d6; }

/* Bootstrap's outline buttons re-declare --bs-btn-* variables on the
   selector, so the global --bs-primary override doesn't reach them.
   Re-declare here so View / Edit and similar .btn-outline-primary
   buttons follow the accent. */
.btn-outline-primary,
.btn-outline-primary-noborder {
    --bs-btn-color: var(--client-accent);
    --bs-btn-border-color: var(--client-accent);
    --bs-btn-hover-color: var(--client-on-accent);
    --bs-btn-hover-bg: var(--client-accent);
    --bs-btn-hover-border-color: var(--client-accent);
    --bs-btn-active-color: var(--client-on-accent);
    --bs-btn-active-bg: var(--client-accent);
    --bs-btn-active-border-color: var(--client-accent);
    --bs-btn-disabled-color: var(--client-accent);
    --bs-btn-disabled-border-color: var(--client-accent);
}

/* Light-mode only: Quill's content area inherits the page surface so it
   blends into the main panel. Lift it to white (matches form-control and
   access-list items) so the secret body reads as a distinct card. Dark
   mode is left alone — looks good as-is. */
[data-bs-theme="light"] .ql-container.ql-snow,
[data-bs-theme="light"] .ql-toolbar.ql-snow,
[data-bs-theme="light"] #quill-toolbar,
[data-bs-theme="light"] #quill-editor-container,
[data-bs-theme="light"] .ql-editor {
    background-color: #ffffff;
}

/* The search-result rows reuse Bootstrap text-primary for the secondary
   pin button; make sure that one follows the accent too. */
.itemsearch-dialog-list .text-primary,
.itemsearch-dialog-list-pinned .text-primary { color: var(--client-accent) !important; }

/* When a result row is hovered or selected, the row's background becomes
   the accent. The inner pin button (text-primary by default) would then
   merge into the background — flip it to white so the star stays visible,
   matching the row's foreground text. */
.btn-outline-primary-noborder:hover .btn-link,
.btn-outline-primary-noborder:focus .btn-link,
.btn-outline-primary-noborder.active .btn-link {
    color: var(--client-on-accent) !important;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

.text-removed {
    background-color: pink !important;
    text-decoration-line: line-through !important;
}

.collapsible-content > .btn {
    padding: .25rem .5rem;
    font-weight: 600;
    background-color: transparent;
    border: 0
}

    .collapsible-content > .btn > i {
        transition: transform 0.35s ease;
    }

@media (prefers-reduced-motion: reduce) {
    .collapsible-content > .btn > i {
        transition: none
    }
}

.collapsible-content > .btn[aria-expanded="true"] > i {
    transform: rotate(90deg)
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* ===== Accent presets =====
   Default (no data-accent attribute) = "Blue" (matches the base :root
   below, so first-paint before JS sets data-accent is still blue).
   Override via <html data-accent="blue|vivid|mono">; only the accent
   variables change. --client-strip-a / --client-strip-b stay locked to
   the brand magenta↔indigo wash regardless of the user's pick. */

:root[data-accent="vivid"] {
    --client-accent: #c85ab4;
    --client-accent-hover: #d883c5;
    --client-on-accent: #ffffff;
    --bs-primary: #c85ab4;
    --bs-primary-rgb: 200, 90, 180;
    --bs-link-color: #c85ab4;
    --bs-link-color-rgb: 200, 90, 180;
    --bs-link-hover-color: #d883c5;
    --bs-link-hover-color-rgb: 216, 131, 197;
}
:root[data-accent="vivid"][data-bs-theme="light"] {
    --client-accent: #5a3eed;
    --client-accent-hover: #7c5cff;
    --bs-primary: #5a3eed;
    --bs-primary-rgb: 90, 62, 237;
    --bs-link-color: #5a3eed;
    --bs-link-color-rgb: 90, 62, 237;
    --bs-link-hover-color: #7c5cff;
    --bs-link-hover-color-rgb: 124, 92, 255;
}

:root[data-accent="blue"] {
    --client-accent: #2a78d6;
    --client-accent-hover: #4a91e6;
    --client-on-accent: #ffffff;
    --bs-primary: #2a78d6;
    --bs-primary-rgb: 42, 120, 214;
    --bs-link-color: #2a78d6;
    --bs-link-color-rgb: 42, 120, 214;
    --bs-link-hover-color: #4a91e6;
    --bs-link-hover-color-rgb: 74, 145, 230;
}
:root[data-accent="blue"][data-bs-theme="light"] {
    --client-accent: #2a78d6;
    --client-accent-hover: #4a91e6;
    --bs-primary: #2a78d6;
    --bs-primary-rgb: 42, 120, 214;
    --bs-link-color: #2a78d6;
    --bs-link-color-rgb: 42, 120, 214;
    --bs-link-hover-color: #4a91e6;
    --bs-link-hover-color-rgb: 74, 145, 230;
}

:root[data-accent="mono"] {
    --client-accent: #cbd5e1;
    --client-accent-hover: #e2e8f0;
    /* Light gray accent + white labels would be invisible — flip
       on-accent to near-black for the mono dark case. */
    --client-on-accent: #1f2333;
    --bs-primary: #cbd5e1;
    --bs-primary-rgb: 203, 213, 225;
    --bs-link-color: #cbd5e1;
    --bs-link-color-rgb: 203, 213, 225;
    --bs-link-hover-color: #e2e8f0;
    --bs-link-hover-color-rgb: 226, 232, 240;
}
:root[data-accent="mono"][data-bs-theme="light"] {
    --client-accent: #475569;
    --client-accent-hover: #64748b;
    --bs-primary: #475569;
    --bs-primary-rgb: 71, 85, 105;
    --bs-link-color: #475569;
    --bs-link-color-rgb: 71, 85, 105;
    --bs-link-hover-color: #64748b;
    --bs-link-hover-color-rgb: 100, 116, 139;
}

/* ===== Main PWA shell (admin-panel style, indigo accent) ===== */

:root {
    /* Default accent = Blue. Vivid/Mono presets override via
       :root[data-accent="…"] below. Keeping the base :root in sync
       with [data-accent="blue"] means the first paint (before JS
       gets a chance to set data-accent from localStorage) is already
       the right colour and we avoid a flash of the wrong accent. */
    --client-accent: #2a78d6;
    --client-accent-hover: #4a91e6;
    /* Foreground on accent surfaces (button labels, badge text). White
       reads well on the blue/vivid accents; flipped to near-black under
       mono dark where the accent is too light for white to read against. */
    --client-on-accent: #ffffff;
    /* Animated topbar strip colors — kept vivid regardless of accent. */
    --client-strip-a: #d943c1;
    --client-strip-b: #7c5cff;
    --client-nav-active-bg: rgba(255, 255, 255, .12);   /* neutral lighten on dark surface */
    --client-surface: #11141c;
    --client-surface-2: #1a1d28;
    --client-border: #2a2f3d;
    --client-text: #d8dbe6;
    --client-text-muted: #8a90a3;
    --client-topbar-h: 56px;
    --client-nav-w: 240px;

    /* Bring Bootstrap's primary/link variables in line with the accent. */
    --bs-primary: #cbd5e1;
    --bs-primary-rgb: 203, 213, 225;
    --bs-link-color: #cbd5e1;
    --bs-link-color-rgb: 203, 213, 225;
    --bs-link-hover-color: #e2e8f0;
    --bs-link-hover-color-rgb: 226, 232, 240;
}

:root[data-bs-theme="light"] {
    --client-accent: #475569;
    --client-accent-hover: #64748b;
    --client-on-accent: #ffffff;
    --client-strip-a: #5a3eed;
    --client-strip-b: #b1219c;
    --client-nav-active-bg: rgba(0, 0, 0, .10);         /* neutral darken on light surface */
    --client-surface: #f6f7fb;
    --client-surface-2: #ffffff;
    --client-border: #d8dbe4;
    --client-text: #1f2333;
    --client-text-muted: #5b6275;

    --bs-primary: #475569;
    --bs-primary-rgb: 71, 85, 105;
    --bs-link-color: #475569;
    --bs-link-color-rgb: 71, 85, 105;
    --bs-link-hover-color: #64748b;
    --bs-link-hover-color-rgb: 100, 116, 139;
}

.client-shell {
    /* Lock the shell to the viewport so the sidebar and topbar stay put;
       .client-main owns its own scrolling via overflow-y: auto below.
       dvh adapts to mobile browser chrome (URL bar) where supported. */
    height: 100vh;
    height: 100dvh;
    background-color: var(--client-surface);
    color: var(--client-text);
    display: grid;
    grid-template-columns: var(--client-nav-w) 1fr;
    grid-template-rows: var(--client-topbar-h) 1fr;
    grid-template-areas: "topbar topbar" "nav main";
    overflow: hidden;
}

.client-topbar {
    grid-area: topbar;
    background: var(--client-surface-2);
    border-bottom: 1px solid var(--client-border);
    display: grid;
    grid-template-columns: var(--client-nav-w) 1fr auto;
    align-items: center;
    /* No left padding here: the brand cell handles its own padding so the
       state-header column starts exactly at the sidebar's right edge. */
    padding: 0 1rem 0 0;
    position: sticky;
    top: 0;
    z-index: 20;
}
.client-topbar::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -3px;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--client-strip-a) 0%,
        var(--client-strip-b) 50%,
        var(--client-strip-a) 100%);
    background-size: 200% 100%;
    animation: client-accent-shift 9s linear infinite;
    z-index: 21;
    pointer-events: none;
}
@keyframes client-accent-shift {
    0%   { background-position:   0% 50%; }
    100% { background-position: 200% 50%; }
}
@media (prefers-reduced-motion: reduce) {
    .client-topbar::after { animation: none; }
}

.client-brand {
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--client-text);
    padding-left: 1rem;
}

.client-state-header {
    color: var(--client-text);
    font-weight: 500;
    padding-left: 1rem;
    border-left: 1px solid var(--client-border);
}

/* Container for the LoginDisplay component. Wrapping it in a single grid
   child prevents the dropdown-menu sibling from claiming its own grid
   cell and pushing the icon onto a second row. */
.client-login-wrap { position: relative; display: flex; align-items: center; }

.client-hamburger {
    background: transparent;
    color: var(--client-text);
    border: 1px solid var(--client-border);
    border-radius: 6px;
    padding: 4px 10px;
    display: none;
    line-height: 1;
}
.client-hamburger i { font-size: 1.25rem; }

.client-nav {
    grid-area: nav;
    background: var(--client-surface-2);
    border-right: 1px solid var(--client-border);
    padding: 1rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

/* Nav links: always render in the regular text color regardless of the
   global a, .btn-link accent. Active state is communicated through font
   weight, not color or background. */
.client-nav .client-nav-link,
.client-nav .client-nav-link:hover,
.client-nav .client-nav-link:focus,
.client-nav .client-nav-link.active,
.client-nav a.client-nav-link {
    color: var(--client-text);
    text-decoration: none;
}
.client-nav-link {
    padding: .55rem .85rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .95rem;
    line-height: 1.2;
    font-weight: 400;
}
.client-nav-link i { font-size: 1.1rem; }
.client-nav-link:hover { background: rgba(127, 127, 127, .12); }
.client-nav-link.active { background: var(--client-nav-active-bg); font-weight: 700; }

.client-nav-sep {
    border: 0;
    border-top: 1px solid var(--client-border);
    margin: .5rem .25rem;
}

.client-main { grid-area: main; overflow-y: auto; }
.client-main .content {
    color: var(--client-text);
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}
.client-main .container-md { max-width: 1100px; }

.client-nav-scrim { display: none; }

@media (max-width: 720px) {
    .client-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "topbar" "main";
    }
    .client-topbar {
        display: flex;
        gap: .75rem;
        padding: 0 1rem;
    }
    .client-brand { padding-left: 0; }
    .client-hamburger { display: inline-flex; align-items: center; }
    .client-state-header { display: none; }
    /* Mobile topbar is flex (not grid) with gap, so without an explicit
       push the user-icon column sits right after the brand. margin-left:
       auto consumes the remaining row to pin the login menu to the right
       edge — matching the desktop grid layout where the third column
       was already pinned via grid-template-columns. */
    .client-login-wrap { margin-left: auto; }
    .client-main .content,
    .client-main .container-md { max-width: 100%; }
    .client-nav {
        position: fixed;
        top: var(--client-topbar-h);
        left: 0;
        bottom: 0;
        width: 78%;
        max-width: 320px;
        transform: translateX(-100%);
        transition: transform .18s ease-out;
        z-index: 19;
    }
    .client-nav.open { transform: translateX(0); }
    .client-nav-scrim {
        display: block;
        position: fixed;
        top: var(--client-topbar-h);
        left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,.45);
        z-index: 18;
    }
}
