/* <app-date-range> - see wwwroot/js/app-date-range.js and TagHelpers/AppDateRangeTagHelper.cs.

   Every colour is a Bootstrap CSS variable, never a literal: the app defaults to dark and the toggle flips
   data-bs-theme at runtime, so a hard-coded colour survives the flip (same rule as app-combobox.css).

   Until the script has run and added .app-date-range-active the pair is two ordinary date boxes side by
   side, which is a working field. */
.app-date-range {
    position: relative;
}

/* The site's own purple in the dark theme (site.css re-themes .btn-primary there; Bootstrap's --bs-primary stays
   blue), the theme's primary otherwise. */
.app-date-range {
    --adr-accent: var(--bs-primary);
    --adr-accent-rgb: var(--bs-primary-rgb);
}

[data-bs-theme="dark"] .app-date-range {
    --adr-accent: #7c3aed;
    --adr-accent-rgb: 124, 58, 237;
}

/* ONE JOINED CONTROL: [ opening day ] → [ closing day ], a Bootstrap input group (Chris, 2026-11-06: "I'd prefer
   if it looked like a single component"). The corners and the overlapping borders are set here by role rather
   than by Bootstrap's first/last-child rules, because the script leaves the hidden real inputs in the group beside
   the boxes it draws, which would otherwise count as the last child. */
.app-date-range-pair {
    position: relative;
    flex-wrap: nowrap;
    max-width: 30rem;
}

.app-date-range-pair > .form-control {
    flex: 1 1 0;
    min-width: 0;
    border-radius: 0;
}

.app-date-range-pair > .app-date-range-start-box {
    border-top-left-radius: var(--bs-border-radius);
    border-bottom-left-radius: var(--bs-border-radius);
}

.app-date-range-pair > .app-date-range-end-box {
    border-top-right-radius: var(--bs-border-radius);
    border-bottom-right-radius: var(--bs-border-radius);
}

.app-date-range-pair > .app-date-range-arrow,
.app-date-range-pair > .app-date-range-end-box {
    margin-left: calc(-1 * var(--bs-border-width));
}

.app-date-range-arrow {
    color: var(--bs-secondary-color);
    border-radius: 0;
}

/* The focused or current half draws its ring over the neighbours' borders. */
.app-date-range-pair > .form-control:focus,
.app-date-range-pair > .app-date-range-current {
    z-index: 5;
}

/* READ-ONLY BUT NOT GREY: Bootstrap paints a [readonly] .form-control with the secondary background, which reads
   as disabled. These boxes are picked from, not typed into, so they keep the ordinary field look with a pointer. */
.app-date-range-shown[readonly] {
    background-color: var(--bs-body-bg);
    cursor: pointer;
    caret-color: transparent;
}

/* The box the next click will fill, so the reader can see which end of the stay they are picking. */
.app-date-range-shown.app-date-range-current {
    border-color: var(--adr-accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--adr-accent-rgb), 0.25);
}

/* Mid-pick, the closing day the pair already had: still there, muted, until the next click replaces it. */
.app-date-range-shown.app-date-range-ghost {
    color: var(--bs-secondary-color);
}

/* ABSOLUTE, so opening the popover does not push the form down and close it again; inside the modal body it
   extends the scrolling area rather than being clipped. */
.app-date-range-popover {
    position: absolute;
    z-index: 1060;
    left: 0;
    top: calc(100% + 0.25rem);
    max-width: min(36rem, 92vw);
    padding: 0.75rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--bs-box-shadow-lg);
}

.app-date-range-popover[hidden] {
    display: none;
}

.app-date-range-bar {
    display: flex;
    justify-content: space-between;
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    top: 0.5rem;
    pointer-events: none;
}

.app-date-range-nav {
    pointer-events: auto;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--bs-body-color);
}

.app-date-range-nav:hover,
.app-date-range-nav:focus-visible {
    background: var(--bs-tertiary-bg);
}

.app-date-range-months {
    display: flex;
    gap: 1.5rem;
}

.app-date-range-month {
    width: 15.75rem;
}

.app-date-range-caption {
    text-align: center;
    font-weight: 600;
    height: 2rem;
    line-height: 2rem;
    margin-bottom: 0.25rem;
}

/* Seven equal columns; the day buttons fill their cell so a span reads as one unbroken band. */
.app-date-range-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    row-gap: 2px;
}

.app-date-range-weekday {
    text-align: center;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    padding-bottom: 0.25rem;
}

.app-date-range-day {
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 0.875rem;
    cursor: pointer;
    position: relative;
}

.app-date-range-day:hover:not(.is-start):not(.is-end) {
    background: var(--bs-tertiary-bg);
    border-radius: 50%;
}

.app-date-range-day:focus-visible {
    outline: 2px solid var(--adr-accent);
    outline-offset: -2px;
    z-index: 1;
}

/* The keyboard lands on the opening day first, which is filled with the accent: an accent ring would vanish there. */
.app-date-range-day.is-start:focus-visible,
.app-date-range-day.is-end:focus-visible {
    outline-color: var(--bs-body-color);
    outline-offset: -3px;
}

/* Today is a ring, whatever else it is. */
.app-date-range-day.is-today::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 3px;
    width: 4px;
    height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--adr-accent);
}

/* THE SPAN, lit as one band from the opening day to the closing (or the hovered) day. */
.app-date-range-day.is-in-range {
    background: rgba(var(--adr-accent-rgb), 0.22);
    border-radius: 0;
}

.app-date-range-day.is-in-range.is-live {
    background: rgba(var(--adr-accent-rgb), 0.14);
}

.app-date-range-day.is-start,
.app-date-range-day.is-end {
    background: var(--adr-accent);
    color: var(--bs-white);
    font-weight: 600;
}

.app-date-range-day.is-start {
    border-radius: 999px 0 0 999px;
}

.app-date-range-day.is-end {
    border-radius: 0 999px 999px 0;
}

.app-date-range-day.is-single {
    border-radius: 999px;
}

.app-date-range-day.is-today.is-start::after,
.app-date-range-day.is-today.is-end::after {
    background: var(--bs-white);
}

.app-date-range-hint {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color);
}

/* PHONE: one month, the popover as wide as the pair, bigger touch targets. */
@media (max-width: 575.98px) {
    .app-date-range-popover {
        left: 0;
        right: 0;
    }

    .app-date-range-months {
        display: block;
    }

    .app-date-range-month {
        width: 100%;
    }

    /* Finger-sized: the root font is 14px, so 3rem is 42px. */
    .app-date-range-day {
        height: 3rem;
    }

    .app-date-range-nav {
        width: 2.9rem;
        height: 2.9rem;
    }

    .app-date-range-caption {
        height: 2.9rem;
        line-height: 2.9rem;
    }

    .app-date-range-shown {
        min-height: 2.75rem;
    }

    .app-date-range-pair {
        max-width: none;
    }
}

/* At 320 the shown day ("Mon, Nov 9, 2026") did not fit its half of the pair (scrollWidth 130 against clientWidth 119). */
@media (max-width: 359.98px) {
    .app-date-range-shown {
        font-size: 0.8125rem;
        padding-inline: 0.5rem;
    }
}
