.calendar {
  max-width: 420px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.calendar-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.calendar-nav {
  display: flex;
  gap: 0.4rem;
}

.calendar-nav button {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.calendar-nav button:hover:not(:disabled) {
  background: var(--color-surface);
}

.calendar-nav button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekdays {
  margin-bottom: 4px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.calendar-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
}

.calendar-day.is-empty {
  cursor: default;
}

.calendar-day.is-past {
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.4;
}

.calendar-day.is-free:hover {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.calendar-day.is-blocked {
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Abreisetag (letzter Tag einer Buchung), nur diese eine Buchung endet hier,
   niemand reist am selben Tag an: halb rot (diagonal), halb frei. */
.calendar-day.is-checkout-only {
  background: linear-gradient(135deg, var(--color-danger) 50%, transparent 50%);
  color: #fff;
}

/* Wechseltag: eine Buchung endet, eine andere beginnt am selben Kalendertag —
   gerade Linie durch die Zelle statt Diagonale, beide Hälften rot. */
.calendar-day.is-turnover {
  background: linear-gradient(
    to bottom,
    var(--color-danger) calc(50% - 1px),
    #fff calc(50% - 1px) calc(50% + 1px),
    var(--color-danger) calc(50% + 1px)
  );
  color: #fff;
}

.calendar-day.is-checkin-blocked-pm {
  background: linear-gradient(
    315deg,
    var(--color-border) 50%,
    transparent 50%
  );
}

.calendar-day.is-selected-start,
.calendar-day.is-selected-end {
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
}

.calendar-day.is-in-range {
  background: rgba(29, 95, 176, 0.15);
}

/* Admin: Ring um die Tage einer angeklickten Buchung, unabhängig von deren
   Belegungsfarbe (Ring statt Hintergrundfarbe, damit der Status weiter sichtbar bleibt). */
.calendar-day.is-highlighted {
  box-shadow: inset 0 0 0 3px var(--color-text);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.calendar-legend i {
  width: 0.8em;
  height: 0.8em;
  border-radius: 3px;
  display: inline-block;
}

.calendar-legend .swatch-free {
  border: 1px solid var(--color-border);
}

.calendar-legend .swatch-blocked {
  background: var(--color-border);
}

.calendar-legend .swatch-turnover {
  background: linear-gradient(135deg, var(--color-danger) 50%, transparent 50%);
  border: 1px solid var(--color-border);
}

.calendar-legend .swatch-selected {
  background: var(--color-accent);
}

.calendar-selection-summary {
  margin-top: 1rem;
  font-size: 0.9rem;
}
