/* ─── CSS Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark:  #2d6a2d;
  --green:       #4caf50;
  --green-light: #a5d6a7;
  --amber:       #ffc107;
  --red:         #e53935;
  --bg:          #f4f6f0;
  --surface:     #ffffff;
  --text:        #1a1a1a;
  --text-muted:  #666;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,.18);
  --nav-h:       56px;
  --footer-h:    58px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ─── Navbar ───────────────────────────────────────────────────────────── */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
  height: var(--nav-h);
  background: var(--green-dark);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow);
}
.nav-brand { font-size: 1.15rem; font-weight: 700; letter-spacing: .02em; }
.nav-actions { display: flex; gap: 8px; }
.nav-btn {
  background: none; border: none; color: #fff; font-size: 1.4rem;
  cursor: pointer; padding: 6px; border-radius: 50%; transition: background .15s;
}
.nav-btn:hover { background: rgba(255,255,255,.18); }

/* ─── Map ──────────────────────────────────────────────────────────────── */
#map {
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: var(--footer-h);
  z-index: 0;
}

/* ─── Footer ───────────────────────────────────────────────────────────── */
#app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-h);
  z-index: 1100;
  background: linear-gradient(135deg, #255c2b 0%, #2f6f35 55%, #3f8d47 100%);
  border-top: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 -4px 16px rgba(0,0,0,.2);
}

.footer-wrap {
  height: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #f3fff4;
  font-size: .88rem;
  flex-wrap: wrap;
}

.footer-claim {
  font-weight: 700;
  letter-spacing: .01em;
}

#app-footer a {
  color: #fff;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  transition: background .15s ease, transform .1s ease;
}

#app-footer a:hover {
  background: rgba(255,255,255,.26);
  transform: translateY(-1px);
}

#app-footer a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 480px) {
  :root { --footer-h: 72px; }
  .footer-wrap { gap: 8px; font-size: .8rem; }
}

/* ─── Modals ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
@media (min-width: 600px) {
  .modal { align-items: center; padding: 16px; }
}
.modal.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  padding: 24px 20px 32px;
  position: relative;
  box-shadow: var(--shadow);
}
@media (min-width: 600px) {
  .modal-card { border-radius: var(--radius); }
}
.modal-card.wide { max-width: 640px; }

.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  color: var(--text-muted);
}

/* ─── Forms ────────────────────────────────────────────────────────────── */
h2 { font-size: 1.25rem; margin-bottom: 16px; color: var(--green-dark); }
h3 { font-size: 1rem; margin: 14px 0 10px; color: var(--green-dark); }
label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .85rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 12px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid #cdd5c0; border-radius: 8px;
  font-size: 1rem; color: var(--text);
  background: #f9fbf7;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
}
textarea { resize: vertical; min-height: 64px; }
hr { border: none; border-top: 1px solid #e0e0e0; margin: 16px 0; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; padding: 12px;
  background: var(--green); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
  cursor: pointer; margin-top: 8px; transition: background .15s;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary {
  display: block; width: 100%; padding: 11px;
  background: #e8f5e9; color: var(--green-dark);
  border: 1.5px solid var(--green-light); border-radius: 8px;
  font-size: .95rem; font-weight: 600; cursor: pointer; margin-top: 8px;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--green-light); }

