/*
 * Modul Termine – Online-Buchung (Assistent, Kalender, Uhrzeiten, Bestätigung), Terminverwaltung,
 * Tagesbetrieb (Kommende Tage, Nächste freie Termine), Wochenplan-Editor und Check-in.
 * Nur Tokens des Designsystems (var(--c-…), var(--space-…)), keine eigenen Farben.
 */

/* ==== Öffentliche Seiten: Kopf ============================================= */

.apt-lang {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-small);
}

.apt-lang > .icon {
    color: var(--c-blue);
}

.apt-lang ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.apt-lang a {
    color: var(--c-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.apt-lang a[aria-current] {
    color: var(--c-text-strong);
    font-weight: 700;
    text-decoration: none;
}

/* ==== Assistent ============================================================= */

.apt-intro {
    margin: 0 0 var(--space-3);
    color: var(--c-text);
    font-size: var(--fs-lead);
    font-style: italic;
    font-weight: 300;
}

.apt-steps li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.apt-steps li::before {
    content: none;
}

.apt-steps__number {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--c-border);
    border-radius: 50%;
    background: var(--c-white);
    color: var(--c-text-strong);
    font-size: var(--fs-tiny);
    font-weight: 700;
}

.apt-steps li.is-done .apt-steps__number {
    border-color: var(--c-success);
    background: var(--c-success-bg);
    color: var(--c-success-text);
}

.apt-steps li[aria-current="step"] .apt-steps__number {
    border-color: var(--c-blue);
    background: var(--c-blue);
    color: var(--brand-on-accent);
}

.apt-steps a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.apt-lead {
    max-width: 75ch;
    color: var(--c-text-strong);
    font-weight: 500;
}

.apt-facts {
    margin-bottom: var(--space-5);
}

.apt-section {
    margin-bottom: var(--space-6);
}

.apt-section > h2 {
    margin-bottom: var(--space-2);
    font-size: var(--fs-h3);
}

.apt-section__text {
    margin-bottom: var(--space-3);
    color: var(--c-muted);
}

.apt-subsection {
    margin: var(--space-4) 0 0 var(--space-4);
}

.apt-subsection > h3 {
    margin-bottom: var(--space-2);
    font-size: 18px;
    font-weight: 500;
}

.apt-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.apt-actions + *,
.apt-after-actions {
    margin-top: var(--space-5);
}

.apt-restart {
    margin-top: var(--space-5);
    font-size: var(--fs-small);
}

/* Auswahlkacheln mit Optionsfeld (Anliegen, Standort) */
.apt-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.apt-choice {
    align-items: flex-start;
    justify-content: flex-start;
    height: 100%;
    color: var(--c-text-strong);
}

.apt-choice input[type="radio"] {
    flex: none;
    margin-top: 4px;
}

.apt-choice:has(input:checked) {
    border-color: var(--c-blue);
    box-shadow: inset 0 0 0 1px var(--c-blue);
    background: var(--c-blue-light);
}

.apt-choice:has(input:focus-visible) {
    outline: 2px solid var(--c-focus);
    outline-offset: 2px;
}

.apt-choice__body {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.apt-choice__title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--c-text-strong);
    font-weight: 500;
}

.apt-choice__title .icon {
    color: var(--c-blue);
}

.apt-choice__text {
    color: var(--c-text);
    font-size: var(--fs-small);
}

.apt-choice__hint {
    display: flex;
    gap: 6px;
    color: var(--c-muted);
    font-size: var(--fs-small);
}

.apt-choice__hint .icon {
    flex: none;
    margin-top: 3px;
    color: var(--c-blue);
}

a.apt-choice {
    text-decoration: none;
}

/* Information ohne Termin (aufklappbar) */
.apt-info {
    height: 100%;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
    background: var(--c-row-alt);
}

.apt-info > summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 14px 18px;
    color: var(--c-text-strong);
    cursor: pointer;
}

.apt-info > summary .icon {
    color: var(--c-blue);
}

.apt-info__body {
    padding: 0 18px 14px;
    font-size: var(--fs-small);
}

/* ==== Terminwahl: Kalender + Uhrzeiten ===================================== */

.apt-picker {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
    margin-bottom: var(--space-5);
}

@media (max-width: 900px) {
    .apt-picker {
        grid-template-columns: minmax(0, 1fr);
    }
}

.apt-calendar {
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-white);
    box-shadow: var(--shadow-card);
}

.apt-calendar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--c-line);
}

.apt-calendar__head h2,
.apt-calendar__head h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: var(--fs-base);
    font-weight: 700;
}

.apt-calendar__nav {
    min-width: var(--target-min);
}

.apt-calendar__grid {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 3px;
    table-layout: fixed;
}

.apt-calendar__grid th {
    padding: 4px 0;
    color: var(--c-muted);
    font-size: var(--fs-tiny);
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
}

