/* ---------- Colors and basics ---------- */
:root {
  --green: #2e7d4f;
  --green-dark: #22603c;
  --bg: #f5f5f2;
  --card: #ffffff;
  --text: #1f2421;
  --muted: #6b716d;
  --border: #d9dcd8;
  --error: #b3261e;
}

* { box-sizing: border-box; }

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

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }

.hidden { display: none !important; }
.muted  { color: var(--muted); font-size: 0.9rem; }
.error  { color: var(--error); min-height: 1em; }

/* ---------- Buttons ---------- */
button { font: inherit; cursor: pointer; }

.btn-primary {
  background: var(--green);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary {
  background: white;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 10px;
  padding: 8px 14px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--green);
  padding: 6px;
}

/* ---------- Forms ---------- */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.95rem;
}
label.checkbox { flex-direction: row; align-items: center; gap: 8px; }

input, select, textarea {
  font: inherit;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
legend { padding: 0 6px; font-weight: 600; }

/* Food style "chips" you can tap on and off */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { display: none; }
.chip span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
}
.chip input:checked + span {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.btn-danger {
  background: white;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: 10px;
  padding: 10px 18px;
}

.new-style-row { display: flex; gap: 8px; }
.new-style-row input { flex: 1; min-width: 0; }

.location-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Screens ---------- */
.view { height: 100%; }

#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card { width: 100%; max-width: 360px; }

#main-view { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--green);
  color: white;
}
.topbar .btn-link { color: white; }

#map { flex: 1; }

/* Floating "Add" button over the map.
   Bottom-left, because Netlify's badge and the map credits use the bottom-right. */
.fab {
  position: fixed;
  left: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ---------- Add restaurant panel ---------- */
.panel {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.35);
  overflow-y: auto;
  padding: 16px;
}
.panel .card { max-width: 520px; margin: 0 auto; }
.panel-top { z-index: 3000; }   /* the dish form sits above the details panel */
.panel-header { display: flex; justify-content: space-between; align-items: center; }

/* While picking a spot on the map, let clicks through to the map */
.panel.picking { background: none; pointer-events: none; }
.panel.picking .card { display: none; }

/* ---------- Map popups ---------- */
.popup h3 { margin: 0 0 4px; font-size: 1rem; }
.popup p  { margin: 2px 0; }
.popup-edit {
  margin-top: 8px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
}
.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6f2ea;
  color: var(--green-dark);
  margin: 2px 2px 0 0;
}
.tag.dessert { background: #fbe9f0; color: #8a2950; }

/* ---------- Search panel (compact) ---------- */
.card.compact { gap: 10px; padding: 16px; }
.card.compact .error { margin: 0; min-height: 0; }
.card.compact input,
.card.compact select { padding: 8px; }

/* Two things side by side (Craving + Protein) */
/* auto-fit: if Protein is hidden, the dessert dropdown stretches to full width */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.row label { min-width: 0; }
.row select { width: 100%; }

/* Food | Dessert switch */
.switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--green);
  border-radius: 10px;
  overflow: hidden;
}
.switch input { display: none; }
.switch span {
  display: block;
  text-align: center;
  padding: 8px;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
}
.switch input:checked + span { background: var(--green); color: white; }

details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
}
summary { cursor: pointer; font-weight: 600; color: var(--green); }
.more-filters-body { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.more-filters-body .checkbox { margin-top: 4px; }
.small-heading { display: block; font-size: 0.9rem; margin-bottom: 6px; }

.button-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

/* OpenStreetMap lookup on the add form */
.lookup-box {
  background: #f0f6f2;
  border: 1px solid #cfe3d6;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lookup-box .muted { margin: 0; }
.lookup-box .muted:empty { display: none; }

/* "Zoom in" hint floating over the map */
#main-view { position: relative; }
.zoom-hint {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(31, 36, 33, 0.85);
  color: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ---------- Dish photos ---------- */
.photo-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
}
.file-button { text-align: center; cursor: pointer; display: block; }
.dish-thumb {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin: 4px 0;
}

/* ---------- Visits ---------- */
.safety-summary {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #e6f2ea;
  color: var(--green-dark);
  font-size: 0.95rem;
}
.safety-summary.warn { background: #fdecea; color: var(--error); }
.safety-summary.empty { background: none; color: var(--muted); padding: 0; }
#visit-list { display: flex; flex-direction: column; gap: 8px; }

/* One-line safety summary in map popups and lists */
.safety-line { font-size: 0.85rem; font-weight: 600; margin: 4px 0 !important; }
.safety-line.ok    { color: var(--green-dark); }
.safety-line.warn  { color: var(--error); }
.safety-line.empty { color: var(--muted); font-weight: normal; }
.sick-yes { color: var(--error); font-weight: 600; }

/* ---------- Admin reports ---------- */
.report { display: flex; flex-direction: column; gap: 16px; }
.report h3 { margin-bottom: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}
.stat b { display: block; font-size: 1.3rem; color: var(--green-dark); }
.stat span { font-size: 0.8rem; color: var(--muted); }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report-table th, .report-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.report-table th { color: var(--muted); font-weight: 600; }
.report-table td.num, .report-table th.num { text-align: right; }

/* ---------- Account panel ---------- */
.sub-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
#password-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ---------- Search results bar ---------- */
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  background: #e6f2ea;
  color: var(--green-dark);
  font-weight: 600;
  font-size: 0.95rem;
}
.topbar > div { display: flex; gap: 2px; }
.matching-dishes { font-size: 0.85rem; color: var(--green-dark); }

/* ---------- Restaurant list ---------- */
.restaurant-list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  text-align: left;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.list-item:hover { border-color: var(--green); }
.warning { color: #a15c00; font-size: 0.85rem; }

/* ---------- Details panel + dish cards ---------- */
h3 { font-size: 1.05rem; margin: 0; }

.btn-small { padding: 8px 12px; font-size: 0.9rem; }

.popup-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.popup-buttons .btn-secondary { margin-top: 8px; padding: 6px 12px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

#dish-list { display: flex; flex-direction: column; gap: 10px; }

.category-levels { display: flex; flex-direction: column; gap: 10px; }
.category-levels label + label { padding-left: 14px; border-left: 3px solid var(--border); }
.tag.protein { background: #fff1e0; color: #8a4b00; }

.dish-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dish-top { display: flex; justify-content: space-between; gap: 8px; }
.dish-card p { margin: 0; }
.dish-card .btn-link { align-self: flex-start; padding: 4px 0; }

.stars { color: #d49a00; letter-spacing: 1px; }

.reviews {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e8eef9;
  color: #1f4b8f;
}
