/* Away – common.css
   Gebaut für zwei Momente: Planung am Schreibtisch und Packen am Koffer.
   Der zweite entscheidet, deshalb große Trefferflächen und sichtbarer Fortschritt. */

:root {
  --paper:       #eceff3;
  --card:        #ffffff;
  --ink:         #151a20;
  --ink-soft:    #3c454f;
  --muted:       #69747f;
  --line:        #d6dce3;
  --line-strong: #b9c2cc;
  --accent:      #0f5f52;
  --accent-dark: #0a463c;
  --accent-tint: #e2efeb;
  --danger:      #a3271f;

  --radius:   10px;
  --radius-s: 7px;
  --tap:      44px;
  --wrap:     780px;

  --shadow: 0 1px 2px rgba(21, 26, 32, .06), 0 4px 16px rgba(21, 26, 32, .05);
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -.015em;
}

h1 { font-size: 1.15rem; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .8rem; }

p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }

.eyebrow {
  margin: 0 0 .15rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.error { color: var(--danger); }

/* Formularelemente */

.field { display: block; margin-bottom: 1rem; }

.field > span {
  display: block;
  margin-bottom: .3rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: .55rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:disabled, select:disabled {
  background: #f2f4f7;
  color: var(--muted);
}

/* Schaltflächen */

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-s);
  transition: background-color .12s ease, border-color .12s ease;
}

.btn-primary, .btn-ghost {
  min-height: var(--tap);
  padding: .5rem 1.1rem;
  font-weight: 600;
  font-size: .92rem;
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
}