.apt-calendar__grid abbr {
    text-decoration: none;
}

.apt-calendar__grid td {
    padding: 0;
    text-align: center;
}

.apt-calendar__day {
    display: grid;
    place-items: center;
    min-height: var(--target-min);
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--c-panel);
    color: var(--c-muted);
    font-variant-numeric: tabular-nums;
}

.apt-calendar__day--outside {
    background: transparent;
    color: var(--c-border-strong);
}

a.apt-calendar__day {
    border-color: var(--c-success-border);
    background: var(--c-success-bg);
    color: var(--c-success-text);
    font-weight: 700;
    text-decoration: none;
}

a.apt-calendar__day:hover,
a.apt-calendar__day:focus-visible {
    border-color: var(--c-success);
    color: var(--c-text-strong);
    text-decoration: none;
}

a.apt-calendar__day.is-selected {
    border-color: var(--c-blue);
    background: var(--c-blue);
    color: var(--brand-on-accent);
}

.apt-calendar__day.is-today {
    box-shadow: inset 0 0 0 2px var(--c-blue);
}

.apt-calendar__legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    margin: 0;
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--c-line);
    color: var(--c-muted);
    font-size: var(--fs-tiny);
}

.apt-calendar__legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.apt-calendar__legend span::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 1px solid var(--c-border);
    border-radius: 2px;
    background: var(--c-panel);
}

.apt-calendar__legend .is-free::before {
    border-color: var(--c-success-border);
    background: var(--c-success-bg);
}

.apt-calendar__legend .is-selected::before {
    border-color: var(--c-blue);
    background: var(--c-blue);
}

.apt-times {
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-white);
    box-shadow: var(--shadow-card);
    scroll-margin-top: var(--space-4);
}

.apt-times h2,
.apt-times h3 {
    margin: 0 0 var(--space-1);
    font-size: 18px;
    font-weight: 700;
}

.apt-times__hint {
    margin-bottom: var(--space-3);
    color: var(--c-muted);
    font-size: var(--fs-small);
}

.apt-times .choice-tiles {
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
    gap: var(--space-2);
    margin: 0;
}

.apt-time {
    justify-content: center;
    min-height: var(--target-min);
    padding: 10px 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    text-align: center;
}

.apt-time__free {
    display: block;
    color: var(--c-muted);
    font-size: var(--fs-tiny);
    font-weight: 400;
}

a.apt-time {
    flex-direction: column;
    gap: 0;
    text-decoration: none;
}

/* ==== Prüfen & Buchen ======================================================= */

.apt-review {
    display: grid;
    gap: var(--space-4);
    max-width: var(--form-max);
    margin-bottom: var(--space-5);
}

.apt-review__block {
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-white);
}

.apt-review__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
}

.apt-review__head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.apt-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius);
    background: var(--c-panel);
    color: var(--c-text-strong);
    font-size: var(--fs-tiny);
}

.apt-edit .icon {
    width: 13px;
    height: 13px;
}

/* ==== Ihre Angaben ========================================================== */

.apt-form {
    max-width: var(--form-max);
}

.apt-form .form-row {
    margin-bottom: 0;
}

.apt-privacy {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--c-box-border);
    background: var(--c-panel);
}

.apt-privacy .check {
    padding: 0;
}

.apt-privacy .check__text .field__required {
    display: inline;
    color: var(--c-blue);
}

/* Honigtopf: für Menschen unsichtbar, Bots füllen es aus */
.apt-hp {
    position: absolute !important;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.apt-required-note {
    color: var(--c-muted);
    font-size: var(--fs-small);
}

/* ==== Bestätigung, Verwaltung, QR-Code ====================================== */

.apt-confirm {
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    max-width: var(--form-max);
    margin-bottom: var(--space-5);
    padding: var(--space-5);
    text-align: center;
}

.apt-confirm > .icon {
    width: 48px;
    height: 48px;
    padding: 8px;
    border: 2px solid var(--c-blue);
    border-radius: 50%;
    color: var(--c-blue);
}

.apt-confirm h1,
.apt-confirm h2 {
    margin: 0;
    font-size: var(--fs-h3);
    font-weight: 700;
}

.apt-confirm p {
    margin: 0 auto;
}

.apt-confirm__when {
    font-weight: 700;
}

.apt-ticket {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    gap: var(--space-5) var(--space-6);
    align-items: start;
    max-width: var(--form-max);
    margin-bottom: var(--space-5);
}

@media (max-width: 700px) {
    .apt-ticket {
        grid-template-columns: minmax(0, 1fr);
    }

    .apt-ticket .apt-qr {
        justify-self: center;
    }
}

.apt-qr {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    width: 100%;
    max-width: 17rem;
    padding: var(--space-4);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-white);
    text-align: center;
}

.apt-qr__image {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
}

.apt-qr figcaption {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
}