.btn-danger {
  display: block; width: 100%; padding: 11px;
  background: #ffebee; color: var(--red);
  border: 1.5px solid #ef9a9a; border-radius: 8px;
  font-size: .95rem; font-weight: 600; cursor: pointer; margin-top: 8px;
  transition: background .15s;
}
.btn-danger:hover { background: #ffcdd2; }

.btn-sm {
  padding: 6px 12px; border-radius: 6px; font-size: .82rem; font-weight: 600;
  cursor: pointer; border: none;
}
.btn-sm-green  { background: var(--green); color: #fff; }
.btn-sm-red    { background: #ef5350; color: #fff; }
.btn-sm-amber  { background: var(--amber); color: #333; }
.btn-sm-outline { background: none; border: 1.5px solid var(--green); color: var(--green-dark); }

/* ─── Tabs ─────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--green-light);
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1; padding: 10px; background: none; border: none;
  font-size: .95rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); border-bottom: 3px solid transparent;
  margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--green-dark); border-color: var(--green-dark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Alerts ───────────────────────────────────────────────────────────── */
.error   { color: var(--red); font-size: .87rem; margin-top: 4px; padding: 8px 10px; background: #ffebee; border-radius: 6px; }
.success { color: #2e7d32; font-size: .87rem; margin-top: 4px; padding: 8px 10px; background: #e8f5e9; border-radius: 6px; }
.hidden  { display: none !important; }

/* ─── Obstwiese list ───────────────────────────────────────────────────── */
.obstwiese-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 10px; border-radius: 8px; margin-bottom: 8px;
  background: #f1f8e9; border: 1px solid #c8e6c9; cursor: pointer;
  transition: background .15s;
}
.obstwiese-item:hover { background: #dcedc8; }
.obstwiese-item .ow-name { font-weight: 700; font-size: .95rem; }
.obstwiese-item .ow-actions { display: flex; gap: 6px; }

/* ─── Side panel (Baum detail) ─────────────────────────────────────────── */
.side-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1050;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.22);
  max-height: 80vh; overflow-y: auto;
  transition: transform .25s ease;
}
@media (min-width: 600px) {
  .side-panel {
    left: auto; right: 16px; bottom: 80px;
    width: 360px; border-radius: var(--radius);
    max-height: 70vh;
  }
}
.side-panel.hidden { transform: translateY(110%); display: none; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  font-weight: 700; font-size: 1rem; color: var(--green-dark);
  border-bottom: 1px solid #e0e0e0;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.panel-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
#panel-baum-body { padding: 14px 18px 24px; }

/* ─── Baum panel internals ─────────────────────────────────────────────── */
.baum-info-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.baum-info-chip {
  background: #e8f5e9; border: 1px solid #c8e6c9; border-radius: 20px;
  padding: 4px 10px; font-size: .8rem; color: var(--green-dark);
}
.log-entry {
  background: #f9fbf7; border: 1px solid #e0e8d8; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.log-entry .log-header { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
.log-entry .log-typ { font-weight: 700; color: var(--green-dark); font-size: .85rem; }
.log-photo { max-width: 100%; border-radius: 6px; margin-top: 6px; }
.color-swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #aaa; vertical-align: middle; }

.color-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.color-choice {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 2px solid #455a64;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
  transition: transform .08s ease, box-shadow .12s ease;
}

.color-choice:hover {
  transform: translateY(-1px);
}

.color-choice:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.color-choice.selected {
  border-color: #111;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #111;
}

/* ─── FAB ──────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: calc(var(--footer-h) + 16px); right: 20px; z-index: 1000;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: #fff;
  border: none; font-size: 1.4rem;
  box-shadow: 0 4px 14px rgba(76,175,80,.5);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.fab:hover { background: var(--green-dark); transform: scale(1.07); }
.fab.hidden { display: none; }
.fab-polygon { bottom: calc(var(--footer-h) + 82px); background: #ff8f00; box-shadow: 0 4px 14px rgba(255,143,0,.5); }
.fab-polygon:hover { background: #e65100; }

/* ─── Admin table ──────────────────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th { background: var(--green-light); padding: 8px; text-align: left; }
.admin-table td { padding: 8px; border-bottom: 1px solid #f0f0f0; }
.admin-table tr:hover td { background: #f9fbf7; }
.badge { display: inline-block; border-radius: 12px; padding: 2px 9px; font-size: .75rem; font-weight: 700; }
.badge-admin  { background: #fff3cd; color: #856404; }
.badge-user   { background: #d1ecf1; color: #0c5460; }
.badge-locked { background: #f8d7da; color: #721c24; }
.badge-active { background: #d4edda; color: #155724; }

/* ─── Leaflet overrides ────────────────────────────────────────────────── */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { border-radius: 8px !important; margin-bottom: 4px !important; font-size: 1.1rem !important; line-height: 30px !important; }
.baum-id-tooltip {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  padding: 0;
}

.baum-id-tooltip:before {
  display: none;
}
