/* =============================================================
   map-and-products.css
   Farmtab — Farm Map + Products page
============================================================= */

/* -------------------------------------------------------
   Page wrapper
------------------------------------------------------- */

.fmp-page {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background: #f5f7f2;
  min-height: 100vh;
}

.fmp-hidden {
  display: none !important;
}

/* -------------------------------------------------------
   Keyword search — icon button (all screen sizes)
------------------------------------------------------- */

.fmp-keyword-wrap {
  margin-left: auto;
  flex-shrink: 0;
}

.fmp-search-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.fmp-search-icon-btn:hover {
  border-color: #2f6f3e;
  color: #2f6f3e;
}

.fmp-keyword-input-wrap {
  display: none; /* always hidden — overlay used on all sizes */
}

.fmp-keyword-icon {
  color: #9ca3af;
  flex-shrink: 0;
}

/* -------------------------------------------------------
   Unified search overlay — two-row panel
------------------------------------------------------- */

.fmp-mobile-search-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 200;
  border-bottom: 1px solid #e5e7eb;
  /* auto height — grows to fit two rows */
  height: auto;
}

.fmp-mobile-search-overlay.fmp-overlay-open {
  display: block;
}

.fmp-overlay-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  background-color: white;
}

/* Close button — top-right corner */
.fmp-mobile-search-close {
  position: absolute;
  top: 0.2rem;
  right: 0rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #6b7280;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}

.fmp-mobile-search-close:hover {
  color: #1f2933;
  background: #f1f5f9;
}

/* Section label */
.fmp-overlay-label {
  font-size: 0.5rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.35rem;
}

.fmp-overlay-section {
  display: flex;
  flex-direction: column;
}

/* Shared input wrap */
.fmp-overlay-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  padding: 0 0.75rem;
  flex: 1;
  transition: border-color 0.15s, background 0.15s;
}

.fmp-overlay-input-wrap:focus-within {
  border-color: #2f6f3e;
  background: #fff;
}

.fmp-overlay-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.65rem 0;
  font-size: 0.95rem;
  color: #1f2933;
  outline: none;
}

.fmp-overlay-input-wrap input::placeholder {
  color: #9ca3af;
}

/* Location row: input + "Use My Location" button side by side */
.fmp-overlay-location-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.fmp-overlay-loc-btn {
  padding: 0 1rem;
  background: #2f6f3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.fmp-overlay-loc-btn:hover {
  background: #265a33;
}

/* -------------------------------------------------------
   Controls bar (toggle + filters)
------------------------------------------------------- */

.fmp-search-title {
  font-size: 0.9rem;
  color: #374151;
  font-weight: 600;
  display: block;
}

.fmp-powered-by {
  display: block;
  font-size: 0.5rem;
  color: #9ca3af;
  font-weight: 400;
  margin-top: 0.15rem;
  font-style: italic;
}

.fmp-controls-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0;
}

.fmp-controls-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

/* View toggle */
.fmp-view-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.fmp-toggle-btn {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.fmp-toggle-btn.active {
  background: #fff;
  color: #2f6f3e;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Category filter pills */
.fmp-category-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.fmp-cat-btn {
  padding: 0.4rem 0.9rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.fmp-cat-btn:hover {
  border-color: #2f6f3e;
  color: #2f6f3e;
}

.fmp-cat-btn.active {
  background: #2f6f3e;
  border-color: #2f6f3e;
  color: #fff;
}

/* -------------------------------------------------------
   Keyword search — icon button default (all screen sizes)
------------------------------------------------------- */

.fmp-keyword-wrap {
  margin-left: auto;
  flex-shrink: 0;
}

/* Icon button always visible */
.fmp-search-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

.fmp-search-icon-btn:hover {
  border-color: #2f6f3e;
  color: #2f6f3e;
}

/* Inline input always hidden — overlay is used on all sizes */
.fmp-keyword-input-wrap {
  display: none;
}

.fmp-keyword-icon {
  color: #9ca3af;
  flex-shrink: 0;
}

#fmp-keyword-input {
  border: none;
  background: transparent;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: #1f2933;
  width: 180px;
  outline: none;
}

#fmp-keyword-input::placeholder {
  color: #9ca3af;
}

/* -------------------------------------------------------
   Map
------------------------------------------------------- */

.fmp-map-section {
  width: 100%;
}

#fmp-map {
  width: 100%;
  height: 200px;
  display: block;
}

/* Map infowindow */
.fmp-infowindow {
  display: flex;
  gap: 0.75rem;
  max-width: 240px;
  font-family: system-ui, sans-serif;
}

