/* Terminbuchung – Widget im Stil der Website (Variablen aus :root werden geerbt). */

.tb-root {
  --tb-primary: var(--primary-color, #9A865C);
  --tb-accent: var(--secondary-color, #008031);
  --tb-soft: var(--tertiary-color, #F2EAE3);
  --tb-tint: var(--utility-color, #F3FFF8);
  --tb-text: var(--text-color, #404040);
  --tb-line: rgba(64, 64, 64, .18);
  --tb-radius: 10px;
  --tb-shadow: 0 12px 15px 0 rgba(0, 0, 0, .24), 0 17px 50px 0 rgba(0, 0, 0, .19);

  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  box-sizing: border-box;
  background: rgba(40, 40, 40, .55);
  font-family: var(--text-font, Verdana), Verdana, sans-serif;
  color: var(--tb-text);
  animation: tb-fade .18s ease-out;
}
.tb-root[hidden] { display: none; }
.tb-root *, .tb-root *::before, .tb-root *::after { box-sizing: border-box; }

@keyframes tb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tb-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes tb-spin { to { transform: rotate(360deg); } }

.tb-dialog {
  width: 100%;
  max-width: 40rem;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--tb-radius);
  box-shadow: var(--tb-shadow);
  overflow: hidden;
  animation: tb-rise .22s ease-out;
}

/* ------------------------------------------------------------------ Kopfbereich */
.tb-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem .9rem;
  background: var(--tb-soft);
  border-bottom: 1px solid var(--tb-line);
}
.tb-head-text { min-width: 0; }
.tb-title {
  margin: 0;
  font-family: var(--primary-font, Georgia), Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--tb-primary);
}
.tb-subtitle {
  margin: .3rem 0 0;
  font-size: .82rem;
  line-height: 1.35;
  opacity: .8;
}
.tb-close {
  margin-left: auto;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .7);
  color: var(--tb-text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.tb-close:hover { background: #fff; transform: scale(1.08); }

/* ------------------------------------------------------------------ Schrittanzeige */
.tb-steps {
  display: flex;
  gap: .35rem;
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--tb-line);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tb-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  opacity: .45;
}
.tb-step-num {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: .72rem;
}
.tb-step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-step.is-active { opacity: 1; color: var(--tb-accent); font-weight: 700; }
.tb-step.is-done { opacity: .85; color: var(--tb-primary); }
.tb-step.is-done .tb-step-num { background: var(--tb-primary); border-color: var(--tb-primary); color: #fff; }
.tb-step.is-active .tb-step-num { background: var(--tb-accent); border-color: var(--tb-accent); color: #fff; }

/* ------------------------------------------------------------------ Inhalt */
.tb-body {
  padding: 1.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tb-section-title {
  margin: 0 0 .9rem;
  font-size: 1rem;
  font-weight: 700;
}
.tb-hint { margin: 0 0 1rem; font-size: .82rem; line-height: 1.5; opacity: .85; }

/* Auswahl-Karten (Leistung) */
.tb-list { display: flex; flex-direction: column; gap: .6rem; }
.tb-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  width: 100%;
  padding: .85rem 1rem;
  text-align: left;
  background: #fff;
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.tb-card:hover, .tb-card:focus-visible {
  border-color: var(--tb-primary);
  background: var(--tb-tint);
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, .16);
  outline: none;
}
.tb-card-icon {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tb-soft);
  color: var(--tb-primary);
  font-size: 1.1rem;
}
.tb-card-text { min-width: 0; flex: 1; }
.tb-card-title { display: block; font-weight: 700; line-height: 1.35; font-size: .95rem; }
.tb-card-meta { display: block; margin-top: .2rem; font-size: .78rem; opacity: .75; }
.tb-card-arrow { flex: none; color: var(--tb-primary); opacity: .6; }

/* Tagesauswahl */
.tb-days {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .15rem .15rem .7rem;
  scroll-snap-type: x proximity;
}
.tb-day {
  flex: none;
  min-width: 4.6rem;
  padding: .5rem .6rem;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}
.tb-day:hover { border-color: var(--tb-primary); }
.tb-day.is-selected {
  background: var(--tb-primary);
  border-color: var(--tb-primary);
  color: #fff;
}
.tb-day-wd { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.tb-day-date { display: block; font-size: 1rem; font-weight: 700; line-height: 1.3; }
.tb-day-count { display: block; font-size: .68rem; opacity: .75; }

.tb-times {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr));
  gap: .5rem;
  margin-top: .3rem;
}
.tb-time {
  padding: .6rem .4rem;
  background: #fff;
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s ease;
}
.tb-time:hover, .tb-time:focus-visible {
  background: var(--tb-accent);
  border-color: var(--tb-accent);
  color: #fff;
  outline: none;
}

.tb-day-heading {
  margin: 1.1rem 0 .6rem;
  font-size: .88rem;
  font-weight: 700;
  color: var(--tb-primary);
}

/* Zusammenfassung des gewählten Termins */
.tb-summary {
  display: flex;
  gap: .75rem;
  padding: .8rem 1rem;
  margin-bottom: 1.1rem;
  background: var(--tb-tint);
  border: 1px solid var(--tb-accent);
  border-radius: var(--tb-radius);
  font-size: .88rem;
  line-height: 1.5;
}
.tb-summary i { color: var(--tb-accent); margin-top: .15rem; }
.tb-summary strong { display: block; }
.tb-summary-when { display: block; color: var(--tb-accent); font-weight: 700; }

/* Formular */
.tb-fields { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.tb-field { display: flex; flex-direction: column; gap: .25rem; }
.tb-field--wide { grid-column: 1 / -1; }
.tb-field label { font-size: .78rem; font-weight: 700; letter-spacing: .01em; }
.tb-field .tb-opt { font-weight: 400; opacity: .6; }
.tb-field input,
.tb-field textarea {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--tb-line);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: .95rem;
  color: inherit;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.tb-field input:focus,
.tb-field textarea:focus {
  outline: none;
  border-color: var(--tb-accent);
  box-shadow: 0 0 0 3px rgba(0, 128, 49, .12);
}
.tb-field input[aria-invalid="true"] { border-color: #c0392b; }
.tb-field textarea { resize: vertical; min-height: 3.5rem; }
.tb-honey { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.tb-notice {
  margin-top: 1rem;
  padding: .75rem .9rem;
  background: var(--tb-soft);
  border-radius: var(--tb-radius);
  font-size: .78rem;
  line-height: 1.5;
  white-space: pre-line;
}
.tb-privacy { margin-top: .8rem; font-size: .74rem; line-height: 1.5; opacity: .8; }
.tb-privacy a { color: var(--tb-primary); }

/* ------------------------------------------------------------------ Fußbereich */
.tb-foot {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--tb-line);
  background: #fbfbfb;
}
.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--tb-radius);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
}
.tb-btn:disabled { opacity: .55; cursor: default; }
.tb-btn--ghost { background: transparent; border-color: var(--tb-line); color: var(--tb-text); }
.tb-btn--ghost:hover:not(:disabled) { border-color: var(--tb-primary); color: var(--tb-primary); }
.tb-btn--primary { background: var(--tb-accent); color: #fff; }
.tb-btn--primary:hover:not(:disabled) { filter: brightness(1.12); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.tb-foot-spacer { flex: 1; }

/* ------------------------------------------------------------------ Zustände */
.tb-state { padding: 2.5rem 1rem; text-align: center; }
.tb-spinner {
  width: 2.1rem;
  height: 2.1rem;
  margin: 0 auto .9rem;
  border: 3px solid var(--tb-soft);
  border-top-color: var(--tb-primary);
  border-radius: 50%;
  animation: tb-spin .8s linear infinite;
}
.tb-state p { margin: 0; font-size: .9rem; opacity: .8; }
.tb-error {
  padding: .85rem 1rem;
  background: #fdf0ee;
  border: 1px solid #e2b4ac;
  border-radius: var(--tb-radius);
  color: #96271a;
  font-size: .85rem;
  line-height: 1.5;
}
.tb-error--inline { margin-bottom: 1rem; }

.tb-done { padding: 1.5rem .5rem; text-align: center; }
.tb-done-icon {
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tb-accent);
  color: #fff;
  font-size: 1.7rem;
}
.tb-done h3 {
  margin: 0 0 .6rem;
  font-family: var(--primary-font, Georgia), Georgia, serif;
  font-size: 1.3rem;
  color: var(--tb-primary);
}
.tb-done p { margin: 0 auto .6rem; max-width: 28rem; font-size: .88rem; line-height: 1.6; white-space: pre-line; }
.tb-reference {
  display: inline-block;
  margin-top: .3rem;
  padding: .3rem .85rem;
  background: var(--tb-soft);
  border-radius: 100rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.tb-done-mail {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  margin: 1.1rem auto .4rem;
  padding: .7rem .9rem;
  max-width: 26rem;
  background: var(--tb-tint);
  border: 1px solid var(--tb-accent);
  border-radius: var(--tb-radius);
  color: var(--tb-accent);
  font-weight: 700;
  white-space: normal;
}
.tb-done-mail i { font-size: 1.1rem; }
.tb-done-note { font-size: .8rem; opacity: .75; }

@media (max-width: 40rem) {
  .tb-root { padding: 0; }
  .tb-dialog { max-width: none; height: 100%; max-height: 100%; border-radius: 0; }
  .tb-fields { grid-template-columns: 1fr; }
  .tb-step-label { display: none; }
  .tb-step { flex: none; }
  .tb-title { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-root, .tb-dialog { animation: none; }
  .tb-spinner { animation-duration: 2s; }
}
