/* =========================================================================
   Zeitraum-Kalender - gemeinsame Optik fuer alle Module
   =========================================================================
   Vorbild: kitzbuehel.com/unterkuenfte (Stefan-Vorgabe 05.08.2026), umgesetzt
   mit den Osttirol-Tokens. Die Regeln lagen vorher in booking.css und galten
   damit nur fuer die Unterkunftssuche; Veranstaltungen und Pauschalen hatten
   zwei nackte `<input type="date">`. Diese Datei wird von allen Modulen geladen,
   die den Kalender einsetzen (`date-picker.js`).

   Merkmale der Vorlage, die hier bewusst uebernommen sind:
     - zwei Monate nebeneinander, Monatsname zentriert, Pfeile an den Aussenrand
     - Wochentagszeile klein und grau, kein Gitter, viel Weissraum
     - heute als Ring, An-/Abreise als gefuellter Kreis, Bereich dazwischen
       flaechig hinterlegt
     - unter einer Trennlinie die Schnellwahl

   Copyright: Stefan Ennemoser, web-crossing GmbH
   ========================================================================= */

.osttirol-cal-overlay {
    position: absolute;
    top: calc(100% + var(--space-2, 8px));
    left: 0;
    z-index: var(--z-dropdown);
    background: var(--c-bg, #fff);
    border: 1px solid var(--c-border, #e3e3e3);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-modal, 0 18px 48px rgba(0, 0, 0, 0.18));
    padding: var(--space-6, 24px);
    min-width: 320px;
    max-width: 720px;
    width: max-content;
}

/* --- Kopfzeile: Pfeil - Monat - Monat - Pfeil ---------------------------- */
.osttirol-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4, 16px);
    margin-bottom: var(--space-5, 20px);
}

.osttirol-cal-nav__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: var(--c-text, #222);
    cursor: pointer;
    transition: background-color var(--duration-fast, 150ms) var(--ease-out, ease);
}