.fmp-infowindow img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.fmp-infowindow-body h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.fmp-infowindow-body p {
  font-size: 0.8rem;
  color: #555;
  margin: 0 0 0.35rem;
}

.fmp-infowindow-body a {
  font-size: 0.85rem;
  color: #2f6f3e;
  font-weight: 600;
  text-decoration: none;
}

.fmp-infowindow-dd {
  height: 14px;
  width: auto;
  filter: brightness(0) invert(1);
  background: #ff3008;
  border-radius: 999px;
  padding: 3px 6px;
  display: block;
  margin-bottom: 0.35rem;
}

/* -------------------------------------------------------
   Results sections
------------------------------------------------------- */

.fmp-results-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.fmp-results-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.fmp-results-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.fmp-results-hint {
  font-size: 0.85rem;
  color: #9ca3af;
}

.fmp-loading,
.fmp-empty {
  color: #6b7280;
  font-size: 0.95rem;
  padding: 2rem 0;
  text-align: center;
  width: 100%;
}

/* -------------------------------------------------------
   Farm grid + cards
------------------------------------------------------- */

.fmp-farm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.fmp-farm-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fmp-farm-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

.fmp-farm-card-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.fmp-farm-card-image {
  height: 180px;
  overflow: hidden;
  background: #e9f0eb;
}

.fmp-farm-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.fmp-farm-card:hover .fmp-farm-card-image img {
  transform: scale(1.03);
}

.fmp-farm-card-image-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #9ca3af;
}

.fmp-farm-card-body {
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.fmp-farm-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.1rem;
}

.fmp-farm-card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.fmp-farm-location {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0;
}

.fmp-farm-distance {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2f6f3e;
  margin: 0;
}

/* Product preview strip inside farm card */
.fmp-farm-product-preview {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
  margin-top: 0.75rem;
  align-items: center;
}

.fmp-farm-product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.fmp-farm-product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fmp-farm-product-more {
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 600;
  white-space: nowrap;
}

.fmp-out-of-season {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 0.6rem;
}

.fmp-distance-products {
  margin-top: 0.5rem;
}

.fmp-doordash-badge-products {
  margin-top: 0.25rem;
}

/* -------------------------------------------------------
   DoorDash badge
------------------------------------------------------- */

.fmp-dd-badge {
  display: inline-flex;
  align-items: center;
  background: #ff3008;
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.fmp-dd-logo {
  height: 12px;
  width: auto;
  filter: brightness(0) invert(1);
  display: block;
}

/* -------------------------------------------------------
   Product grid + cards
------------------------------------------------------- */

.fmp-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.fmp-product-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fmp-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

.fmp-product-card > a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.fmp-product-image {
  height: 180px;
  overflow: hidden;
  background: #e9f0eb;
}

.fmp-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.fmp-product-card:hover .fmp-product-image img {
  transform: scale(1.04);
}

.fmp-product-image-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.fmp-product-body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.fmp-product-farm {
  font-size: 0.65rem;
  color: #9ca3af;
  margin: 0;
  font-weight: 600;
}

.fmp-product-farm-link {
  color: #9ca3af;
  text-decoration: none;
}

.fmp-product-farm-link:hover {
  color: #2f6f3e;
}

.fmp-product-body h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.15rem 0 0;
  line-height: 1.35;
}

.fmp-product-location {
  font-size: 0.6rem;
  color: #9ca3af;
  margin: 0;
}

.fmp-product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.6rem;
}

.fmp-product-price {
  font-size: .75rem;
  font-weight: 700;
  color: #2f6f3e;
}

.fmp-product-distance {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
}

/* -------------------------------------------------------
   Responsive
------------------------------------------------------- */

@media (max-width: 768px) {
  #fmp-map {
    height: 160px;
  }

  .fmp-farm-grid {
    grid-template-columns: 1fr;
  }

  .fmp-cat-btn {
    padding-right: 1.5rem;
  }

  .fmp-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .fmp-controls-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
  }

  .fmp-category-filters {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
    order: 3;
  }

  .fmp-keyword-wrap {
    margin-left: 0;
    order: 2;
  }
}

@media (max-width: 480px) {
  .fmp-hero {
    padding: 2rem 1rem 2rem;
  }

  #fmp-location-input {
    width: 100%;
  }

  .fmp-search-bar {
    flex-direction: column;
  }

  .fmp-product-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .fmp-farm-card-image {
    height: 150px;
  }
}

@media (max-width:700px) {
  .fmp-overlay-inner {
    border-bottom: solid 2px #e5e7eb;
  }
  .fmp-product-grid {
    gap: .65rem;
  }
}