/* Custom date picker for form fields.
   Value in the hidden <input> stays ISO (YYYY-MM-DD) so server-side stays untouched;
   only the trigger button shows a locale-formatted date. Mobile: dialog fills the viewport. */
/* ---------------------------------------------------------------------------------------------
   Shared base class for EVERY form control (text/email/number inputs, <select>, <textarea>, and the
   custom date / rich-select triggers). One class so a template can style all fields uniformly and
   set --field-radius / --field-bg once. Element-specific rules should extend, not replace, this.
   --------------------------------------------------------------------------------------------- */
.mat-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line, #d5d5d5);
    border-radius: var(--field-radius, 8px);
    background: var(--field-bg, #fff);
    color: inherit;
    font: inherit;
    line-height: 1.4;
}
.mat-input:focus, .mat-input:focus-visible {
    outline: none;
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.mat-input:disabled, .mat-input[disabled] { opacity: .55; background: #f7f7f7; cursor: not-allowed; }
textarea.mat-input { min-height: 120px; resize: vertical; }

.mat-dp { display: block; width: 100%; }

/* Date trigger inherits the .mat-input base (border, radius, padding, bg); here only its layout. */
.mat-dp-btn-trigger { display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; }
.mat-dp-btn-trigger[disabled] { cursor: not-allowed; }

.mat-dp-display { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-dp-placeholder { color: #999; }
.mat-dp-icon { flex: 0 0 auto; display: inline-flex; opacity: .55; }
.mat-dp-icon svg { width: 18px; height: 18px; }

/* Header (title + ✕) — shown on desktop AND mobile, so the picker always has an explicit close
   (there is no separate Cancel button). */
.mat-dp-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 10px 12px 16px; border-bottom: 1px solid #ececec; flex: 0 0 auto;
}
.mat-dp-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-dp-close {
    border: 0; background: none; cursor: pointer; font-size: 22px; line-height: 1;
    color: inherit; padding: 4px 8px; border-radius: 8px; flex: none;
}
.mat-dp-close:hover { background: #f2f2f2; }

/* Overlay: full-screen dim that holds + centres the panel (same approach as the rich-select, so it
   behaves identically on mobile). z-index sits above the floating language selector (1300). */
.mat-dp-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.mat-dp-overlay[hidden] { display: none; }

/* Dialog panel */
.mat-dp-dialog {
    border: 0;
    padding: 0;
    border-radius: 14px;
    max-width: 640px;
    width: 100%;
    background: #fff;
    color: inherit;
    box-shadow: 0 30px 80px rgba(0,0,0,.22);
    overflow: hidden;
    max-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Body holds the prev/next arrows and one or two month panels side by side. */
.mat-dp-body {
    display: flex;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 12px 6px;
}
.mat-dp-months { display: flex; gap: 22px; flex: 1; min-width: 0; }
.mat-dp-month { flex: 1 1 0; min-width: 0; }
.mat-dp-mtitle {
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    text-transform: capitalize;
    margin: 2px 0 8px;
}
.mat-dp-nav {
    align-self: center;
    border: 0;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    color: inherit;
    flex: 0 0 auto;
}
.mat-dp-nav:hover { background: #f2f2f2; }

.mat-dp-weekdays,
.mat-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.mat-dp-weekdays {
    padding: 8px 10px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #888;
    text-align: center;
}
.mat-dp-weekdays span { padding: 4px 0; }
/* row-gap only → the in-range highlight stays a continuous horizontal bar (booking-style). */
.mat-dp-grid { padding: 4px 0 6px; gap: 3px 0; }

.mat-dp-day {
    aspect-ratio: 1 / 1;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font: inherit;
    color: inherit;
    padding: 0;
    min-height: 36px;
}
.mat-dp-day:hover:not(:disabled) { background: #f0f0f0; }
.mat-dp-day.mat-dp-empty { visibility: hidden; }
.mat-dp-day.mat-dp-today { box-shadow: inset 0 0 0 1px var(--accent, #2563eb); }
.mat-dp-day.mat-dp-selected {
    background: var(--accent, #2563eb);
    color: #fff;
    font-weight: 600;
}
.mat-dp-day.mat-dp-selected.mat-dp-today { box-shadow: none; }

/* Range mode: days between start and end are lightly tinted; endpoints stay solid. */
.mat-dp-day.mat-dp-in-range {
    background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
    border-radius: 0;
}
/* Fallback if color-mix() is unsupported. */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
    .mat-dp-day.mat-dp-in-range { background: rgba(37, 99, 235, .14); }
}
.mat-dp-day.mat-dp-range-start { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mat-dp-day.mat-dp-range-end { border-top-left-radius: 0; border-bottom-left-radius: 0; }
/* When start and end are the same day, keep the full pill shape. */
.mat-dp-day.mat-dp-range-start.mat-dp-range-end { border-radius: 8px; }

/* Flexible-date options (booking-style): "Genaue Zeitangabe" + ± N days chips. */
.mat-dp-flex { padding: 10px 14px 12px; border-top: 1px solid #ececec; }
.mat-dp-flex-title { font-size: 12px; color: #888; margin-bottom: 8px; }
.mat-dp-flex-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-dp-chip {
    border: 1px solid var(--line, #d5d5d5); background: #fff; color: inherit;
    padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
    transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.mat-dp-chip:hover { border-color: var(--accent, #2563eb); }
.mat-dp-chip.is-active { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; font-weight: 600; }

.mat-dp-foot {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #ececec;
    align-items: center;
    flex-wrap: wrap;
}
.mat-dp-spacer { flex: 1; }
.mat-dp-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font: inherit;
    background: transparent;
    color: inherit;
}
.mat-dp-btn-ghost:hover { background: #f2f2f2; }
.mat-dp-btn-primary {
    background: var(--accent, #2563eb);
    color: #fff;
    border-color: var(--accent, #2563eb);
    font-weight: 600;
}
.mat-dp-btn-primary:hover { filter: brightness(1.05); }

/* Narrow screens: show a single month (nav arrows still reach the next month). */
@media (max-width: 640px) {
    .mat-dp-dialog { max-width: 380px; }
    .mat-dp-months { gap: 0; }
    .mat-dp-months .mat-dp-month:nth-child(2) { display: none; }
}

/* Mobile: full-screen dialog with a fixed header (title + ✕), a scrollable calendar and a pinned
   footer. dvh keeps the footer above the browser chrome. */
@media (max-width: 600px) {
    .mat-dp-overlay { padding: 0; }        /* full screen, no gutter */
    .mat-dp-dialog {
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        overflow: hidden;
    }
    /* Header with the ✕ close, pinned at the top. */
    .mat-dp-head {
        display: flex; align-items: center; justify-content: space-between; gap: 10px;
        padding: 16px 12px 14px 16px; border-bottom: 1px solid #ececec; flex: 0 0 auto;
    }
    /* Scrollable calendar region. */
    .mat-dp-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        align-items: flex-start;
        padding: 14px 10px 6px;
    }
    .mat-dp-month { display: flex; flex-direction: column; }
    .mat-dp-mtitle { font-size: 17px; }
    .mat-dp-grid { padding: 8px 2px; }
    .mat-dp-day { font-size: 16px; min-height: 42px; }
    /* Flex chips + footer never shrink and never scroll away. */
    .mat-dp-flex { flex: 0 0 auto; }
    .mat-dp-foot {
        flex: 0 0 auto;
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }
    .mat-dp-btn { min-height: 44px; padding: 10px 16px; }
}
