/* ==========================================================
   Packliste - eigenständige kleine App, rein optisch an die Web-App auf
   diesem Account angelehnt (Farb-Tokens/Radien/Schatten, die
   Doppel-Checkbox-Optik pro Zeile aus deren Packlisten-Vorlage übernommen)
   - hier aber bewusst schlank auf das Nötigste reduziert, kein großes
   Design-System, kein Branding (privates Projekt).
   ========================================================== */

:root {
  --color-bg: #f5f6fb;
  --color-surface: #ffffff;
  --color-surface-2: #fbfbfe;
  --color-border: #e6e8f2;
  --color-border-strong: #d7d9e8;
  --color-text: #14152b;
  --color-text-muted: #676b84;
  --color-text-faint: #9598ae;

  --color-accent: #0071e3;
  --color-accent-hover: #0058b9;
  --color-accent-soft: #e8f2fd;

  --color-success: #16a34a;
  --color-success-soft: #e6f8ed;
  --color-danger: #dc2626;
  --color-danger-soft: #fdeaea;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 28px -6px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.05);

  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand .dim { color: var(--color-text-faint); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 12.5px; color: var(--color-text-muted); }

.shell {
  display: flex; min-height: calc(100% - 53px);
}
.sidebar {
  width: 240px; flex-shrink: 0; border-right: 1px solid var(--color-border);
  background: var(--color-surface); padding: 18px 14px; display: flex; flex-direction: column; gap: 10px;
}
.sidebar-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.sidebar-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-text-faint); padding: 0 6px;
}
.list-nav { display: flex; flex-direction: column; gap: 2px; }
.list-nav-row {
  display: flex; align-items: center; gap: 0; border-radius: var(--radius-sm); cursor: grab;
}
.list-nav-row:active { cursor: grabbing; }
.list-nav-row.is-dragging { opacity: 0.4; }
.list-nav-row .drag-handle { width: 14px; height: 20px; font-size: 11px; }
.list-nav-row:hover .drag-handle { opacity: 1; }
.list-nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1; min-width: 0;
  padding: 9px 10px; border-radius: var(--radius-sm); text-decoration: none;
  color: var(--color-text); font-size: 13.5px; font-weight: 500;
}
.list-nav-item:hover { background: var(--color-bg); }
.list-nav-item.is-active { background: var(--color-accent-soft); color: var(--color-accent-hover); font-weight: 700; }
.list-nav-item .progress-pill {
  font-size: 10.5px; font-weight: 600; color: var(--color-text-faint); flex-shrink: 0;
}
.list-nav-item.is-active .progress-pill { color: var(--color-accent-hover); }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
.main-inner { max-width: 760px; margin: 0 auto; }

/* ---------- Cards / buttons / forms (schlanke Untermenge) ---------- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--color-border-strong);
  background: var(--color-surface); color: var(--color-text); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--color-bg); }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; padding: 6px 8px; }
.btn-ghost:hover { background: var(--color-bg); }
.btn-danger { color: var(--color-danger); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

input[type="text"], input[type="password"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); background: var(--color-surface-2); font-size: 13.5px;
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none; border-color: var(--color-accent); background: var(--color-surface);
}
select {
  padding: 6px 8px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-surface); font-size: 12.5px;
}
label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
/* .card.login-card (statt nur .login-card): braucht höhere Spezifität als
   die spätere ".card { padding: 4px 18px; }"-Regel für die Content-Karten
   der Packliste, sonst gewinnt bei gleicher Spezifität die spätere Regel im
   Stylesheet und das Padding hier wird überschrieben (genau das Problem:
   "Elemente hängen direkt am Rand der weißen Box"). */
