/* ── Variables ─────────────────────────────────── */
:root {
  --green-dark:   #0b3d2c;
  --green-mid:    #00a32a;
  --green-light:  #8ac069;
  --green-lime:   #90c33d;
  --green-bg:     #e9f2ea;
  --orange:       #f8ab48;
  --text-dark:    #292929;
  --text-mid:     #414141;
  --text-muted:   #6b7280;
  --border:       #d1d5db;
  --white:        #ffffff;
  --card-shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius:       10px;
  --font:         'Inter', sans-serif;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text-dark); background: #f6f8f5; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ── Header ────────────────────────────────────── */
.app-header {
  background: var(--green-dark);
  color: var(--white);
  padding: 0 24px;
  position: relative;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
}
.header-brand { display: none; flex-direction: column; gap: 2px; flex-shrink: 0; }
.back-link {
  font-size: 11px;
  color: var(--green-light);
  opacity: .85;
  letter-spacing: .3px;
  transition: opacity .15s;
}
.back-link:hover { opacity: 1; }
.header-title { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }

.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: var(--white);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, background .15s;
}
.search-input::placeholder { color: rgba(255,255,255,.5); }
.search-input:focus { border-color: var(--green-light); background: rgba(255,255,255,.18); }

/* ── Filters Bar ───────────────────────────────── */
.filters-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: relative;
  top: 0px;
  z-index: 90;
}
.filters-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }

.filter-select {
  padding: 7px 32px 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-dark);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  min-width: 160px;
}
.filter-select:focus { border-color: var(--green-mid); }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  background: var(--white);
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--green-mid); color: var(--green-dark); }
.chip.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: var(--white);
}

.clear-btn {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--white);
  margin-top: 18px;
  transition: all .15s;
}
.clear-btn:hover { border-color: var(--orange); color: var(--text-dark); }

/* ── Toolbar ───────────────────────────────────── */
.toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
}
.toolbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.results-count { font-size: 13px; color: var(--text-muted); }
.results-count strong { color: var(--text-dark); font-weight: 600; }

.view-toggle { display: flex; gap: 4px; }
.view-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--white);
  transition: all .15s;
}
.view-btn svg { width: 14px; height: 14px; }
.view-btn:hover { border-color: var(--green-mid); color: var(--green-dark); }
.view-btn.active {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: var(--white);
}
.view-btn.favorites-toggle.active { background: var(--orange); border-color: var(--orange); }

/* ── Main Content ──────────────────────────────── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── Grid View ─────────────────────────────────── */
.farm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

/* ── Card Image ────────────────────────────────── */
.card-image {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
  display: block;
  background: var(--green-bg);
}
.card-image-wrap {
  margin: -18px -18px 14px -18px;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  height: 160px;
  background: var(--green-bg);
}
.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .3s ease;
}
.farm-card:hover .card-image-wrap img { transform: scale(1.03); }

/* ── Modal Image ───────────────────────────────── */
.modal-image-wrap {
  margin: -24px -24px 20px -24px;
  height: 220px;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  background: var(--green-bg);
}
.modal-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Farm Card ─────────────────────────────────── */
.farm-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.farm-card:hover {
  border-color: var(--green-mid);
  box-shadow: 0 4px 16px rgba(0,163,42,.12);
  transform: translateY(-1px);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-name { font-size: 15px; font-weight: 600; line-height: 1.35; color: var(--text-dark); }
.fav-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  padding: 4px;
  border-radius: 6px;
  color: var(--border);
  transition: color .15s, background .15s;
}
.fav-btn svg { width: 18px; height: 18px; }
.fav-btn:hover { color: var(--orange); background: #fff7ed; }
.fav-btn.saved { color: var(--orange); }

.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-location { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.card-location svg { width: 12px; height: 12px; }
.card-category {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}
.card-description { font-size: 13px; color: var(--text-mid); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.card-tag {
  padding: 2px 8px;
  background: var(--green-bg);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--green-dark);
}
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.card-website { font-size: 12px; color: var(--green-mid); font-weight: 500; }
.card-website:hover { text-decoration: underline; }
.card-more { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Category colors */
.cat-urban { background: #e8f5e9; color: #1b5e20; }
.cat-community { background: #e3f2fd; color: #0d47a1; }
.cat-school { background: #fff3e0; color: #bf360c; }
.cat-market { background: #f3e5f5; color: #4a148c; }
.cat-forest { background: #e8f5e9; color: #33691e; }
.cat-agrihood { background: #fce4ec; color: #880e4f; }
.cat-refugee { background: #fff8e1; color: #f57f17; }
.cat-therapeutic { background: #e0f7fa; color: #006064; }
.cat-indigenous { background: #efebe9; color: #3e2723; }
.cat-faith { background: #e8eaf6; color: #1a237e; }

/* ── No Results ────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.no-results-icon { font-size: 48px; margin-bottom: 12px; }
.no-results p { font-size: 16px; margin-bottom: 16px; }
.clear-btn-secondary {
  padding: 8px 20px;
  background: var(--green-dark);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}
.clear-btn-secondary:hover { opacity: .88; }

/* ── Map View ──────────────────────────────────── */
.map-view {
  display: flex;
  gap: 0;
  height: calc(100vh - 185px);
  min-height: 540px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--border);
}
#map { flex: 1; min-width: 0; }
.map-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--white);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.map-sidebar-list { display: flex; flex-direction: column; }
.map-list-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.map-list-item:hover { background: var(--green-bg); }
.map-list-item.active { background: var(--green-bg); border-left: 3px solid var(--green-mid); }
.map-item-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.map-item-meta { font-size: 11px; color: var(--text-muted); }

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-close {
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--green-bg);
  border-radius: 8px;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background .15s;
}
.modal-close svg { width: 16px; height: 16px; }
.modal-close:hover { background: var(--border); }
.modal-content { padding: 24px; }

.modal-category-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.modal-name { font-size: 22px; font-weight: 700; line-height: 1.3; margin-bottom: 6px; }
.modal-location { font-size: 14px; color: var(--text-muted); margin-bottom: 18px; display: flex; align-items: center; gap: 5px; }
.modal-section { margin-bottom: 18px; }
.modal-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 8px; }
.modal-description { font-size: 14px; line-height: 1.65; color: var(--text-mid); }
.modal-get-involved { font-size: 14px; line-height: 1.65; color: var(--text-mid); }
.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-tag {
  padding: 4px 10px;
  background: var(--green-bg);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green-dark);
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.modal-btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.modal-btn:hover { opacity: .88; }
.modal-btn-primary { background: var(--green-dark); color: var(--white); }
.modal-btn-secondary { background: var(--green-bg); color: var(--green-dark); }
.modal-btn-fav { background: #fff7ed; color: #92400e; }
.modal-btn-fav.saved { background: var(--orange); color: var(--white); }

/* ── Leaflet popup override ────────────────────── */
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,.15); }
.leaflet-popup-content { margin: 14px 16px; }
.popup-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.popup-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.popup-btn {
  display: inline-block;
  padding: 5px 12px;
  background: var(--green-dark);
  color: var(--white);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font);
}

/* ── Utility ───────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 16px; }
  .header-inner { gap: 12px; }
  .search-wrap { max-width: none; }
  .filters-bar { padding: 10px 16px; }
  .filters-inner { gap: 14px; }
  .main-content { padding: 16px; }
  .farm-grid { grid-template-columns: 1fr; }
  .map-view { flex-direction: column; height: auto; }
  .map-sidebar { width: 100%; height: 200px; border-left: none; border-top: 1px solid var(--border); }
  #map { height: 400px; }
  .toolbar { padding: 8px 16px; }
}