.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-ghost.danger { color: var(--danger); border-color: #e0c3c0; }
.btn-ghost.danger:hover { border-color: var(--danger); }

.btn-primary:disabled, .btn-ghost:disabled { opacity: .5; cursor: default; }

.btn-primary.small, .btn-ghost.small {
  min-height: 36px;
  padding: .3rem .7rem;
  font-size: .82rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1;
}

.btn-icon:hover { color: var(--danger); }

/* Anmeldung */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 2rem 1.6rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card .brand-row { margin-bottom: .35rem; }
.login-card p { color: var(--muted); font-size: .9rem; margin-bottom: 1.25rem; }
.login-card .btn-primary { width: 100%; }
.login-card .error { margin: .8rem 0 0; font-size: .85rem; }

/* Rahmen */

.app { min-height: 100dvh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1rem;
  background: rgba(236, 239, 243, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

main {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.view-head-actions { display: flex; gap: .5rem; }

/* Reiseliste */

.trip-list { display: flex; flex-direction: column; gap: .5rem; }

.trip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: .9rem 1rem;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.trip-row:hover { border-color: var(--line-strong); }

.trip-row-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.trip-name { font-weight: 600; }

.trip-state {
  flex: 0 0 auto;
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.trip-state.done { background: #e8eaee; color: var(--muted); }

/* Blöcke */

.trip-config, .trip-section, .manage-block {
  margin-bottom: 1.25rem;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section-head, .manage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 1rem;
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}

.hint { margin: .75rem 0 0; }

/* Tags */

.tag-config { margin-top: .5rem; }

.tag-row { display: flex; flex-wrap: wrap; gap: .4rem; }

.tag-chip {
  min-height: 36px;
  padding: .35rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: .85rem;
  font-weight: 600;
}

.tag-chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.tag-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tag-chip:disabled { opacity: .55; cursor: default; }

/* Auswahl der Gegenstände */

.item-group { margin-bottom: 1.25rem; }

.item-cat {
  margin-bottom: .4rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.item-list { border-top: 1px solid var(--line); }

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: var(--tap);
  padding: .35rem 0;
  border-bottom: 1px solid var(--line);
}

.item-row.is-off .item-check { color: var(--muted); }

.check {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  min-width: 0;
}

.check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.item-check { flex: 1 1 auto; min-width: 0; }
.item-check > span:first-of-type { overflow-wrap: anywhere; }
.item-note { flex: 0 0 auto; }

input.qty-input {
  width: 5rem;
  min-width: 5rem;
  flex: 0 0 auto;
  min-height: 38px;
  padding: .35rem .4rem;
  text-align: center;
}

/* Packliste. Die Leiste links füllt sich beim Packen, das ist der Fortschritt. */

.pack-cat { margin-bottom: 1.25rem; }

.packing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--tap);
  padding: .4rem .75rem;
  border-left: 3px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  transition: border-color .15s ease, background-color .15s ease;
}

.packing-row.is-packed {
  border-left-color: var(--accent);
  background: var(--accent-tint);
}

.packing-row.is-packed .ing-name {
  text-decoration: line-through;
  color: var(--muted);
}

.pack-check { flex: 1 1 auto; flex-wrap: wrap; }
.ing-name { font-weight: 500; }

/* Am Bildschirm bleibt die Menge rechts am Zeilenende, im Druck rückt sie
   direkt vor den Namen. Die Reihenfolge im Markup ist die des Drucks. */
.pack-check .ing-amount {
  order: 9;
  margin-left: auto;
}

.ing-amount {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-soft);
}

/* Verwaltung */

.manage-title { margin-bottom: .25rem; }

.tag-admin { display: grid; gap: 1.25rem; margin-top: 1rem; }

.tag-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .5rem;
}

.tag-admin-head h4 {
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag-admin-values { display: flex; flex-direction: column; gap: .25rem; }

.tag-admin-show {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.tag-admin-value {
  flex: 1 1 auto;
  min-height: 38px;
  padding: .3rem .5rem;
  text-align: left;
  border: none;
  background: none;
  color: var(--ink);
  font-weight: 500;
}

.tag-admin-value:hover { color: var(--accent); }

.tag-admin-edit { display: flex; gap: .4rem; align-items: center; }
.tag-admin-edit input[type="text"] { min-height: 38px; }

.item-form {
  margin: 1rem 0 1.5rem;
  padding: 1.1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.item-form-tags { display: grid; gap: .75rem; margin: .5rem 0 1rem; }
.item-form-default { margin-bottom: 1rem; }
.item-form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Übersicht der Gegenstände als Tabelle, damit Mengen und Tags
   ohne Klick sichtbar sind. */

.items-table { margin-top: 1rem; }

.items-table-head,
.items-table-row {
  display: grid;
  grid-template-columns:
    minmax(0, 2fr) minmax(0, 1.3fr) 4.5rem 5.5rem minmax(0, 2.2fr) 34px;
  align-items: center;
  gap: .75rem;
}

.items-table-head {
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--line-strong);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.items-table-group { margin-bottom: 1.25rem; }
.items-table-group .item-cat { margin: 1rem 0 .25rem .5rem; }

.items-table-row {
  min-height: var(--tap);
  padding: .35rem .5rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.items-table-row:hover { background: var(--paper); }

.cell { min-width: 0; }

.cell-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
  font-weight: 500;
}

.cell-qty {
  font-variant-numeric: tabular-nums;
  font-size: .88rem;
  color: var(--ink-soft);
}

.cell-cap { font-variant-numeric: tabular-nums; }

.cell-base { white-space: nowrap; }

.cell-tags { display: flex; flex-wrap: wrap; gap: .25rem; }

.mini-chip {
  padding: .1rem .45rem;
  border-radius: 999px;
  background: #eaeef2;
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.mini-chip.is-base { background: var(--accent-tint); color: var(--accent-dark); }

/* Schmale Bildschirme: Kopfzeile weg, Zeilen zweizeilig. */
@media (max-width: 640px) {
  .items-table-head { display: none; }

  .items-table-row {
    grid-template-columns: minmax(0, 1fr) 34px;
    grid-template-areas:
      "name   del"
      "qty    del"
      "tags   del";
    row-gap: .2rem;
    padding: .6rem .5rem;
  }

  .cell-name { grid-area: name; }
  .cell-qty  { grid-area: qty; }
  .cell-tags { grid-area: tags; }
  .cell-cap  { display: none; }

  /* Grundgepäck rutscht als Chip zu den Tags, die eigene Spalte entfällt. */
  .cell-base {
    grid-area: tags;
    justify-self: end;
    align-self: start;
  }

  .cell-base .muted { display: none; }
  .items-table-row .btn-icon { grid-area: del; }
}

/* Hinweis */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 50;
  padding: .65rem 1.1rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.toast.error { background: var(--danger); }

/* Druck */

.only-print { display: none; }

@media print {
  :root { --paper: #fff; }

  body { background: #fff; font-size: 11pt; }

  .no-print, .toast { display: none !important; }
  .only-print { display: block; }

  main { max-width: none; padding: 0; }

  .trip-section {
    margin: 0 0 1rem;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  .print-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: .5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--ink);
  }

  .print-sub, .print-date { color: var(--muted); font-size: .85rem; }

  .packing-row {
    min-height: 0;
    padding: .2rem .4rem;
    border-left: none;
    background: none !important;
  }

  /* Menge zwischen Kästchen und Name: [ ] 1× Item */
  .pack-check input[type="checkbox"] { order: 0; }
  .pack-check .ing-amount {
    order: 1;
    margin-left: 0;
    min-width: 2.2rem;
    text-align: right;
  }
  .pack-check .ing-name { order: 2; }
  .pack-check .item-note { order: 3; }

  .packing-row.is-packed .ing-name { text-decoration: none; color: var(--ink); }

  .pack-cat { break-inside: avoid; }
}

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

/* Verhältnisfeld im Item-Formular: "X je Y Tage" statt einer Dezimalzahl.
   Läuft über die volle Rasterbreite, damit die Zeile nie umbricht. */

.field-wide { grid-column: 1 / -1; }

.ratio-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  max-width: 28rem;
}

.ratio-row input[type="number"] {
  flex: 1 1 0;
  width: auto;
  min-width: 5.5rem;
  max-width: 9rem;
  text-align: center;
}

.ratio-sep {
  font-size: .85rem;
  color: var(--muted);
  white-space: nowrap;
}

.qty-preview {
  margin: -.25rem 0 1rem;
  padding: .45rem .7rem;
  border-radius: var(--radius-s);
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Overlay zum Bearbeiten der Standardeigenschaften eines Gegenstands.
   Erreichbar aus der Verwaltung und mitten aus einer Reise heraus. */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  background: rgba(21, 26, 32, .45);
}

.modal-card {
  width: 100%;
  max-width: 40rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(21, 26, 32, .25);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

/* Im Overlay trägt die Karte selbst den Rahmen, das Formular nicht mehr. */
.modal-card .item-form {
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  padding: 1.25rem;
}

/* Kleiner Einstieg in die Bearbeitung neben jedem Gegenstand der Reise. */
.btn-edit-item {
  flex: 0 0 auto;
  min-height: 34px;
  padding: .2rem .6rem;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}

.btn-edit-item:hover {
  border-color: var(--line-strong);
  color: var(--accent);
}

@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal-card { max-width: none; border-radius: 0; min-height: 100%; }
}

/* Reihenfolge der Kategorien in der Verwaltung. */

.cat-order {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .5rem 1rem;
  margin-top: 1rem;
}

.cat-order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: var(--tap);
  padding: .25rem 0;
  border-bottom: 1px solid var(--line);
}

.cat-order-name { font-weight: 500; }

.cat-order-row input[type="number"] {
  width: 5rem;
  flex: 0 0 auto;
  min-height: 38px;
  text-align: center;
}
