/* https://codepen.io/kevinpowell/pen/KKEevOp */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,100..1000&display=swap");

:root {
    --rev-frost: #a7c8d3;
    --rev-mist: #8da9d7;
    --rev-h2o: #3d6bb5;
    /* h2o lifted for the dark surface (4.6:1 on plate), fixed in both themes; auth accent (button, links) in dark */
    --rev-h2o-lifted: #4b82cc;
    --rev-denim: #002446;
    /* the real brand denim in both themes (dark overrides --rev-denim); auth brand panel */
    --rev-denim-brand: #002446;
    --rev-plate: #0f192d;
    --rev-dawn: #fdfaf5;
    --rev-oat: #f2ebe0;
    /* the real brand oat in both themes (dark overrides --rev-oat); auth brand panel logo */
    --rev-oat-brand: #f2ebe0;
    --rev-linen: #c4baad;
    --rev-white: #fff;
    --rev-border: color-mix(in srgb, var(--rev-plate) 10%, transparent);
    --rev-border-10: color-mix(in srgb, var(--rev-plate) 12%, transparent);
    --rev-ylw: rgb(227, 169, 79);
    --fav-color: #ffb700;
    --rev-blue: #07bafe;
    --rev-blue2: #c3e9fa;
    --rev-blue-light: #e2f2f4;
    --rev-blue-light2: #f1fafe;
    --rev-red: #f22f46;
    --rev-red-100: #fef2f2;
    --rev-red-200: #f6cfcf;
    --rev-green: #00d98e;
    --rev-green-100: #f0fbf6;
    --rev-green-200: #c7efdd;
    --rev-green-400: #10b981;
    --rev-orange-100: #fffbef;
    --rev-orange-200: #fbe6bd;
    --rev-orange-800: #c98a00;
    --rev-gray: #f8fafb;
    /* only for the commented-out utilities of the unrendered contacts/import_new_contacts.blade.php
    --rev-dark-blue-100: #e9f6fd;
    --rev-dark-blue-400: #0277b5;
    --rev-orange-150: #fff7e2;
    --rev-gray-300: #fcfdfe;
    --danger-dark: #7e121d;
    */

    --ff: "DM Sans", sans-serif;

    --bg-body: var(--rev-white);
    --text-body: var(--rev-plate);
    --bg-sidebar: var(--rev-denim);
    --clr-sidebar: #aab9d4;
    --bg-chat: light-dark(#efefef,
            color-mix(in srgb, var(--rev-plate) 5%, transparent));

    --sidebar-width: 0px;
    --submenu-sidebar-width: 0px;

    /* muted helper text; .credit-strip still defines its own --muted locally */
    --muted: color-mix(in srgb, var(--on-surface) 60%, transparent);

    /* <select> arrow (replaces img/angle-down.png). Data URIs cannot read CSS variables,
       so the stroke is the literal --rev-plate value; the dark theme swaps in an oat arrow */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%230f192d' stroke-opacity='0.6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    /* emoji-mart picker colours. The library builds its colours as rgba(var(--rgb-*), a), so these must be bare
       "r, g, b" channels, not colours; custom properties inherit into the picker's shadow DOM, so every picker
       follows the theme switcher live. Light keeps the picker's original grey/white look. */
    --emoji-rgb-background: 247, 247, 247;
    /* nav / header strip */
    --emoji-rgb-input: 255, 255, 255;
    /* emoji grid + search */
    --emoji-rgb-border: 219, 229, 234;
    --emoji-rgb-color: 97, 98, 100;
    /* labels, category icons */
    --emoji-rgb-accent: 0, 122, 255;
}

/*
 * Theme is chosen by the topbar switcher (theme/theme-switcher) and set on <html>:
 *   data-theme-preference = light | dark | auto   (what the user picked, saved in localStorage "rt-theme")
 *   data-theme            = light | dark          (what is applied; "auto" resolves via prefers-color-scheme)
 * color-scheme drives every light-dark() call and native controls (scrollbars, inputs).
 */
:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --rev-frost: var(--rev-border);
    --rev-oat: #d0e2f9;
    /* h2o (secondary) for dark: balanced so it works both as text on the dark surface (4.3:1)
       and as a button fill under white text (4.1:1); #2467d5 was 3.3:1 as text */
    --rev-h2o: #3b7ae6;
    /* --rev-denim: #33517a; */
    --rev-denim: #1c57a7;
    /* focus ring (login handoff: mist in dark); dark-mode primary (denim) is under 3:1 on the dark surface */
    --focus-ring: var(--rev-mist);
    /* text links (login handoff: mist in dark) */
    --link-color: var(--rev-mist);
    --rev-plate: #0f192d;

    --rev-border: #273249;
    --rev-border-10: #1e2d47;
    /* success / danger tuned for dark: white text on them >= 4.5:1, and >= 3.8:1 against the dark surface */
    --rev-green-400: #01a870;
    --rev-red: #dc3248;
    /* pale tints (-100 / -150 / -200, light blues, greys) are near-white in light mode, which glares on the dark
       surface; in dark they become low-strength tints of the same hue so badges and info rows keep their meaning */
    --rev-blue2: color-mix(in srgb, var(--rev-h2o) 25%, transparent);
    --rev-blue-light: color-mix(in srgb, var(--rev-h2o) 16%, transparent);
    --rev-blue-light2: color-mix(in srgb, var(--rev-h2o) 12%, transparent);
    --rev-red-100: color-mix(in srgb, var(--rev-red) 14%, transparent);
    --rev-red-200: color-mix(in srgb, var(--rev-red) 25%, transparent);
    --rev-green-100: color-mix(in srgb, var(--rev-green-400) 16%, transparent);
    --rev-green-200: color-mix(in srgb, var(--rev-green-400) 28%, transparent);
    --rev-orange-100: color-mix(in srgb, var(--fav-color) 10%, transparent);
    --rev-orange-200: color-mix(in srgb, var(--fav-color) 24%, transparent);
    --rev-orange-800: #fcb718;
    --rev-gray: color-mix(in srgb, var(--rev-oat) 4%, transparent);
    /* only for the commented-out utilities of the unrendered contacts/import_new_contacts.blade.php
    --rev-dark-blue-100: color-mix(in srgb, var(--rev-h2o) 16%, transparent);
    --rev-dark-blue-400: #4ea3e0;
    --rev-orange-150: color-mix(in srgb, var(--fav-color) 14%, transparent);
    --rev-gray-300: color-mix(in srgb, var(--rev-oat) 3%, transparent);
    */
    --bg-sidebar: #131f39;
    --text-body: var(--rev-oat);
    /* headings brighter than body text (dawn vs oat) so heading and description read apart */
    --text-heading: var(--rev-dawn);
    --bg-body: #0b1322;
    --surface: var(--rev-plate);
    --on-surface: var(--rev-oat);
    /* <select> arrow in the dark-theme oat (#d0e2f9) */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23d0e2f9' stroke-opacity='0.7' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    /* modal backdrop: the page colour (darker than --dark/plate here), strong enough to flatten cards and sidebar behind it */
    --backdrop-color: var(--bg-body);
    --backdrop-opacity: 0.75;
    /* tooltip: the light-theme dark bubble vanishes on the dark page, so use a light bubble (dawn) with plate text */
    --tooltip-bg: var(--rev-dawn);
    --tooltip-color: var(--rev-plate);
    /* form controls: opaque fill lifted above the lightest dark panel (--bg-sidebar, used by card headers),
       so inputs/selects stand out on headers (1.36:1) and cards (1.45:1); border 30% for a clear edge */
    --control-border: var(--rev-border);
    /* checkbox / radio / switch fill: primary (denim) is too dark on the dark surface, use secondary (h2o) */
    --check-color: var(--rev-h2o);
    --neutral-percentage: 25%;
    /* dark neutral text: fixed OKLCH lightness + chroma boost of the real colour (hue kept, no oat mixing) */
    --neutral-text-lightness: 0.82;
    --neutral-text-chroma: 1.3;
    /* neutral btn border: 35% of the text colour, so the button edge shows on the dark page */
    --neutral-border-percentage: 35%;
    /* emoji-mart picker in dark: the channels of --bg-sidebar (strip), --rev-plate/--surface (grid),
       a light edge (≈ oat 25% over the surface) that separates the picker from the card behind it,
       --rev-oat (text) and --rev-h2o (accent) */
    --emoji-rgb-background: 19, 31, 57;
    --emoji-rgb-input: 15, 25, 45;
    --emoji-rgb-border: 63, 75, 96;
    --emoji-rgb-color: 208, 226, 249;
    --emoji-rgb-accent: 59, 122, 230;
}

