/* ── Root element ─────────────────────────────────────────── */
.hs-calendar {
    background: var(--color-surface, #fff);
    border-radius: var(--radius-xl, 18px);
    padding: var(--space-lg, 28px);
    box-shadow: var(--shadow-modal, 0 8px 40px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.08));
    max-width: 720px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-family: var(--font-system, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif);
    box-sizing: border-box;
}

.hs-calendar *,
.hs-calendar *::before,
.hs-calendar *::after {
    box-sizing: border-box;
}

.hs-calendar.hs-calendar--inline {
    box-shadow: none;
    border: 1px solid var(--color-border, #D2D2D7);
}

/* ── Summary bar — centered "Jul 24 – Jul 27" display ────────
   Sits above the months grid. Collapsed to zero height/padding
   until a selection exists — no empty gap on first load — then
   smoothly expands in once a date is picked. The nights/days
   count renders as a small pill above the dates via ::before,
   driven by the data-nights attribute set in JS — keeps the
   markup to one plain text node while still giving two visual
   tiers (small pill label + bold date line).

   max-height on the active state is generous (not a tight guess)
   specifically so a wrapped pill or a wrapped date line on narrow
   screens is never clipped by the overflow:hidden used for the
   collapse/expand transition.                                   */
.hs-calendar__summary {
    max-height: 0;
    width: 100%;
    padding: 0 2px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 6px;
    text-align: center;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.22s ease, opacity 0.18s ease, padding-bottom 0.22s ease;
}

.hs-calendar__summary--active {
    max-height: 120px;
    padding-bottom: 20px;
    opacity: 1;
    font-size: var(--text-lg, 19px);
    font-weight: var(--weight-bold, 700);
    color: var(--color-text-primary, #1D1D1F);
    letter-spacing: var(--tracking-tight, -0.01em);
}

.hs-calendar__summary--active[data-nights]::before {
    content: attr(data-nights);
    order: -1;
    display: inline-block;
    max-width: 100%;
    font-size: var(--text-xs, 11px);
    font-weight: var(--weight-semibold, 600);
    color: var(--color-text-secondary, #6E6E73);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide, 0.04em);
    background: var(--color-muted, #F5F5F7);
    padding: 3px 10px;
    border-radius: 999px;
}

/* ── Viewport wrapper — plain block, no positioning role anymore.
   Clipping/positioning now happens per-month on .hs-calendar__month-body,
   so the header (title + arrows) it sits alongside is never touched. */
.hs-calendar__months-viewport {
    display: block;
}

/* ── Month body — the ONLY part that animates during navigation/swipe.
   Holds the weekday row + days grid. Plain block by default; only gains
   position/overflow/height while a slide transition is actively running
   (set inline by JS, cleared after) or while a finger-drag is in progress. */
.hs-calendar__month-body {
    display: block;
}

/* ── Dual-month grid ──────────────────────────────────────── */
.hs-calendar__months {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl, 36px);
    margin-bottom: 20px;
}

/* ── Month navigation transition — "liquid" slide + fade ─────
   Two full-width panes stacked absolutely inside the clipped
   viewport, each driven by a CSS @keyframes animation (not a
   transition) so the browser commits the correct starting frame
   immediately — no flash of the wrong state on the first paint. */
.hs-calendar__months--pane {
    margin-bottom: 0; /* the viewport controls spacing while panes are absolute */
    will-change: transform, opacity;
}

@keyframes hsCalSlideInFromRight {
    from { transform: translateX(24px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes hsCalSlideInFromLeft {
    from { transform: translateX(-24px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

@keyframes hsCalSlideOutLeft {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(-24px); opacity: 0; }
}

@keyframes hsCalSlideOutRight {
    from { transform: translateX(0);    opacity: 1; }
    to   { transform: translateX(24px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .hs-calendar__months--pane {
        animation: none !important;
    }
}

/* ── Single month ─────────────────────────────────────────── */
.hs-calendar__month {
    min-width: 0;
}

/* ── Month header ─────────────────────────────────────────── */
.hs-calendar__month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md, 16px);
}

.hs-calendar__month-title {
    font-size: var(--text-md, 15px);
    font-weight: var(--weight-semibold, 600);
    color: var(--color-text-primary, #1D1D1F);
    letter-spacing: var(--tracking-tight, -0.01em);
}

/* ── Nav buttons ──────────────────────────────────────────── */
.hs-calendar__nav {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--color-border, #D2D2D7);
    background: var(--color-surface, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-primary, #1D1D1F);
    cursor: pointer;
    transition: background var(--transition-fast, 0.12s ease), box-shadow var(--transition-fast, 0.12s ease);
    flex-shrink: 0;
}

.hs-calendar__nav:hover {
    background: var(--color-muted, #F5F5F7);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.hs-calendar__nav--hidden {
    visibility: hidden;
    pointer-events: none;
}

/* ── Weekday labels ───────────────────────────────────────── */
.hs-calendar__weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: var(--space-xs, 6px);
}

.hs-calendar__weekday {
    text-align: center;
    font-size: var(--text-xs, 11px);
    font-weight: var(--weight-semibold, 600);
    color: var(--color-text-secondary, #6E6E73);
    padding: 4px 0;
    letter-spacing: var(--tracking-wide, 0.02em);
}

/* ── Days grid ────────────────────────────────────────────── */
.hs-calendar__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px 0;
}

/* ── Day cell ─────────────────────────────────────────────── */
.hs-calendar__day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm, 13px);
    font-weight: 400;
    color: var(--color-text-primary, #1D1D1F);
    background: none;
    border: none;
    border-radius: 50%;
    position: relative;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    z-index: 1;
    font-family: inherit;
}

.hs-calendar__day:hover:not(:disabled):not(.hs-calendar__day--empty):not(.hs-calendar__day--selected):not(.hs-calendar__day--range-start):not(.hs-calendar__day--range-end)::before {
    content: '';
    position: absolute;
    inset: 1px;
    border: 1.5px solid var(--color-text-primary, #1D1D1F);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* In-range days still get the hover ring, just drawn above the grey fill */
.hs-calendar__day--in-range:hover:not(:disabled)::before,
.hs-calendar__day--hover-range:hover:not(:disabled)::before {
    z-index: 2;
}

.hs-calendar__day--empty {
    cursor: default;
    pointer-events: none;
}

.hs-calendar__day:active:not(:disabled):not(.hs-calendar__day--empty) {
    transform: scale(0.9);
}

.hs-calendar__day--disabled {
    color: var(--color-muted-dark, #DDDDDD);
    text-decoration: line-through;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Today dot ────────────────────────────────────────────── */
.hs-calendar__day--today {
    font-weight: var(--weight-bold, 700);
}

.hs-calendar__day--today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--color-primary, #FF385C);
    border-radius: 50%;
    z-index: 4;
}

/* ── Public holiday — subtle dot indicator, Apple Calendar style ── */
.hs-calendar__day--holiday {
    color: var(--color-primary, #FF385C);
    font-weight: var(--weight-semibold, 600);
}

/* Small dot under the number. Sits opposite the "today" dot so the
   two never collide — today's dot is centered low; this one is
   offset slightly so a day that's both today AND a holiday still
   reads cleanly (today dot wins visually, holiday color carries). */
.hs-calendar__day-holiday-dot {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--color-primary, #FF385C);
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
}

/* If a day is both today and a holiday, the today dot (already red)
   is enough — hide the duplicate holiday dot to avoid a double-dot. */
.hs-calendar__day--today .hs-calendar__day-holiday-dot {
    display: none;
}

/* On selected / range endpoints / in-range: dot turns white so it
   reads against the dark/grey fill instead of disappearing. */
.hs-calendar__day--selected .hs-calendar__day-holiday-dot,
.hs-calendar__day--range-start .hs-calendar__day-holiday-dot,
.hs-calendar__day--range-end .hs-calendar__day-holiday-dot {
    background: #ffffff;
    opacity: 0.85;
}

.hs-calendar__day--in-range .hs-calendar__day-holiday-dot {
    background: var(--color-primary, #FF385C);
}

/* Disabled holiday: faded dot */
.hs-calendar__day--disabled.hs-calendar__day--holiday {
    color: rgba(255, 56, 92, 0.35);
}

.hs-calendar__day--disabled .hs-calendar__day-holiday-dot {
    background: rgba(255, 56, 92, 0.35);
}

/* ══════════════════════════════════════════════════════════
   SELECTED / RANGE ENDPOINTS
   Approach: the CELL element itself is transparent/band-only.
   The black circle is drawn entirely via ::before (full inset).
   The today dot is drawn via ::after (unchanged, sits on top).
   This way z-index never fights — ::before is always under
   the element background of siblings, ::after is always on top.
   ══════════════════════════════════════════════════════════ */

/* ── Single selected (no range) ── */
.hs-calendar__day--selected {
    background: var(--color-secondary, #222222) !important;
    color: #ffffff !important;
    font-weight: var(--weight-semibold, 600);
    border-radius: 50%;
    z-index: 2;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* today dot turns white when selected */
.hs-calendar__day--selected::after {
    background: #ffffff !important;
}

/* today + selected: hide the dot — the solid circle is indicator enough */
.hs-calendar__day--today.hs-calendar__day--selected::after {
    display: none !important;
}

/* ── Range start ── */
.hs-calendar__day--range-start {
    /* Right half = grey band; left half = transparent */
    background: linear-gradient(to right, transparent 50%, #EBEBEB 50%) !important;
    border-radius: 0 !important;
    color: transparent !important;
    /* hide real text — ::before redraws it */
    transition: background-color 0.15s ease;
    z-index: 2;
    position: relative;
}

/* ── Range end ── */
.hs-calendar__day--range-end {
    /* Left half = grey band; right half = transparent */
    background: linear-gradient(to left, transparent 50%, #EBEBEB 50%) !important;
    border-radius: 0 !important;
    color: transparent !important;
    transition: background-color 0.15s ease;
    z-index: 2;
    position: relative;
}

/* Black circle drawn via ::before — sits over the band, under ::after (today dot) */
.hs-calendar__day--range-start::before,
.hs-calendar__day--range-end::before {
    content: attr(data-day);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-secondary, #222222);
    color: #ffffff;
    font-size: inherit;
    font-weight: 600;
    font-family: inherit;
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
}

/* Today dot on range endpoints — ::after still fires, sits above ::before circle */
.hs-calendar__day--today.hs-calendar__day--range-start::after,
.hs-calendar__day--today.hs-calendar__day--range-end::after {
    background: #ffffff !important;
    z-index: 4;
}

/* ── In-range fill ────────────────────────────────────────── */
.hs-calendar__day--in-range {
    background: #EBEBEB !important;
    color: var(--color-text-primary, #1D1D1F);
    border-radius: 0;
    z-index: 1;
}

.hs-calendar__day--in-range:hover {
    background: #E0E0E0 !important;
}

.hs-calendar__day--hover-range {
    background: #EBEBEB !important;
    border-radius: 0;
    z-index: 1;
}

/* ── Focus ring ───────────────────────────────────────────── */
.hs-calendar__day:focus-visible {
    outline: 2px solid var(--color-primary, #FF385C);
    outline-offset: 1px;
}

/* ── Live region (screen-reader only) ────────────────────── */
.hs-calendar__live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .hs-calendar__months {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .hs-calendar {
        padding: 20px 16px;
    }
}


/* ══════════════════════════════════════════════════════════
   SINGLE-MONTH LAYOUT  (options.months = 1)
   The grid defaults to two columns; with one month, use the
   full width instead of leaving the right half empty.
   ══════════════════════════════════════════════════════════ */
.hs-calendar[data-months="1"] .hs-calendar__months {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 0;
}

.hs-calendar__month-title {
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════
   OUTSIDE-MONTH DAYS  (options.showOutsideDays, default true)
   Faded, non-interactive filler numbers (e.g. "1, 2, 3" after
   the 30th) so every week row is complete.
   ══════════════════════════════════════════════════════════ */
.hs-calendar__day--outside {
    color: var(--color-muted-dark, #DDDDDD);
    cursor: default;
    pointer-events: none;
    text-decoration: none;
}

/* ══════════════════════════════════════════════════════════
   DATE FIELD  — dropdown trigger + panel that holds a calendar
   Markup: <button class="cal-trigger"> … </button>
           <div class="cal-panel" hidden><div id="…"></div></div>
   ══════════════════════════════════════════════════════════ */
.cal-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    border: 1.5px solid var(--color-border, #e2e2e2);
    border-radius: 10px;
    padding: 9px 12px;
    background: var(--color-surface, #fff);
    color: var(--color-text-primary, #111827);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cal-trigger:hover {
    border-color: #9aa3af;
}

.cal-trigger[aria-expanded="true"] {
    border-color: var(--color-secondary, #102A43);
    box-shadow: 0 0 0 3px rgba(16, 42, 67, 0.08);
}

.cal-trigger__icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #eef2f6;
    color: #102A43;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cal-trigger__icon svg {
    width: 17px;
    height: 17px;
}

.cal-trigger__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cal-trigger__date {
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.25;
}

.cal-trigger__note {
    font-size: 12px;
    font-weight: 500;
    color: #0a7a3d;
    line-height: 1.25;
}

.cal-trigger__chev {
    width: 18px;
    height: 18px;
    color: var(--color-text-secondary, #6B7280);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.cal-trigger[aria-expanded="true"] .cal-trigger__chev {
    transform: rotate(180deg);
}

.cal-panel {
    margin-top: 8px;
    border: 1.5px solid var(--color-border, #e2e2e2);
    border-radius: 14px;
    padding: 12px;
    background: var(--color-surface, #fff);
    animation: hsCalPanelIn 0.18s ease;
}

.cal-panel[hidden] {
    display: none;
}

@keyframes hsCalPanelIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* A calendar inside a .cal-panel drops its own card chrome and uses the navy accent */
.cal-panel .hs-calendar {
    --color-secondary: #102A43;
    padding: 0;
    max-width: 100%;
    background: transparent;
    box-shadow: none;
    border: 0;
    font-family: inherit;
}

.cal-panel .hs-calendar__month-header {
    margin-bottom: 10px;
}

.cal-panel .hs-calendar__month-title {
    font-size: 15px;
}

.cal-panel .hs-calendar__day {
    font-size: 13.5px;
}

/* Unavailable days: plain grey — no strike-through, no holiday colour/dot */
.cal-panel .hs-calendar__day--disabled {
    text-decoration: none;
}

.cal-panel .hs-calendar__day--disabled.hs-calendar__day--holiday {
    color: var(--color-muted-dark, #DDDDDD);
    font-weight: 400;
}

.cal-panel .hs-calendar__day--disabled .hs-calendar__day-holiday-dot {
    display: none;
}