/* Cold Spring Tree Inventory — mobile-first styles */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #eef1ea;
  --ink: #1f2a1c;
  --ink-soft: #57624e;
  --accent: #2e7d32;
  --accent-dark: #1b5e20;
  --danger: #b3261e;
  --border: #d7dcd0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent-dark); }

/* --- app shell --- */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
}

.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}
.topbar h1 {
  font-size: 1rem; font-weight: 600; margin: 0;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .who {
  font-size: .85rem; opacity: .9;
  max-width: 40%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 500px) {
  /* On phones, drop the username display to keep the login/logout button on screen. */
  .topbar .who { display: none; }
}
.topbar button, .topbar a.btn {
  background: rgba(255,255,255,.15);
  color: #fff; border: 1px solid rgba(255,255,255,.25);
  padding: .4rem .7rem; border-radius: 6px;
  font-size: .85rem; cursor: pointer; text-decoration: none;
}
.topbar button:hover, .topbar a.btn:hover { background: rgba(255,255,255,.25); }

/* --- content: map + panel --- */
.content {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  min-height: 0;
}
@media (min-width: 900px) {
  .content { grid-template-columns: 1fr 380px; grid-template-rows: 1fr; }
  .panel { border-left: 1px solid var(--border); border-top: 0; }
}

#map {
  width: 100%; height: 100%;
  min-height: 240px;
  background: #dde5d3;
}

.panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-height: 55dvh;
  overflow-y: auto;
  padding: .8rem .9rem 1.2rem;
}
@media (min-width: 900px) {
  .panel { max-height: none; }
}

/* --- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .55rem .9rem;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  font-size: .95rem; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent-dark); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small   { padding: .35rem .6rem; font-size: .85rem; }
.btn.wide    { width: 100%; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }

/* --- forms --- */
label { display: block; font-size: .85rem; color: var(--ink-soft); margin: .5rem 0 .2rem; }
input, select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

/* --- lists --- */
.trees-list {
  list-style: none; padding: 0; margin: .5rem 0;
  border-top: 1px solid var(--border);
}
.trees-list li {
  padding: .6rem .3rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .5rem;
}
.trees-list li:hover { background: var(--surface-2); }
.trees-list .tag { font-weight: 600; }
.trees-list .meta { font-size: .8rem; color: var(--ink-soft); }
.trees-list li.selected { background: #e2ecdd; }

.notes-list {
  list-style: none; padding: 0; margin: .3rem 0;
}
.notes-list li {
  padding: .5rem .3rem;
  border-bottom: 1px dashed var(--border);
}
.notes-list .note-meta { font-size: .8rem; color: var(--ink-soft); margin-bottom: .2rem; }
.notes-list .note-body { white-space: pre-wrap; }

/* --- headings --- */
h2 { font-size: 1.05rem; margin: .5rem 0; }
h3 { font-size: .95rem; margin: 1rem 0 .3rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.muted { color: var(--ink-soft); font-size: .9rem; }
.status { font-size: .85rem; margin: .3rem 0; min-height: 1.1em; }
.status.error { color: var(--danger); }
.status.ok { color: var(--accent-dark); }

/* --- health pill --- */
.health-pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: .75rem; text-transform: capitalize;
  background: #ddd;
}
.health-pill.good { background: #c8e6c9; color: #1b5e20; }
.health-pill.fair { background: #fff9c4; color: #7c6f00; }
.health-pill.poor { background: #ffe0b2; color: #a85400; }
.health-pill.dead { background: #ffcdd2; color: #8b0000; }

/* --- auth pages --- */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #edf3e6 0%, #d6e5cf 100%);
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.5rem 1.4rem;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 .3rem;
  color: var(--accent-dark);
}
.auth-card p.sub { margin-top: 0; color: var(--ink-soft); font-size: .9rem; }
.auth-card .alt { text-align: center; margin-top: .8rem; font-size: .9rem; }

/* --- modal --- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 480px; width: 100%;
  max-height: 90dvh; overflow-y: auto;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.1rem 1.3rem;
}
.modal h2 { margin-top: 0; }
.modal .close-row { display: flex; justify-content: flex-end; margin-top: 1rem; gap: .5rem; }

/* Auth visibility: elements are toggled via the [hidden] attribute in JS.
   That keeps each element's own display value intact when shown. */
[hidden] { display: none !important; }

/* When in anonymous detail mode, inputs render read-only. */
.tree-form-readonly input,
.tree-form-readonly select,
.tree-form-readonly textarea {
  background: var(--surface-2);
  color: var(--ink);
  pointer-events: none;
}
.anon-notice { margin: .1rem 0 .5rem; font-size: .9rem; }

/* "Show dead trees" checkbox row */
.checkbox-row {
  display: flex; align-items: center; gap: .5rem;
  margin: .5rem 0 .3rem;
  font-size: .9rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

/* Inline "Date unknown" toggle beside the planted-on date input */
.inline-check {
  display: inline-flex; align-items: center; gap: .35rem;
  margin-top: .35rem;
  font-size: .85rem; color: var(--ink-soft);
}
.inline-check input { width: auto; margin: 0; }
.inline-check label { display: inline; margin: 0; font-size: inherit; color: inherit; cursor: pointer; }

/* Leaflet: keep default marker icons visible over our bg */
.leaflet-container { font-family: inherit; }