/*
 * Neutral buttons / backgrounds use one recipe in Bootstrap for both themes
 * (real-colour tint, OKLCH text, border); the dark block above only changes
 * --neutral-percentage, --neutral-text-lightness, --neutral-text-chroma and --neutral-border-percentage.
 */

/* light-variant neutrals force dark text for light mode; in dark mode use the lifted colour instead */
:root[data-theme="dark"] .btn-neutral-light {
    --btn-neutral-text: initial;
}

:root[data-theme="dark"] .bg-neutral-light {
    --bg-neutral-text: initial;
}

/* neutral info in dark: mist (#8da9d7) is a pale, low-chroma blue, so its 25% tint and lifted text read as grey
   and the button / badge vanished on dark panels (card headers). Give the neutral recipe a brighter, more
   saturated mist (same hue) in dark only; solid / outline info buttons keep the real --info. */
:root[data-theme="dark"] .btn-neutral-info {
    --btn-color: oklch(from var(--info) 0.8 calc(c * 2.4) h);
    /* text a step brighter than the shared neutral recipe (0.82), so the icon / label stands out on the tint */
    --btn-neutral-text: oklch(from var(--info) 0.9 calc(c * 2.4) h);
}

:root[data-theme="dark"] .bg-neutral-info {
    --bg-color: oklch(from var(--info) 0.8 calc(c * 2.4) h);
    --bg-neutral-text: oklch(from var(--info) 0.9 calc(c * 2.4) h);
}

/* "dark" variant in dark: --dark is the plate colour, the same as --surface, so every dark button / badge
   vanished on cards (fill 1.2:1, outline text 1.06:1). Dark mode swaps in a slate lifted from the surface for
   the solid button, the light text colour for the outline (its hover fill then takes dark text), and a 60% text
   colour as the tint for the neutral recipe (button, badge, avatar; the full text colour made the active tint so
   light the label dropped to 2.9:1). Measured on a dark card: label 6–9:1, active 5–9:1. Light mode is unchanged. */
:root[data-theme="dark"] .btn-dark {
    --btn-color: color-mix(in srgb, var(--on-surface) 28%, var(--surface));
    --btn-text: var(--on-surface);
    /* hover / active mix toward the page instead of white, so the light label keeps its contrast */
    --btn-mix: var(--surface);
}

:root[data-theme="dark"] .btn-outline-dark {
    --btn-color: color-mix(in srgb, var(--on-surface) 80%, var(--surface));
    --btn-text: var(--surface);
}

:root[data-theme="dark"] .btn-neutral-dark {
    --btn-color: color-mix(in srgb, var(--on-surface) 60%, var(--surface));
}

:root[data-theme="dark"] .bg-neutral-dark {
    --bg-color: color-mix(in srgb, var(--on-surface) 60%, var(--surface));
}

/* outline primary in dark: the denim text read 2.6:1 on the dark card; lifted to 5:1, like .btn-outline-secondary.
   The hover / active fill uses the same colour (white label 3.7:1, outline-secondary is 4.1:1). */
