/* =====================================================================
   app.css — Layout & Komponenten der Terminbuchung.
   Nutzt ausschliesslich die Custom Properties aus brands.css.
   Nichts hier drin ist firmenspezifisch.
   ===================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 96px;
  min-height: 100vh;
  background: var(--brand-page-bg);
  color: var(--brand-ink);
  font-family: var(--brand-font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--brand-font-headline);
  font-weight: var(--brand-headline-weight);
  letter-spacing: var(--brand-headline-spacing);
  margin: 0;
}

a { color: var(--brand-primary); }

.tb-app { max-width: 1080px; margin: 0 auto; padding: 32px 20px 0; }

/* ------------------------------- Header ------------------------------- */
.tb-header { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }

.tb-brand { display: flex; align-items: center; gap: 12px; }

.tb-brand__logo {
  width: var(--brand-logo-size);
  height: var(--brand-logo-size);
  flex: 0 0 auto;
  border-radius: var(--brand-radius-sm);
  background-image: var(--brand-logo);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--brand-primary);
  color: var(--brand-primary-contrast);
  display: grid; place-items: center;
  font-weight: 700; font-size: calc(var(--brand-logo-size) * .55);
  line-height: 1;
}
/* Initiale als Ersatz, solange kein Logo-Bild hinterlegt ist.
   Wer --brand-logo setzt, setzt --brand-logo-initials auf "" (siehe brands.css). */
.tb-brand__logo::before { content: var(--brand-logo-initials, ""); }

.tb-brand__name { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
.tb-brand__name::after { content: var(--brand-name); }

.tb-header__claim { margin: 0 0 0 auto; color: var(--brand-ink-soft); font-size: .95rem; }
.tb-header__claim::after { content: var(--brand-claim); }

/* -------------------------------- Cards ------------------------------- */
.tb-card {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-lg);
  box-shadow: var(--brand-shadow);
  padding: 22px 24px 24px;
  margin-bottom: 18px;
  transition: opacity .18s ease;
}
.tb-card[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.tb-card__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.tb-card__head h2 { font-size: 1.08rem; }
.tb-card__hint { margin: 2px 0 18px; color: var(--brand-ink-soft); font-size: .9rem; }

.tb-step {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
  color: var(--brand-primary);
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tb-card__done { margin-left: auto; color: var(--brand-ok); font-size: .85rem; font-weight: 600; }

/* ------------------------------- Buttons ------------------------------ */
.tb-btn {
  font: inherit;
  border-radius: var(--brand-radius-sm);
  border: 1px solid var(--brand-border-strong);
  background: var(--brand-surface);
  color: var(--brand-ink);
  padding: 9px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}
.tb-btn:hover:not(:disabled) { border-color: var(--brand-primary); color: var(--brand-primary); }
.tb-btn:active:not(:disabled) { transform: translateY(1px); }
.tb-btn:disabled { opacity: .45; cursor: not-allowed; }

.tb-btn--primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-primary-contrast);
  font-weight: 600;
  padding: 11px 22px;
}
.tb-btn--primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: var(--brand-primary-contrast);
}
.tb-btn--ghost { border-color: transparent; background: transparent; color: var(--brand-ink-soft); padding: 6px 10px; }
.tb-btn--icon { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 1.05rem; }
.tb-btn--sm { padding: 6px 10px; font-size: .87rem; }

:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ------------------------------- Dauer -------------------------------- */
.tb-duration { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tb-chip {
  font: inherit;
  border: 1px solid var(--brand-border-strong);
  background: var(--brand-surface);
  color: var(--brand-ink);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s, color .15s;
}
.tb-chip:hover { border-color: var(--brand-primary); }
.tb-chip[aria-pressed="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-primary-contrast);
  font-weight: 600;
}

.tb-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--brand-border-strong); border-radius: var(--brand-radius-sm); overflow: hidden; }
.tb-stepper button { font: inherit; width: 38px; border: 0; background: var(--brand-surface-alt); color: var(--brand-ink); cursor: pointer; font-size: 1.1rem; }
.tb-stepper button:hover { background: color-mix(in srgb, var(--brand-primary) 10%, transparent); color: var(--brand-primary); }
.tb-stepper input {
  font: inherit; width: 72px; border: 0; border-inline: 1px solid var(--brand-border);
  text-align: center; background: var(--brand-surface); color: var(--brand-ink);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.tb-stepper input::-webkit-outer-spin-button,
.tb-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tb-unit { color: var(--brand-ink-soft); font-size: .92rem; }

/* ------------------------- Layout Datum + Zeit ------------------------ */
.tb-split { display: grid; grid-template-columns: minmax(300px, 360px) 1fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .tb-split { grid-template-columns: 1fr; } }

/* ------------------------------ Kalender ------------------------------ */
.tb-cal__nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tb-cal__label { flex: 1; text-align: center; font-weight: 650; font-size: 1rem; }

.tb-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tb-cal__dow {
  text-align: center; font-size: .74rem; font-weight: 700;
  color: var(--brand-ink-muted); text-transform: uppercase; letter-spacing: .06em;
  padding-bottom: 6px;
}

.tb-day {
  font: inherit;
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--brand-radius-sm);
  background: var(--brand-surface-alt);
  color: var(--brand-ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  transition: background .13s, color .13s, border-color .13s;
}
.tb-day:hover:not(:disabled) { background: color-mix(in srgb, var(--brand-primary) 14%, transparent); border-color: var(--brand-primary); }
.tb-day[aria-pressed="true"] {
  background: var(--brand-primary); border-color: var(--brand-primary);
  color: var(--brand-primary-contrast); font-weight: 700;
}
.tb-day:disabled { background: transparent; color: var(--brand-ink-muted); cursor: not-allowed; opacity: .55; text-decoration: line-through; text-decoration-thickness: 1px; }
.tb-day--other { visibility: hidden; }
.tb-day--today:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 1.5px var(--brand-accent); }
.tb-day__dot {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--brand-accent);
}
.tb-day[aria-pressed="true"] .tb-day__dot { background: var(--brand-primary-contrast); }
.tb-day:disabled .tb-day__dot { display: none; }

.tb-cal__legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: .8rem; color: var(--brand-ink-soft); }
.tb-cal__legend span { display: inline-flex; align-items: center; gap: 6px; }
.tb-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--brand-border-strong); }
.tb-swatch--free { background: var(--brand-surface-alt); }
.tb-swatch--busy { background: var(--brand-busy-bg); }
.tb-swatch--off { background: transparent; }

.tb-tz { margin-top: 12px; font-size: .8rem; color: var(--brand-ink-muted); }

/* ------------------------------ Timeline ------------------------------ */
.tb-tl__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tb-tl__date { font-weight: 650; }
.tb-tl__zoom { display: flex; align-items: center; gap: 4px; }