.apt-qr__caption {
    color: var(--c-muted);
    font-size: var(--fs-small);
}

.apt-code {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-row-alt);
    color: var(--c-heading);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

.apt-link-box {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--c-line);
    border-radius: var(--radius);
    background: var(--c-row-alt);
    font-size: var(--fs-small);
    overflow-wrap: anywhere;
}

.apt-status-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-4);
}

/* ==== Check-in ============================================================== */

.apt-checkin-result {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-5);
    text-align: center;
}

.apt-checkin-result .plate {
    font-size: clamp(2.5rem, 9vw, 4.5rem);
}

.apt-checkin-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.apt-checkin-form .field {
    flex: 1 1 16rem;
}

.apt-checkin-form input[name="code"] {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 20px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ==== Tagesbetrieb: Kommende Tage, nächste freie Termine ===================== */

.apt-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--space-3);
    margin: 0 0 var(--space-6);
    padding: 0;
    list-style: none;
}

@media (max-width: 1200px) {
    .apt-days {
        grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    }
}

.apt-day {
    display: grid;
    gap: 4px;
    height: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--c-line);
    border-radius: var(--radius-lg);
    background: var(--c-white);
    box-shadow: var(--shadow-card);
    color: var(--c-text);
    text-decoration: none;
}

a.apt-day:hover,
a.apt-day:focus-visible {
    border-color: var(--c-blue);
    text-decoration: none;
}

.apt-day__weekday {
    color: var(--c-muted);
    font-size: var(--fs-tiny);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.apt-day__date {
    color: var(--c-heading);
    font-size: 20px;
    font-weight: 700;
}

.apt-day__count {
    color: var(--c-text-strong);
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.apt-day__label {
    color: var(--c-muted);
    font-size: var(--fs-tiny);
}

.apt-day .bar__fill {
    display: block;
}

.apt-day--today {
    border: 2px solid var(--c-red);
}

.apt-day--today .apt-day__weekday,
.apt-day--today .apt-day__date {
    color: var(--c-red-dark);
}

.apt-day--closed {
    background: var(--c-row-alt);
    box-shadow: none;
}

.apt-day--closed .apt-day__date,
.apt-day--closed .apt-day__count {
    color: var(--c-muted);
}

.apt-next {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: var(--space-3);
    margin: 0 0 var(--space-6);
    padding: 0;
    list-style: none;
}

.apt-next__item {
    display: grid;
    gap: 2px;
    height: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--c-line);
    border-left: 4px solid var(--c-success);
    border-radius: var(--radius);
    background: var(--c-white);
    box-shadow: var(--shadow-card);
    color: var(--c-text);
    text-decoration: none;
}

a.apt-next__item:hover,
a.apt-next__item:focus-visible {
    border-color: var(--c-blue);
    border-left-color: var(--c-success);
    text-decoration: none;
}

.apt-next__date {
    color: var(--c-text-strong);
    font-weight: 700;
}

.apt-next__time {
    color: var(--c-blue);
    font-weight: 500;
}

.apt-next__service {
    color: var(--c-text);
    font-size: var(--fs-small);
}

.apt-next__free {
    color: var(--c-muted);
    font-size: var(--fs-tiny);
}

.apt-toolbar {
    align-items: flex-end;
}

.apt-toolbar .field {
    flex: 1 1 12rem;
}

.apt-toolbar .apt-toolbar__search {
    flex: 2 1 18rem;
}

.apt-day-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.apt-row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-2);
}

.table__actions .apt-row-actions > * {
    margin-left: 0;
}

.apt-time-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.apt-time-cell strong {
    display: block;
    color: var(--c-text-strong);
    font-size: var(--fs-base);
}

/* ==== Einrichtung: Wochenplan-Editor ======================================== */

.apt-week {
    width: 100%;
}

.apt-week th[scope="row"] {
    width: 9rem;
    white-space: nowrap;
}

.apt-week__windows {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
}

.apt-week__window {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.apt-week__window input {
    width: 7.5rem;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-white);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.apt-week__window input:focus {
    border-color: var(--c-blue);
    outline: none;
    box-shadow: 0 0 0 2px var(--c-blue-light);
}

.apt-week__window input[aria-invalid="true"] {
    border-color: var(--c-red);
    box-shadow: 0 0 0 1px var(--c-red);
}

.apt-week__sep {
    color: var(--c-muted);
}

.apt-rules {
    width: 100%;
}

.apt-rules select {
    min-width: 12rem;
}

.apt-preview {
    display: grid;
    gap: var(--space-3);
}

.apt-preview__day {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-3);
}

.apt-preview__day strong {
    min-width: 11rem;
    color: var(--c-text-strong);
}

.apt-preview__times {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

@media print {
    .apt-lang,
    .apt-actions,
    .apt-restart {
        display: none !important;
    }
}
