/* features/backdate.css — Besitzer: Feature "backdate" (Tages-Sheet im Kalender).
   Nur Klassen mit eigenem Präfix (.backdate-…) bzw. innerhalb der eigenen Container;
   Farben über die CSS-Variablen aus style.css (:root), damit Dark Mode greift.
   Desktop: zentrierter Dialog · Telefon (≤ 560 px): Bottom-Sheet über die volle Breite. */

/* Hintergrund wie .overlay (gleiche Ebene 60, Toast liegt mit 80 darüber → Undo bleibt klickbar). */
.backdate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.45);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.backdate-overlay[hidden] { display: none; }
body.backdate-open { overflow: hidden; }

.backdate-sheet {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 26px 24px;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: fade 0.24s ease;
}
.backdate-sheet:focus { outline: none; }

.backdate-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.backdate-head-text { flex: 1; min-width: 0; }
.backdate-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0;
  overflow-wrap: anywhere;
}
.backdate-sub { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.backdate-close { flex: none; margin-top: -6px; }

/* Einträge des Tages — Optik wie der Verlauf (.log-item). */
.backdate-list { list-style: none; margin: 0 0 6px; padding: 0; border-top: 1px solid var(--line); }
.backdate-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.backdate-item.pending .badge { opacity: 0.6; }
.backdate-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.backdate-item-reason { font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.backdate-item-meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.backdate-tag,
.backdate-pending {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--muted);
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}
.backdate-del {
  flex: none;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  font-size: 16px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 10px;
}
.backdate-del:hover { color: var(--debt); background: var(--debt-soft); }
.backdate-del:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.backdate-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; border-bottom: 1px solid var(--line); }

.backdate-future-hint { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

.backdate-form { margin-top: 18px; }
.backdate-form[hidden] { display: none; }
.backdate-form-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
.backdate-hint { color: var(--muted); font-size: 12px; margin: -4px 0 12px; }
.backdate-add { width: 100%; }

/* Live-Region für Screenreader (Meldungen zu Hinzufügen/Entfernen) — visuell versteckt. */
.backdate-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.backdate-sheet { position: relative; }

/* Zukünftige Kalendertage (Dekorator): zurückgenommen, kein Hover-Effekt. */
.cal-cell.backdate-future { opacity: 0.45; }
.cal-cell.clickable.backdate-future { cursor: default; }
.cal-cell.clickable.backdate-future:hover { border-color: var(--line); }

[dir="rtl"] .backdate-item-text { text-align: right; }

@media (max-width: 560px) {
  .backdate-overlay { align-items: flex-end; padding: 0; }
  .backdate-sheet {
    max-width: none;
    max-height: 88vh;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .backdate-title { font-size: 20px; }
  /* Der Undo-Toast sitzt unten und würde den Eintragen-Button verdecken → solange
     das Sheet offen ist, oben anzeigen (nur über die eigene body-Klasse). */
  body.backdate-open .sync-toast { bottom: auto; top: 16px; left: 16px; right: 16px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .backdate-sheet { animation: none; }
}