.tb-tl__scroll {
  position: relative;
  max-height: min(62vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  background: var(--brand-closed-bg);
}

.tb-tl {
  position: relative;
  display: grid;
  grid-template-columns: 62px 1fr;
  --tb-ppm: 1.15;              /* Pixel pro Minute (Zoom) */
}

.tb-tl__axis { position: relative; border-right: 1px solid var(--brand-border); background: var(--brand-surface); }
.tb-tl__tick {
  position: absolute; right: 8px; transform: translateY(-50%);
  font-size: .74rem; color: var(--brand-ink-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.tb-tl__col {
  position: relative;
  touch-action: none;                 /* Drag statt Scroll auf Touch */
  -webkit-user-select: none; user-select: none;
  cursor: crosshair;
  background: var(--brand-closed-bg);
}
.tb-tl__col[data-mode="move"] { cursor: grabbing; }

.tb-tl__line { position: absolute; left: 0; right: 0; height: 1px; background: var(--brand-border); pointer-events: none; }
.tb-tl__line--half { background: color-mix(in srgb, var(--brand-border) 55%, transparent); }

.tb-band { position: absolute; left: 0; right: 0; pointer-events: none; }
.tb-band--free { background: var(--brand-free-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-accent) 22%, transparent); }
.tb-band--busy {
  background: var(--brand-busy-bg);
  border-top: 1px solid var(--brand-border-strong);
  border-bottom: 1px solid var(--brand-border-strong);
  color: var(--brand-busy-ink);
  font-size: .74rem;
  padding: 2px 8px;
  overflow: hidden;
}
.tb-band--busy::after { content: attr(data-label); }
.tb-band--past { background: color-mix(in srgb, var(--brand-ink) 7%, transparent); }
.tb-band--buffer {
  background: repeating-linear-gradient(90deg,
    color-mix(in srgb, var(--brand-ink) 5%, transparent) 0 4px,
    transparent 4px 8px);
  border-block: 1px dotted var(--brand-border-strong);
  font-size: .68rem; color: var(--brand-ink-muted); padding: 0 8px; overflow: hidden;
}
.tb-band--buffer::after { content: attr(data-label); }
.tb-swatch--buffer { background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--brand-ink) 12%, transparent) 0 3px, transparent 3px 6px); }

.tb-sel {
  position: absolute; left: 6px; right: 6px;
  background: var(--brand-selection-bg);
  border: 2px solid var(--brand-selection-border);
  border-radius: var(--brand-radius-sm);
  color: var(--brand-selection-ink);
  cursor: grab;
  min-height: 22px;
  box-shadow: var(--brand-shadow-sm);
  display: flex; flex-direction: column; justify-content: center;
  padding: 2px 10px;
  overflow: hidden;
  z-index: 3;
}
.tb-sel:active { cursor: grabbing; }
.tb-sel.is-invalid { border-color: var(--brand-error); background: color-mix(in srgb, var(--brand-error) 14%, transparent); color: var(--brand-error); }
.tb-sel__time { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-sel__dur { font-size: .74rem; opacity: .85; white-space: nowrap; }
.tb-sel__handle {
  position: absolute; left: 0; right: 0; height: 12px;
  cursor: ns-resize; display: grid; place-items: center;
}
.tb-sel__handle::before { content: ""; width: 26px; height: 3px; border-radius: 2px; background: var(--brand-selection-border); }
.tb-sel__handle--top { top: -6px; }
.tb-sel__handle--bottom { bottom: -6px; }

.tb-ghost {
  position: absolute; left: 6px; right: 6px;
  border: 1px dashed var(--brand-primary);
  border-radius: var(--brand-radius-sm);
  background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
  pointer-events: none; z-index: 2;
}

.tb-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--brand-error); pointer-events: none; z-index: 4; }
.tb-now::before { content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-error); }

.tb-tl__empty { padding: 28px 20px; text-align: center; color: var(--brand-ink-soft); }

.tb-tl__foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.tb-tl__foot label { font-size: .85rem; color: var(--brand-ink-soft); }
.tb-time-input { font: inherit; font-variant-numeric: tabular-nums; padding: 7px 9px; border: 1px solid var(--brand-border-strong); border-radius: var(--brand-radius-sm); background: var(--brand-surface); color: var(--brand-ink); }

.tb-msg { margin-top: 10px; font-size: .87rem; min-height: 1.2em; }
.tb-msg--error { color: var(--brand-error); }
.tb-msg--ok { color: var(--brand-ok); }
.tb-msg--info { color: var(--brand-ink-soft); }

/* ------------------------------ Formular ------------------------------ */
.tb-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
@media (max-width: 700px) { .tb-grid2 { grid-template-columns: 1fr; } }

.tb-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.tb-field--full { grid-column: 1 / -1; }
.tb-field label { font-size: .86rem; font-weight: 600; color: var(--brand-ink-soft); }
.tb-field .tb-req { color: var(--brand-error); }

