/*
 * GrenzTracker Team – Web-Ansicht. W2: immer dunkelgrün wie www.grenztracker.de,
 * für die Zielgruppe 50+: große Schrift (18 px), große Knöpfe (mind. 52 px), hoher Kontrast,
 * wenige Hauptknöpfe, Seltenes im Menü.
 */
:root {
  --bg: #0b120e; --surface: #111a15; --card: #16201a; --border: #33463a;
  --text: #e8eee8; --muted: #b4c3b7; --accent: #ff9100; --on-accent: #1a1000;
  --green: #2e7d32; --brand-green: #00e676; --amber: #ff8f00; --red: #c62828; --red-soft: #ff8a80;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* W1: „hidden“ gilt immer – sonst blendet z. B. .zonebar { display: flex } die Zonen-Leiste dauerhaft ein */
[hidden] { display: none !important; }
html { font-size: 18px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Kopfzeile */
header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; position: relative; z-index: 5; }
.brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.01em; }
.brand span { color: var(--brand-green); }
.who { flex: 1; text-align: right; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Menü (details/summary, ohne Bibliothek) */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; min-height: 52px; padding: 12px 18px; border: 2px solid var(--border); border-radius: 12px; font-weight: 700; user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; }
.menu[open] summary { border-color: var(--accent); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.menu-list button, .menu-link { width: 100%; text-align: left; }
.menu-link { display: block; padding: 12px 16px; min-height: 52px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; border: 1px solid var(--border); }
.menu-link:hover { border-color: var(--accent); }

section { max-width: 1240px; margin: 0 auto; padding: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 20px 0; }
h1 { font-size: 1.7rem; margin: 0 0 8px; }
h2 { font-size: 1.3rem; margin: 0 0 8px; }

/* Anmeldung */
.login { max-width: 520px; margin: 40px auto; text-align: center; }
#qr { display: inline-block; padding: 14px; background: #fff; border-radius: 12px; margin: 8px 0; }
.code { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.08em; }

/* Werkzeugleiste: Revier links, wenige große Knöpfe rechts */
.toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
#revierName { font-size: 1.35rem; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.focus { display: flex; flex-direction: column; font-size: 0.9rem; color: var(--muted); min-width: 260px; }
.focus select { margin: 4px 0 0; }

button { background: var(--accent); color: var(--on-accent); border: 2px solid var(--accent); border-radius: 12px; padding: 12px 20px; font: inherit; font-weight: 700; cursor: pointer; min-height: 52px; }
button:hover { filter: brightness(1.08); }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.secondary:hover { border-color: var(--accent); filter: none; }
button.active { background: #00838f; border-color: #00838f; color: #fff; }
button.danger { background: var(--red); border-color: var(--red); color: #fff; margin-top: 10px; }
button.small { padding: 6px 12px; min-height: 40px; font-size: 0.85rem; margin-left: 8px; background: transparent; color: var(--red-soft); border: 2px solid var(--red-soft); }

#map { height: 65vh; min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); margin-top: 14px; }
.maplibregl-ctrl-group button { width: 40px; height: 40px; min-height: 0; padding: 0; border: 0; border-radius: 0; }
.legend { font-size: 0.9rem; color: var(--muted); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; vertical-align: middle; }
.dot-intakt { background: var(--green); } .dot-mangel { background: var(--amber); } .dot-gesperrt { background: var(--red); }
.dot-belegt { background: #fff; border: 3px solid #1565C0; }
.dash { display: inline-block; width: 28px; border-top: 3px dashed #ff6d00; vertical-align: middle; }

/* Liste */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255, 145, 0, 0.1); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid .card { margin: 0; }
ul#members, ul.zones { list-style: none; padding: 0; margin: 0; }
ul#members li, ul.zones li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }

select, input, textarea { width: 100%; padding: 12px; min-height: 52px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font: inherit; margin: 6px 0 14px; }
textarea { min-height: 0; }
#inviteOut { margin-top: 14px; }
#inviteOut div[title], #inviteOut img, #inviteOut canvas { background: #fff; padding: 6px; border-radius: 8px; }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); max-width: 520px; width: 92vw; padding: 24px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
label { display: block; font-size: 1rem; }
label.check { display: flex; gap: 10px; align-items: center; margin: 6px 0 14px; }
label.check input { width: 24px; height: 24px; min-height: 0; margin: 0; }
ul.help { padding-left: 20px; } ul.help li { margin: 8px 0; }

/* Popup auf der Karte bleibt hell (bessere Lesbarkeit über der Karte) */
.maplibregl-popup-content { border-radius: 12px; padding: 14px 16px; }
.popup { color: #14231a; font-size: 1rem; }
.popup .muted { color: #4a5e51; }
.popup .state { font-weight: 700; margin: 4px 0; }
.popup ul { margin: 4px 0; padding-left: 18px; }
.popup .notes { margin-top: 6px; font-style: italic; }
.popup .photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.popup .photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid #ccc; }
.popup .photo { position: relative; display: inline-block; }
.popup .photo-del { position: absolute; top: 2px; right: 2px; min-height: 0; padding: 0 8px; font-size: 0.8rem; background: rgba(0,0,0,0.65); color: #fff; border: 0; border-radius: 6px; }
.popup button { font-size: 0.95rem; min-height: 46px; padding: 8px 14px; }
.popup button.secondary { margin-top: 6px; color: #14231a; border-color: #8a9a8f; }
.popup button.small { display: block; margin: 6px 0 0; color: var(--red); border-color: var(--red); }
.popup button.danger { display: block; }
.popup .sector { margin-top: 6px; }
.popup .occ { color: #E65100; font-weight: 700; margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #263238; color: #fff; padding: 14px 22px; border-radius: 12px; z-index: 10; max-width: 90vw; font-size: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
footer { text-align: center; padding: 28px 16px; }
footer a { color: inherit; }

.stores { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 10px 0 6px; }
.stores a { display: inline-block; padding: 14px 18px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none; min-height: 52px; }
.newuser { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.zonebar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding: 10px 14px; border: 2px solid #ef5350; border-radius: var(--radius); }
.zonebar span { flex: 1; }

.print-only { display: none; }
@media (max-width: 720px) {
  html { font-size: 17px; }
  .grid { grid-template-columns: 1fr; }
  #map { height: 55vh; }
  .who { text-align: left; flex-basis: 100%; order: 3; }
  .buttons button { flex: 1 1 100%; }
  section { padding: 16px; }
}

/* W1: Revierkarte drucken – ganze Revierfläche auf einer A4-Seite, ohne Knöpfe */
body.printing #map { width: 720px; height: 880px; }
@media print {
  header, .buttons, .noprint, .maplibregl-ctrl, .maplibregl-popup, .focus, .zonebar, footer, #toast, button, .menu { display: none !important; }
  @page { size: A4 portrait; margin: 12mm; }
  html { font-size: 12pt; }
  body { background: #fff; color: #000; }
  section { padding: 0; }
  .card { border: 0; padding: 0; background: #fff; color: #000; }
  .muted { color: #333; }
  #map { width: 720px !important; height: 880px !important; border: 1px solid #999; page-break-after: always; }
  .print-only { display: block; }
  .print-head { margin-bottom: 6px; font-size: 14pt; }
  .legend { color: #000; }
  tbody tr:hover { background: none; }
  th, td { border-color: #bbb; color: #000; }
}
