/* === Core tokens (safe defaults; can be overridden by --t-* via theme adapter) === */
:root {
    --ring: var(--t-ring, #222c45);
    --text: var(--t-text, #e5e9f0);
    --muted: var(--t-text-muted, #9aa4b2);
    --acc: var(--t-brand, #6ecbff);
    --acc-soft: var(--t-brand-soft, rgba(110,203,255,.16));
    --tile-accent: var(--t-bg-surface-2, #263a50);
}

/* === Accent via data-attribute ===
   These name what the colour *means*, not which hue it is. See the Accent enum in
   AthanSync.Core/Enums.cs for why: the previous hue names (electric/amber/cyan/teal/...)
   had to be translated back into meanings separately by each app, and the three apps
   disagreed — so the same enum member rendered three different colours.

   Fallbacks keep this file standalone; the theme layers override --t-* per theme. */
[data-accent="brand"] {
    --acc:      var(--t-brand, #6ecbff);
    --acc-soft: var(--t-brand-soft, rgba(110,203,255,.16));
}

[data-accent="success"] {
    --acc:      var(--t-success, #52e28b);
    --acc-soft: var(--t-success-soft, rgba(82,226,139,.16));
}

[data-accent="danger"] {
    --acc:      var(--t-danger, #ff6b6b);
    --acc-soft: var(--t-danger-soft, rgba(255,107,107,.16));
}

[data-accent="warning"] {
    --acc:      var(--t-warn, #f8b84c);
    --acc-soft: var(--t-warn-soft, rgba(248,184,76,.16));
}

[data-accent="info"] {
    --acc:      var(--t-info, #22d3ee);
    --acc-soft: var(--t-info-soft, rgba(34,211,238,.16));
}

[data-accent="muted"] {
    --acc:      var(--t-text-muted, #7b8697);
    --acc-soft: rgba(123,134,151,.10);
    --text:     var(--t-text-muted, #a3abb8);
    --ring:     var(--t-panel-border, #2a3346);
}

/* === Shared control row shell === */
.ctl-row {
    display: grid;
    /* The right column had no floor, so a preferred width (--DDL_RIGHT, or max-content) was
       honored even past the row's own edge instead of shrinking to fit — the control appeared
       to push right and spill over the container border. minmax(0, ...) lets it compress first. */
    grid-template-columns: minmax(220px,1fr) minmax(0, var(--DDL_RIGHT, max-content));
    align-items: center;
    column-gap: clamp(8px,2vw,24px);
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--ctl-row-border, var(--ring));
    background: var(--ctl-row-bg, var(--t-panel-bg, rgba(255,255,255,.02)));
}

.ctl-row.no-border {
    border: none;
    background: transparent;
    padding: 0;
}

/* Left cluster */
.ctl-row__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ctl-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--ctl-icon-bg, var(--t-bg-surface-2, rgba(255,255,255,.06)));
    border: 1px solid var(--ctl-icon-border, var(--t-panel-border, rgba(255,255,255,.06)));
    font-size: 1.25rem;
    color: var(--acc);
}

.ctl-titles {
    min-width: 0;
}

.ctl-name {
    color: var(--text);
    font-weight: 800;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctl-hint {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right cluster */
.ctl-row__right {
    justify-self: end;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
    column-gap: 12px;
}

/* Generic dropdown nice defaults */
.ctl-row .dropdown-menu {
    width: clamp(72px, 8vw, 240px);
    min-width: clamp(72px, 8vw, 160px);
    background-image: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
    background-color: var(--t-bg-elevated, #0a0f1a);
    border: 1px solid var(--t-panel-border, var(--ring));
    border-radius: 12px;
    padding: .5rem;
    margin-top: .35rem;
    box-shadow: 0 14px 32px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.03);
    max-height: none;
    overflow: visible;
    z-index: 1056;
}

.ctl-row .dropdown-item {
    color: var(--t-text, var(--text));
    font-weight: 800;
    border-radius: .5rem;
    text-align: left;
    font-variant-numeric: tabular-nums;
    padding: .4rem .5rem;
}

.ctl-row .dropdown-item:hover,
.ctl-row .dropdown-item:focus {
        background: var(--acc-soft);
        color: var(--text);
    }

/* === Shared slider visuals (used by UiSlider + SimpleSlider) === */
.slider-track,
.ss-range {
    --slider-track-h: 12px;
    --slider-thumb: 24px;
    --slider-thumb-ring: 2px;
    --slider-track-bg: var(--acc-soft, rgba(110,203,255,.16));
    --slider-track-brd: color-mix(in oklab, var(--acc, #7db4ff) 35%, var(--t-panel-border, rgba(255,255,255,.18)));
    --slider-track-hover: color-mix(in oklab, var(--acc-soft, rgba(110,203,255,.16)) 85%, var(--t-bg-elevated, rgba(255,255,255,.14)));
    --slider-thumb-bg: var(--acc, #7db4ff);
    --slider-thumb-brd: rgba(0,0,0,.35);
    --track-sheen: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
    --track-sheen-hover: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: var(--slider-track-h);
    border-radius: 9999px;
    outline: 0;
    margin: 0;
    padding: 0;
    background: var(--track-sheen), var(--slider-track-bg);
    border: 1px solid var(--slider-track-brd);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
    accent-color: var(--acc, #1f6feb);
}

.slider-track:hover,
.ss-range:hover {
    background: var(--track-sheen-hover), var(--slider-track-hover);
}

.slider-track.has-fill,
.ss-range.has-fill {
    background: linear-gradient(90deg, var(--acc, #1f6feb) 0 0) 0 / var(--fill, 0%) 100% no-repeat, var(--track-sheen), var(--slider-track-bg);
}

.slider-track.has-fill:hover,
.ss-range.has-fill:hover {
    background: linear-gradient(90deg, var(--acc, #1f6feb) 0 0) 0 / var(--fill, 0%) 100% no-repeat, var(--track-sheen-hover), var(--slider-track-hover);
}

.slider-track::-webkit-slider-runnable-track,
.ss-range::-webkit-slider-runnable-track {
    background: transparent;
    border: none;
    height: var(--slider-track-h);
    border-radius: 9999px;
}

.slider-track::-webkit-slider-thumb,
.ss-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--slider-thumb);
    height: var(--slider-thumb);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), rgba(255,255,255,.08) 35%, transparent 36%), var(--slider-thumb-bg);
    border: var(--slider-thumb-ring) solid var(--slider-thumb-brd);
    box-shadow: 0 2px 8px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.12);
    margin-top: calc((var(--slider-track-h) - var(--slider-thumb))/2);
    cursor: pointer;
}

.slider-track::-moz-range-track,
.ss-range::-moz-range-track {
    height: var(--slider-track-h);
    background: var(--track-sheen), var(--slider-track-bg);
    border: 1px solid var(--slider-track-brd);
    border-radius: 9999px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}

.slider-track::-moz-range-thumb,
.ss-range::-moz-range-thumb {
    width: var(--slider-thumb);
    height: var(--slider-thumb);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), rgba(255,255,255,.08) 35%, transparent 36%), var(--slider-thumb-bg);
    border: var(--slider-thumb-ring) solid var(--slider-thumb-brd);
    box-shadow: 0 2px 8px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.12);
    cursor: pointer;
}

.slider-track.has-fill::-moz-range-progress,
.ss-range.has-fill::-moz-range-progress {
    height: var(--slider-track-h);
    border-radius: 9999px 0 0 9999px;
    background: var(--acc, #1f6feb);
}

/* F36: was an arbitrary 720px, now Bootstrap's `md`. This is the grid behind every settings row,
   so it should switch at the same width the rest of the page does rather than 48px earlier. */
@media (max-width: 768px) {
    .ctl-row {
        grid-template-columns: minmax(180px,1fr) minmax(0, var(--DDL_RIGHT, 240px));
    }
}

/* === SEGMENTED CONTROL (shared by TwoState + UiTimePicker AM/PM) === */
.ctl-seg {
    position: relative;
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    isolation: isolate;
    padding: 4px;
    border-radius: 14px;
    background: var(--t-bg-surface-2, rgba(255,255,255,.07));
    border: 1px solid var(--t-panel-border, var(--ring));
    box-shadow: none;
    min-width: 128px;
}

.ctl-seg.flat {
        background: var(--t-bg-surface-2, rgba(255,255,255,.94));
        background: var(--t-bg-surface-2, color-mix(in oklab, var(--acc-soft, rgba(110,203,255,.12)) 24%, rgba(255,255,255,.94)));
        border-color: var(--t-panel-border, rgba(148,163,184,.26));
        box-shadow: none;
    }

    /* hide native radios */
    .ctl-seg input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
        margin: 0;
        inset: auto;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
    }

    .ctl-seg label {
        height: 36px;
        display: grid;
        place-items: center;
        font-weight: 800;
        letter-spacing: .2px;
        color: var(--t-text-muted, var(--muted));
        border-radius: 10px;
        cursor: pointer;
        user-select: none;
        padding: 0 .9rem;
        z-index: 2;
        background: transparent;
    }

    .ctl-seg input:checked + label {
        color: var(--t-text, #fff);
        text-shadow: 0 1px 0 rgba(0,0,0,.16);
    }

    .ctl-seg.flat input:checked + label {
        color: var(--t-text, #fff);
        text-shadow: 0 1px 0 rgba(0,0,0,.16);
    }

    .ctl-seg.flat input:not(:checked) + label {
        color: var(--t-text-muted, color-mix(in oklab, var(--t-text, #1f2937) 64%, transparent));
    }

    .ctl-seg .pill {
        position: absolute;
        top: 4px;
        height: calc(100% - 8px);
        left: 4px;
        width: calc(50% - 4px);
        border-radius: 10px;
        background: var(--acc-soft, rgba(110,203,255,.22));
        background: color-mix(in oklab, var(--acc, #6ecbff) 24%, var(--t-bg-elevated, rgba(255,255,255,.98)));
        border: 1px solid var(--acc, #6ecbff);
        border: 1px solid color-mix(in oklab, var(--acc, #6ecbff) 42%, var(--t-panel-border, rgba(156,192,224,.26)));
        box-shadow: none;
        transition: transform .25s ease;
        z-index: 1;
        transform: translate(var(--pos, 0%), 0);
    }

    /* Labels follow grid direction; anchor the indicator to its selected label's
       grid area so RTL does not invert the highlighted value. */
    .ctl-seg label { grid-row:1; }
    .ctl-seg label:first-of-type { grid-column:1; }
    .ctl-seg label:last-of-type { grid-column:2; }
    .ctl-seg .pill { grid-row:1 / 2;grid-column:1 / 2;inset:0;width:auto;height:auto;transform:none; }
    .ctl-seg input:last-of-type:checked ~ .pill { grid-column:2 / 3; }
    .ctl-seg.xs .pill { inset:0;width:auto;height:auto; }

    .ctl-seg.flat .pill {
        background: var(--acc, #6ecbff);
        background: color-mix(in oklab, var(--acc, #6ecbff) 72%, var(--t-bg-elevated, rgba(255,255,255,.96)));
        border-color: var(--acc, #6ecbff);
        border-color: color-mix(in oklab, var(--acc, #6ecbff) 74%, var(--t-panel-border, rgba(156,192,224,.26)));
        box-shadow: none;
    }

.ctl-seg.sm {
    min-width: 108px;
}

    .ctl-seg.sm label {
        height: 32px;
        padding: 0 .75rem;
    }

.ctl-seg.xs {
    min-width: 104px;
    padding: 3px;
    border-radius: 13px;
}

    .ctl-seg.xs label {
        height: 29px;
        padding: 0 .7rem;
        font-size: .92rem;
    }

    .ctl-seg.xs .pill {
        inset: 0;
        width: auto;
        border-radius: 9px;
    }

/* (optional) small spacing when the segment sits after the minute dropdown) */
.ctl-timepicker .ctl-seg {
    margin-left: 10px;
}

.pill-muted {
    color: var(--t-text-muted, #3a5473);
    border: 1px solid var(--t-panel-border, rgba(108,117,125,.25));
    background: var(--t-bg-surface-2, transparent);
    font-size: .7em;
}

.pill-brand {
    color: var(--t-brand, #d4a853);
    border: 1px solid color-mix(in srgb, var(--t-brand, #d4a853) 28%, var(--t-panel-border, rgba(108,117,125,.25)));
    background: color-mix(in srgb, var(--t-brand-soft, rgba(212,168,83,.18)) 60%, transparent);
    font-size: .7em;
}

/* ═══════════════════════════════════════════════════════════════════
   Mobile-compact overrides (applied via [data-app-mode="mobile"])
   ═══════════════════════════════════════════════════════════════════ */
[data-app-mode="mobile"] .ctl-row {
    padding: 8px 10px;
    border-radius: 12px;
    grid-template-columns: 1fr auto;
}

[data-app-mode="mobile"] .ctl-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 1rem;
}

[data-app-mode="mobile"] .ctl-name {
    font-size: 0.82rem;
}

[data-app-mode="mobile"] .ctl-hint {
    font-size: 0.65rem;
}

/* ── UiSlider: stacked layout on mobile ──────────────────────────────────────────────
   Label-beside-track does not fit a phone. The .ctl-row grid above gives the label column
   a hard floor, so the title and hint both clipped to an ellipsis ("Distance from t...")
   while the track was squeezed under 100px — too short to pick a value with any precision
   — and the readout ended up marooned between the two.

   So on mobile the row becomes two rows: title + value on top, track underneath.
   `display: contents` on both clusters promotes the icon, the titles, the track and the
   readout to grid items of the row itself, which is what lets this be done with no markup
   change — kiosk and the admin portal never set data-app-mode, so they keep the side-by-side
   layout untouched. Placement is by grid area, so it mirrors correctly in RTL.

   The icon gets its own column and the track starts at the *titles* column, not at the row
   edge: a track running under the icon reads as belonging to the row as a whole, while one
   that starts where the label starts reads as that label's value. Giving the icon a real
   column rather than indenting the track by a hardcoded 44px also means the two stay aligned
   if the icon size ever changes. A caller with no Icon leaves that column at zero width, so
   the label and the track simply share the same smaller indent and stay aligned with each
   other.

   These rules are here rather than in UiSlider.razor.css because a scoped stylesheet cannot
   express "inside the mobile shell" — see the note at the top of that file. They must also
   stay *after* the [data-app-mode="mobile"] .ctl-row rule above, which they override at
   equal specificity. */
[data-app-mode="mobile"] .ctl-slider-row {
    grid-template-columns: max-content 1fr max-content;
    grid-template-areas:
        "icon titles value"
        ".    track  track";
    column-gap: 12px;
    row-gap: 12px;
    padding: 10px 12px;
}

[data-app-mode="mobile"] .ctl-slider-row .ctl-row__right,
[data-app-mode="mobile"] .ctl-slider-row .ctl-row__left {
    display: contents;
}

[data-app-mode="mobile"] .ctl-slider-row .ctl-icon {
    grid-area: icon;
}

[data-app-mode="mobile"] .ctl-slider-row .ctl-titles {
    grid-area: titles;
}

/* !important is load-bearing: UiSlider's SliderWidth parameter writes the caller's width as
   an *inline* style on this element, which no ordinary rule can outrank. That parameter is a
   non-mobile concession — trading track length for label room is the exact compromise this
   stacked layout removes — so on mobile the layout owns the width. */
[data-app-mode="mobile"] .ctl-slider-row .slider-track {
    grid-area: track;
    width: 100% !important;
    min-width: 0;
    --slider-track-h: 14px;
    --slider-thumb: 26px;
}

/* On the title line rather than beside the track: it reads as a value for the label it
   belongs to, and the track gets the whole width instead of surrendering ~70px to it. */
[data-app-mode="mobile"] .ctl-slider-row .slider-value {
    grid-area: value;
    align-self: center;
    justify-self: end;
    min-width: 0;
    text-align: end;
    font-size: 0.88rem;
    color: var(--acc);
    background: var(--acc-soft);
    border-radius: 999px;
    padding: 2px 10px;
}

/* The title column is the full row width now, so both lines have room to wrap and neither
   needs the ellipsis the shared row applies. */
[data-app-mode="mobile"] .ctl-slider-row .ctl-name,
[data-app-mode="mobile"] .ctl-slider-row .ctl-hint {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

/* ReadOnly display value (UiInput ReadOnly=true) */
.ctl-readonly-value {
    font-size: .87rem;
    color: var(--muted, #9aa4b2);
    opacity: .7;
    font-variant-numeric: tabular-nums;
}