.card.login-card { width: 100%; max-width: 340px; padding: 32px 28px; }
.login-card h1 { font-size: 17px; margin: 0 0 4px; }
.login-card p.hint { font-size: 12.5px; color: var(--color-text-muted); margin: 0 0 20px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-error {
  background: var(--color-danger-soft); color: var(--color-danger); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px;
}

/* ---------- Liste: Kopf + Fortschritt ---------- */
.list-header { margin-bottom: 18px; }
.list-title-row { display: flex; align-items: center; gap: 8px; }
.list-title {
  font-size: 21px; font-weight: 700; letter-spacing: -0.01em; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 3px 6px; background: transparent; min-width: 60px;
}
.list-title:hover, .list-title:focus { border-color: var(--color-border-strong); background: var(--color-surface); outline: none; }

.list-dates-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; row-gap: 6px; }
.list-date {
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
  background: var(--color-surface-2); padding: 6px 8px; font-size: 12.5px; color: var(--color-text);
}
.list-date:hover, .list-date:focus { outline: none; border-color: var(--color-accent); background: var(--color-surface); }
.date-sep { color: var(--color-text-faint); font-size: 12.5px; }
.nights-badge {
  font-size: 11px; font-weight: 700; color: var(--color-accent-hover); background: var(--color-accent-soft);
  border-radius: 999px; padding: 4px 10px;
}
.nights-badge:empty { display: none; }
/* Icon-Buttons statt Text-Links (siehe Chat-Verlauf: "die ganzen Links in
   der Mitte durch Icons ersetzen ... in einer Linie mit dem Datum"). */
.list-icon-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.progress-row { display: flex; gap: 18px; margin-top: 10px; font-size: 12px; color: var(--color-text-muted); }
.progress-row b { color: var(--color-text); }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--color-text-faint); font-size: 13.5px;
}

/* ---------- Gruppen / Artikel ---------- */
.group { margin-bottom: 28px; }
.group-header {
  display: flex; align-items: center; gap: 4px; margin-bottom: 10px; padding: 2px; border-radius: var(--radius-sm);
  cursor: grab;
}
.group-header:active { cursor: grabbing; }
.group-header.is-dragging { opacity: 0.4; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 22px; flex-shrink: 0;
  color: var(--color-text-faint); font-size: 13px; cursor: grab; opacity: 0; transition: opacity .1s;
  touch-action: none; /* verhindert Scrollen beim Ziehen per Touch */
}
.group-header:hover .drag-handle, .item-row:hover .drag-handle { opacity: 1; }

/* Ganzer Titel klickbar zum Auf-/Zuklappen; Umbenennen nur noch über den
   separaten Edit-Button (siehe Chat-Verlauf: "Gruppen-Titel komplett
   klickbar machen zum auf und zuklappen ... Edit-Button rechts"). */
.group-title-toggle {
  display: flex; align-items: center; flex: 1; min-width: 0;
  border: none; background: transparent; padding: 2px; margin: 0; text-align: left; cursor: pointer;
}
.group.is-collapsed .card { display: none; }
.group-name-text {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--color-accent-hover); background: var(--color-accent-soft);
  border-radius: 999px; padding: 5px 12px;
}
.group-title-toggle:hover .group-name-text { background: #ddeafb; }
.group-name-text.is-static { color: var(--color-text-faint); background: var(--color-bg); }

.group-name-input {
  display: none; flex: 1; min-width: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--color-accent-hover); background: var(--color-surface);
  border: 1px solid var(--color-accent); border-radius: 999px; padding: 5px 12px;
}
.group-header.is-editing .group-title-toggle { display: none; }
.group-header.is-editing .group-name-input { display: block; }

.group-actions { display: flex; gap: 2px; margin-left: auto; flex-shrink: 0; opacity: 0; transition: opacity .1s; }
.group-header:hover .group-actions, .group-header.is-editing .group-actions { opacity: 1; }

/* ---------- Content-Karte: mehr Luft, weniger Kanten (Chat-Verlauf:
   "Design vor allem im Content Bereich etwas cleaner machen") ---------- */
.card { padding: 4px 18px; }
.item-list { min-height: 4px; }
.item-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--color-border);
  cursor: grab;
}
.item-row:active { cursor: grabbing; }
.item-row.is-dragging { opacity: 0.4; }
.item-list > .item-row:last-child { border-bottom: none; }
.item-name {
  flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 6px; padding: 5px 7px;
  background: transparent; font-size: 13.5px;
}
.item-name:hover, .item-name:focus { border-color: var(--color-border-strong); background: var(--color-surface-2); outline: none; }
.item-row.is-done .item-name { color: var(--color-text-faint); text-decoration: line-through; }
.item-list-empty-hint { padding: 10px 0; color: var(--color-text-faint); font-size: 12.5px; }

/* Eine runde Checkbox links vom Artikel, wie in der mitgegebenen PDF (siehe
   Chat-Verlauf: "nur eine Checkbox ... rund und links vom Artikel") - mit
   kleiner Pop-Animation und farblicher Hervorhebung beim Anklicken. */