:root[data-theme="dark"] .btn-outline-primary {
    --btn-color: oklch(from var(--primary) 0.62 calc(c * 1.15) h);
}

/* headers painted --bg-sidebar in dark (card header, template picker header, chat header): controls on them
   (inputs, select2) blend in, so their border is raised to 30% */
:root[data-theme="dark"] .card-header,
:root[data-theme="dark"] .template-modal__header,
:root[data-theme="dark"] .chat-page-wrap .rightPart .chat-header {
    /* --control-bg: color-mix(in srgb, var(--on-surface) 12%, var(--bg-sidebar)); */
    --control-border: color-mix(in srgb, var(--on-surface) 30%, transparent);
}

/* folder-create step body (create template folder pages): inputs blended into it, so they get the option tiles'
   soft h2o 8% fill and a quiet light edge (on-surface 20%; an h2o edge read too blue) */
:root[data-theme="dark"] .folder-create-step-card__body {
    --control-border: color-mix(in srgb, var(--on-surface) 20%, transparent);
    --control-bg: color-mix(in srgb, var(--rev-h2o) 8%, var(--surface));
}

/* dark modal: a thin light edge so the panel separates from the darkened page */
:root[data-theme="dark"] .modal-content {
    border: 1px solid color-mix(in srgb, var(--on-surface) 12%, transparent);
}

/* modal form controls (input, select, textarea, select2): the panel and the default control fill are both
   --surface, so fields blended in. Light keeps the plain white field (--surface) and relies on the stronger edge;
   dark sets the field into the panel with the page colour (--bg-body, darker than the plate panel);
   both with an on-surface 18% edge, a step above the default border but no glow */
.modal-content {
    --control-bg: light-dark(var(--surface), var(--bg-body));
    --control-border: color-mix(in srgb, var(--on-surface) 18%, transparent);
}

/*
 * Custom-drawn checkboxes in dark mode (the browser paints the unchecked box almost black there,
 * and accent-color only reaches the checked state). :where() keeps specificity at 0,
 * so page rules that size checkboxes still win.
 * Bootstrap .custom-control inputs (checkbox, radio, switch) have their own styling and are skipped.
 * Table checkboxes used to be drawn here in both themes too; they are Bootstrap .custom-control now,
 * so the `table input[type="checkbox"]` selector is commented out below.
 */
:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where(:not(.custom-control-input)) {
    -webkit-appearance: none;
    appearance: none;
    display: inline-grid;
    place-content: center;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
    /* currentColor: the box contrasts with whatever text colour its cell uses (light or dark header/row) */
    border: 1.5px solid color-mix(in srgb, currentColor 55%, transparent);
    border-radius: 0.25rem;
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 80%;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where(:not(.custom-control-input)):hover {
    border-color: var(--check-color);
}

:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where(:not(.custom-control-input)):checked {
    border-color: var(--check-color);
    background-color: var(--check-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where( :not(.custom-control-input)):indeterminate {
    border-color: var(--check-color);
    background-color: var(--check-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}

:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where( :not(.custom-control-input)):focus-visible {
    outline: 2px solid color-mix(in srgb, var(--check-color) 60%, transparent);
    outline-offset: 2px;
}

:where( :root[data-theme="dark"] input[type="checkbox"]

    /* , table input[type="checkbox"] */
):where(:not(.custom-control-input)):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dark mode on campaign / contact-import pages (.champain-main-block):
   denim text and white / oat utility backgrounds were picked for light mode only */
:root[data-theme="dark"] .champain-main-block .text-rev-blue {
    color: oklch(from var(--secondary) 0.8 calc(c * 1.15) h);
}

:root[data-theme="dark"] .champain-main-block .bg-white {
    background-color: var(--surface) !important;
}

:root[data-theme="dark"] .champain-main-block .bg-light {
    background-color: color-mix(in srgb,
            var(--on-surface) 6%,
            transparent) !important;
}