.osttirol-cal-nav__btn:hover {
    background: var(--c-bg-alt, #f5f5f5);
}

.osttirol-cal-nav__btn:focus-visible {
    outline: 3px solid var(--c-accent, #b51621);
    outline-offset: 2px;
}

.osttirol-cal-nav__btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Die Monatstitel teilen den Platz zwischen den Pfeilen - dadurch stehen sie
   wie in der Vorlage jeweils ueber ihrer eigenen Monatsspalte. */
.osttirol-cal-nav__titles {
    display: flex;
    flex: 1 1 auto;
    justify-content: space-around;
    gap: var(--space-6, 24px);
}

.osttirol-cal-month__title {
    margin: 0;
    font-family: var(--font-display, inherit);
    font-size: var(--fs-lg, 18px);
    font-weight: 600;
    text-align: center;
    color: var(--c-text, #222);
}

/* --- Monatsraster -------------------------------------------------------- */
.osttirol-cal-months {
    display: flex;
    gap: var(--space-7, 32px);
}

@media (max-width: 767px) {
    .osttirol-cal-months {
        flex-direction: column;
        gap: var(--space-5, 20px);
    }

    /* Auf dem Handy nur EIN Monat: zwei untereinander sind ohne Not zwei
       Bildschirmhoehen. Der zweite Monat ist per Pfeil erreichbar.

       Geschwister-Selektor, NICHT `:nth-child(2)`: Alpine laesst das
       `<template x-for>` als erstes Kind im DOM stehen und rueckt die Monate
       damit um eine Position weiter. `:nth-child(2)` traf so den ERSTEN Monat -
       auf 390 px war der aktuelle Monat samt gewaehltem Datum unsichtbar und
       der Folgemonat stand da (gemessen 06.08.2026). */
    .osttirol-cal-month + .osttirol-cal-month {
        display: none;
    }

    /* Gleiches Spiel in der Kopfzeile: sonst stehen zwei Monatsnamen ueber
       genau einem Gitter. */
    .osttirol-cal-month__title + .osttirol-cal-month__title {
        display: none;
    }
}

.osttirol-cal-month {
    flex: 1 1 0;
    min-width: 0;
}

.osttirol-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.osttirol-cal__weekday {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    font-size: var(--fs-xs, 12px);
    font-weight: 600;
    color: var(--c-text-muted, #767676);
    text-transform: none;
}

.osttirol-cal__day {
    display: flex;
    align-items: center;
    justify-content: center;
    /* 44px: Touch-Target-Mindestmass der UI-Checkliste und gleichzeitig die
       luftige Anmutung der Vorlage. */
    min-height: 44px;
    min-width: 44px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: transparent;
    padding: 0;
    font-size: var(--fs-sm, 14px);
    font-weight: 500;
    color: var(--c-text, #222);
    cursor: pointer;
    transition: background-color var(--duration-fast, 150ms) var(--ease-out, ease),
                color var(--duration-fast, 150ms) var(--ease-out, ease);
}

.osttirol-cal__day:hover:not(.osttirol-cal__day--past):not(.osttirol-cal__day--empty):not(.osttirol-cal__day--blocked) {
    background: var(--c-bg-alt, #f5f5f5);
}

.osttirol-cal__day:focus-visible {
    outline: 3px solid var(--c-accent, #b51621);
    outline-offset: 2px;
}

.osttirol-cal__day--empty {
    cursor: default;
    pointer-events: none;
}

.osttirol-cal__day--past,
.osttirol-cal__day--blocked {
    color: var(--c-text-muted, #767676);
    cursor: not-allowed;
    opacity: 0.4;
    pointer-events: none;
}

/* Heute: Ring, nicht gefuellt - genau wie in der Vorlage. */
.osttirol-cal__day--today {
    font-weight: 700;
    border-color: var(--c-primary, #b51621);
}

/* An- und Abreise: gefuellter Kreis. */
.osttirol-cal__day--from,
.osttirol-cal__day--to {
    background: var(--c-primary, #b51621);
    border-color: var(--c-primary, #b51621);
    color: #fff;
    font-weight: 700;
}

/* Bereich dazwischen: flaechig, eckig, damit eine durchgehende Spur entsteht. */
.osttirol-cal__day--in-range {
    background: color-mix(in srgb, var(--c-primary, #b51621) 14%, transparent);
    border-radius: 0;
    color: var(--c-text, #222);
}

/* --- Schnellwahl --------------------------------------------------------- */
.osttirol-cal-presets {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3, 12px);
    margin-top: var(--space-5, 20px);
    padding-top: var(--space-5, 20px);
    border-top: 1px solid var(--c-border, #e3e3e3);
}

.osttirol-cal-presets__label {
    font-weight: 600;
    font-size: var(--fs-sm, 14px);
    color: var(--c-text, #222);
}

.osttirol-cal-preset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 var(--space-4, 16px);
    border: 1px solid var(--c-border-strong, #c8c8c8);
    border-radius: var(--radius-sm, 6px);
    background: var(--c-bg, #fff);
    font: inherit;
    font-size: var(--fs-sm, 14px);
    font-weight: 500;
    color: var(--c-text, #222);
    cursor: pointer;
    transition: border-color var(--duration-fast, 150ms) var(--ease-out, ease),
                color var(--duration-fast, 150ms) var(--ease-out, ease);
}

.osttirol-cal-preset-btn:hover {
    border-color: var(--c-primary, #b51621);
    color: var(--c-primary, #b51621);
}

.osttirol-cal-preset-btn:focus-visible {
    outline: 3px solid var(--c-accent, #b51621);
    outline-offset: 2px;
}

/* „Datum loeschen" steht rechts und ohne Rahmen, damit es nicht wie eine
   weitere Schnellwahl aussieht. */
.osttirol-cal-presets__reset {
    margin-left: auto;
    border: none;
    background: transparent;
    min-height: 44px;
    padding: 0 var(--space-2, 8px);
    font: inherit;
    font-size: var(--fs-sm, 14px);
    color: var(--c-text-muted, #767676);
    cursor: pointer;
    text-decoration: underline;
}

.osttirol-cal-presets__reset:hover {
    color: var(--c-primary, #b51621);
}

/* --- Trigger ------------------------------------------------------------- */
.osttirol-datepicker {
    position: relative;
}

.osttirol-datepicker__trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 8px);
    min-height: 44px;
    padding: 0 var(--space-4, 16px);
    border: 1px solid var(--c-border-strong, #c8c8c8);
    border-radius: var(--radius-pill, 999px);
    background: var(--c-bg, #fff);
    font: inherit;
    color: var(--c-text, #222);
    cursor: pointer;
}

.osttirol-datepicker__trigger:hover {
    border-color: var(--c-primary, #b51621);
}

.osttirol-datepicker__trigger:focus-visible {
    outline: 3px solid var(--c-accent, #b51621);
    outline-offset: 2px;
}

.osttirol-datepicker__icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: var(--c-primary, #b51621);
}

/* Handy: der Kalender wird ein Panel von unten (Muster der Suchleisten-Sheets,
   Abnahme-Punkte 65/67) - ein absolut positioniertes Overlay waere auf 390 px
   entweder abgeschnitten oder ausserhalb des Sichtfelds. */
@media (max-width: 767px) {
    .osttirol-cal-overlay {
        position: fixed;
        inset: auto 0 0 0;
        top: auto;
        max-width: none;
        width: 100%;
        max-height: 85vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: var(--radius-lg, 12px) var(--radius-lg, 12px) 0 0;
        padding: var(--space-5, 20px);
        z-index: var(--z-modal);
    }
}