.check-toggle { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; }
.check-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-circle {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--color-border-strong);
  background: var(--color-surface); display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.check-toggle:active .check-circle { transform: scale(0.88); }
.check-toggle input:checked + .check-circle {
  background: var(--color-success); border-color: var(--color-success);
  animation: check-pop .28s ease;
}
.check-toggle input:checked + .check-circle::after {
  content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}
.check-toggle input:focus-visible + .check-circle { outline: 2px solid var(--color-accent); outline-offset: 2px; }
@keyframes check-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.item-actions { display: flex; gap: 1px; flex-shrink: 0; opacity: 0; transition: opacity .1s; }
.item-row:hover .item-actions, .item-row:focus-within .item-actions { opacity: 1; }

.add-item-row { display: flex; gap: 8px; padding: 10px 0 12px; }
.add-item-row input { flex: 1; }

.icon-btn {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--color-text-faint); border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { background: var(--color-bg); color: var(--color-text); }
.icon-btn.danger:hover { color: var(--color-danger); background: var(--color-danger-soft); }

.toolbar-bottom { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--color-border); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--color-text); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 12.5px; box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity .15s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; }
.toast.is-error { background: var(--color-danger); }

/* Touch-Geräte (kein Hover): Aktions-Buttons (Löschen usw.) UND Drag-Griffe
   immer sichtbar lassen statt nur bei Hover einzublenden - sonst sind sie
   auf dem Handy gar nicht erreichbar. Verschieben per Touch funktioniert
   inzwischen über Pointer Events (siehe <script> in index.php), die
   Drag-Griffe also bewusst NICHT mehr verstecken (siehe Chat-Verlauf: "die
   einzelnen Artikel lassen sich mobile jetzt auch nicht mehr verschieben"). */
@media (hover: none) {
  .item-actions, .group-actions { opacity: 1; }
  .drag-handle { opacity: 1; }
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .topbar { padding: 10px 14px; }
  .brand { font-size: 14px; }

  .sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--color-border);
    padding: 10px 12px; gap: 6px;
  }
  .sidebar-title { font-size: 9.5px; margin-bottom: 0; }
  /* Nur die Listen-Navigation selbst horizontal scrollbar machen - vorher
     wurde die ganze Sidebar (inkl. "Listen"-Titel und "Neue Liste"-Formular)
     zu einer Reihe, dadurch sah die Seite auf dem Handy unübersichtlich aus. */
  .list-nav {
    flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 6px; padding-bottom: 4px;
  }
  .list-nav-row { flex-shrink: 0; }
  .list-nav-item { white-space: nowrap; padding: 7px 9px; font-size: 12.5px; }

  .main { padding: 12px 12px 40px; }

  /* Kopfbereich deutlich kompakter (siehe Chat-Verlauf: "der gesamte obere
     Block ... intelligent komprimieren, die Liste kommt erst sehr weit
     unten") - kleinere Schrift/Abstände, Aktions-Buttons in einer scrollbaren
     statt umbrechenden Reihe. */
  .list-header { margin-bottom: 10px; }
  .list-title { font-size: 17px; padding: 2px 4px; }
  .list-dates-row { margin-top: 4px; gap: 6px; }
  .list-date { padding: 5px 7px; font-size: 12px; flex: 1; min-width: 0; }
  .nights-badge { font-size: 10px; padding: 3px 8px; }
  .list-icon-actions { margin-left: 0; }
  .progress-row { margin-top: 6px; gap: 12px; font-size: 11px; }

  .group { margin-bottom: 14px; }
  .group-header { margin-bottom: 4px; }
  .group-name-text, .group-name-input { font-size: 10px; padding: 4px 10px; }
  .card { padding: 0 12px; }

  /* Artikelzeilen kompakter (siehe Chat-Verlauf: "Artikel ... mobile zu
     groß dargestellt, das kann kleiner sein. Checkbox auch kleiner"). */
  .item-row { gap: 8px; padding: 6px 0; }
  .item-name { font-size: 12.5px; padding: 3px 5px; }
  .check-circle { width: 20px; height: 20px; border-width: 1.4px; }
  .check-toggle input:checked + .check-circle::after { width: 7px; height: 4px; border-width: 2px; }
  .icon-btn { width: 24px; height: 24px; }
  .add-item-row { padding: 6px 0 8px; }
  .add-item-row input { font-size: 12.5px; padding: 7px 9px; }
}

@media (max-width: 420px) {
  .topbar-user { display: none; }
}
