/* Bierfahrer-App – Styles (mobile-first, große Touch-Flächen) */

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #f59e0b;
  --accent-dark: #b45309;
  --danger: #dc2626;
  --header: #1f2937;
  --header-text: #f9fafb;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--header);
  color: var(--header-text);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 10px 10px;
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  background: none;
  border: none;
  color: var(--header-text);
  font-size: 1.5rem;
  line-height: 1;
  padding: 8px 10px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  border-radius: 10px;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.15); }
#syncBtn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.sync-status {
  background: var(--header);
  color: #d1d5db;
  font-size: 0.8rem;
  padding: 0 14px 8px 14px;
}
.sync-status.warn { color: #fbbf24; }
.sync-status.error { color: #fca5a5; }

/* ---------- Inhalt ---------- */
main {
  padding: 12px 12px calc(env(safe-area-inset-bottom, 0px) + 96px) 12px;
  max-width: 640px;
  margin: 0 auto;
}

.empty {
  text-align: center;
  color: var(--muted);
  margin-top: 15vh;
  padding: 0 24px;
  line-height: 1.6;
}
.empty .big { font-size: 3rem; }

/* Tourenliste */
.tour-card {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}
.tour-card .tour-main {
  flex: 1;
  padding: 14px 16px;
  cursor: pointer;
  min-width: 0;
}
.tour-card .tour-name {
  font-weight: 600;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tour-card .tour-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.tour-card .tour-sum {
  font-weight: 700;
  color: var(--accent-dark);
  padding: 0 4px;
  white-space: nowrap;
}
.tour-card .menu-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  padding: 14px 12px;
  cursor: pointer;
}

/* Schuldner-Gruppen in der Touransicht */
.group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fef3c7;
  border-bottom: 1px solid var(--line);
}
.group-head .g-name { font-weight: 700; font-size: 1.05rem; }
.group-head .g-sum { font-weight: 700; color: var(--accent-dark); white-space: nowrap; }

.entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.entry-row:last-child { border-bottom: none; }
.entry-row .e-date {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  min-width: 84px;
}
.entry-row .e-mid { flex: 1; min-width: 0; }
.entry-row .e-note {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-row .e-amount { font-weight: 600; white-space: nowrap; }
.entry-row .e-amount.negative { color: #059669; }
.entry-row .del-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  color: var(--danger);
}

.tour-total {
  text-align: right;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 4px 6px 0 6px;
}

/* ---------- Schwebender Plus-Button ---------- */
#fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 2.2rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 20;
}
#fab:active { background: var(--accent-dark); }

/* ---------- Dialoge ---------- */
dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(92vw, 420px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dlg { padding: 20px; }
.dlg h2 { margin: 0 0 14px 0; font-size: 1.15rem; }
.dlg p { margin: 0 0 14px 0; }
.dlg label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.dlg input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  font-size: 1.05rem;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
.dlg input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

.dlg-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.ghost { background: #f3f4f6; color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.wide { display: block; width: 100%; margin-bottom: 10px; background: #f3f4f6; text-align: left; }
.btn.danger-outline { background: #fef2f2; color: var(--danger); }

/* Namens-Auswahl (Eingabe + Dropdown) */
.combo { position: relative; margin-top: 4px; }
.combo input { margin-top: 0; padding-right: 48px; }
.combo-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 40px;
  border: none;
  background: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
}
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  max-height: 200px;
  overflow-y: auto;
  z-index: 5;
}
.suggestions div {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 1rem;
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:active { background: #fef3c7; }