.tb-input, .tb-select, .tb-textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--brand-border-strong);
  border-radius: var(--brand-radius-sm);
  background: var(--brand-surface);
  color: var(--brand-ink);
}
.tb-input::placeholder, .tb-textarea::placeholder { color: var(--brand-ink-muted); }
.tb-input:focus, .tb-select:focus, .tb-textarea:focus { border-color: var(--brand-primary); box-shadow: var(--brand-focus-ring); outline: none; }
.tb-input[aria-invalid="true"], .tb-select[aria-invalid="true"] { border-color: var(--brand-error); }
.tb-textarea { min-height: 84px; resize: vertical; }
.tb-hint { font-size: .78rem; color: var(--brand-ink-muted); }

.tb-participants { display: flex; flex-direction: column; gap: 10px; }
.tb-participant { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; align-items: center; }
@media (max-width: 620px) { .tb-participant { grid-template-columns: 1fr auto; } .tb-participant .tb-p-mail { grid-column: 1 / -1; } }

.tb-check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--brand-ink-soft); }
.tb-check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--brand-primary); flex: 0 0 auto; }

.tb-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

.tb-known {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--brand-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-accent) 35%, transparent);
  border-radius: var(--brand-radius-sm);
  padding: 10px 14px; margin-bottom: 16px; font-size: .88rem;
}

/* --------------------------- Zusammenfassung -------------------------- */
.tb-summary { display: grid; gap: 8px; background: var(--brand-surface-alt); border: 1px solid var(--brand-border); border-radius: var(--brand-radius); padding: 14px 16px; margin-bottom: 18px; }
.tb-summary dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.tb-summary dt { color: var(--brand-ink-soft); }
.tb-summary dd { margin: 0; font-weight: 600; }
@media (max-width: 560px) { .tb-summary dl { grid-template-columns: 1fr; gap: 2px 0; } .tb-summary dd { margin-bottom: 8px; } }

.tb-bar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  background: color-mix(in srgb, var(--brand-surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--brand-border);
  padding: 12px 20px;
}
.tb-bar__in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.tb-bar__txt { font-size: .9rem; color: var(--brand-ink-soft); }
.tb-bar__txt strong { color: var(--brand-ink); }
.tb-bar__btn { margin-left: auto; }

/* ------------------------------ Ergebnis ------------------------------ */
.tb-result { text-align: center; padding: 12px 0 4px; }
.tb-result__icon { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: color-mix(in srgb, var(--brand-ok) 16%, transparent); color: var(--brand-ok); }
.tb-result--error .tb-result__icon { background: color-mix(in srgb, var(--brand-error) 16%, transparent); color: var(--brand-error); }
.tb-result h2 { margin-bottom: 8px; }
.tb-result p { color: var(--brand-ink-soft); margin: 0 auto 8px; max-width: 46ch; }
.tb-result__actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ------------------------------- Footer ------------------------------- */
.tb-footer {
  display: flex; justify-content: center; align-items: center; gap: 8px;
  flex-wrap: wrap; text-align: center;
  color: var(--brand-ink-muted); font-size: .8rem; padding: 22px 0 8px;
}
.tb-footer__brand::before { content: var(--brand-name); }
.tb-footer__brand::after { content: "·"; color: var(--brand-border-strong); }
.tb-footer__link { color: var(--brand-ink-muted); text-decoration: underline; text-decoration-color: var(--brand-border-strong); }
.tb-footer__link:hover { color: var(--brand-primary); text-decoration-color: var(--brand-primary); }
.tb-footer__link + .tb-footer__link::before { content: "·"; margin-right: 8px; color: var(--brand-border-strong); text-decoration: none; }

.tb-spinner {
  width: 15px; height: 15px; border-radius: 50%; display: inline-block; vertical-align: -2px;
  border: 2px solid color-mix(in srgb, var(--brand-primary-contrast) 40%, transparent);
  border-top-color: var(--brand-primary-contrast);
  animation: tb-spin .7s linear infinite;
}
@keyframes tb-spin { to { transform: rotate(360deg); } }

.tb-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}
