/* =============================================
   SUBSITE PROFILE HEADER — DoorDash-style
   Compact hero, sidebar layout, cart drawer
============================================= */

/* ── Compact hero banner ── */
.farmtab-profile-header {
  position: relative;
  background: #1a1a1a;
  padding: 0rem;
}

.farmtab-hero-banner {
  position: relative;
  width: 100%;
  height: 180px;
  background-size: cover;
  background-position: center;
  background-color: #2f6f3e;
  overflow: hidden;
}

.farmtab-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.15) 0%,
    rgba(0,0,0,.55) 100%
  );
}

.farmtab-hero-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem 1rem;
  height: 100%;
}

/* Avatar */
.farmtab-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid #fff;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  flex-shrink: 0;
}

.farmtab-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hero text */
.farmtab-hero-text {
  flex: 1;
  min-width: 0;
}

.farmtab-farm-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 2px;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
  line-height: 1.2;
}

.farmtab-hero-location {
  font-size: 0.82rem;
  color: rgba(255,255,255,.85);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.farmtab-hero-location svg {
  flex-shrink: 0;
}

.farmtab-hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.farmtab-hero-hours {
  font-size: 0.78rem;
  color: rgba(255,255,255,.8);
  background: rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 2px 10px;
}

/* Info button on hero */
.farmtab-info-btn-hero {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  transition: background .15s;
}

.farmtab-info-btn-hero:hover {
  background: rgba(255,255,255,.28);
}

/* ── CSA notice below hero ── */
.csa-message-wrap {
  width: 100%;
  padding: 0 1.25rem;
  background: #fff;
}

.farmtab-csa-notice {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 18px;
  background: #e7f4ec;
  border-left: 5px solid #2f6f3e;
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.farmtab-csa-notice p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2937;
}

.farmtab-csa-notice a {
  display: inline-block;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  background: #2f6f3e;
  border-radius: 4px;
  white-space: nowrap;
  transition: background .15s;
}

.farmtab-csa-notice a:hover {
  background: #235530;
}

/* ── Modal (mobile-only) ── */
#farmtab-profile-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.5);
}

#farmtab-profile-modal.active {
  display: flex;
}

.farmtab-modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.farmtab-modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  cursor: pointer;
  font-size: 1.4rem;
  background: none;
  border: none;
  color: #374151;
}

.farmtab-modal-overlay {
  position: absolute;
  inset: 0;
}

/* =============================================
   GLOBAL FARM SEARCH BAR
============================================= */
.subsite-global-search-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 1.25rem;
}

.subsite-global-search-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.subsite-global-search-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.subsite-global-search-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.subsite-global-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0 10px;
  background: #f9fafb;
  transition: border-color .15s, box-shadow .15s;
}

.subsite-global-input-wrap:focus-within {
  border-color: #2f6f3e;
  box-shadow: 0 0 0 3px rgba(47,111,62,.1);
  background: #fff;
}

.subsite-global-input-wrap svg {
  flex-shrink: 0;
  color: #9ca3af;
}

#subsite-location-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  padding: 8px 0;
  font-family: inherit;
  color: #1f2937;
  min-width: 0;
}

#subsite-location-input::placeholder {
  color: #9ca3af;
}

.subsite-search-btn {
  padding: 8px 14px;
  background: #2f6f3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.subsite-search-btn:hover {
  background: #235530;
}

.subsite-use-location-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.subsite-use-location-btn:hover {
  background: #f0fdf4;
  border-color: #2f6f3e;
  color: #2f6f3e;
}

@media (max-width: 640px) {
  .subsite-global-search-label {
    display: none;
  }

  .subsite-use-location-btn span {
    display: none;
  }
}

/* =============================================
   MAIN LAYOUT — products + sidebar
============================================= */
.bg-wrap-subsite-archive {
  background: #f5f7f2;
  width: 100%;
}
.subsite-layout-wrap {
  display: flex;
  align-items: flex-start;
  max-width: 1400px;
  margin: 0 auto;
  gap: 0;
  background: #f5f7f2;
}

.subsite-products-area {
  flex: 1;
  min-width: 0;
}

/* =============================================
   SIDEBAR
============================================= */
.subsite-sidebar {
  width: 320px;
  flex-shrink: 0;
  padding: 1.25rem 1rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

/* ── Store info card ── */
.sidebar-store-info {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.sidebar-store-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-store-avatar {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}

.sidebar-store-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 2px;
  line-height: 1.2;
}

.sidebar-store-location {
  font-size: 0.75rem;
  color: #6b7280;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.sidebar-store-desc {
  font-size: 0.8rem;
  color: #374151;
  line-height: 1.55;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.sidebar-store-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid #f3f4f6;
  padding-top: 8px;
}

.sidebar-hours-row,
.sidebar-contact-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #374151;
}

.sidebar-hours-row svg,
.sidebar-contact-row svg {
  flex-shrink: 0;
  color: #9ca3af;
}

.sidebar-contact-row a {
  color: #2f6f3e;
  text-decoration: none;
  word-break: break-all;
}

.sidebar-contact-row a:hover {
  text-decoration: underline;
}

.sidebar-hours-today {
  font-weight: 600;
}

/* ── Cart panel ── */
.sidebar-cart-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.sidebar-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sidebar-cart-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.sidebar-cart-count-badge {
  background: #2f6f3e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 22px;
  text-align: center;
}

.sidebar-cart-empty {
  font-size: 0.85rem;
  color: #9ca3af;
  text-align: center;
  padding: 12px 0;
  margin: 0;
}

.sidebar-cart-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.sidebar-cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.sidebar-cart-item:last-child {
  border-bottom: none;
}

.sidebar-cart-item-img {
  width: 40px;
  height: 40px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f3f4f6;
}

.sidebar-cart-item-info {
  flex: 1;
  min-width: 0;
}

.sidebar-cart-item-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-cart-item-qty {
  font-size: 0.75rem;
  color: #9ca3af;
}

.sidebar-cart-item-price {
  font-size: 0.82rem;
  font-weight: 700;
  color: #111827;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-cart-totals {
  padding: 8px 0;
  border-top: 1px solid #e5e7eb;
  margin-bottom: 10px;
}

.sidebar-cart-subtotal-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 1.25rem;

}

.sidebar-cart-subtotal-row strong {
  font-weight: 700;
  color: #111827;
}

.sidebar-checkout-btn {
  display: block;
  width: 100%;
  padding: 11px;
  background: #2f6f3e;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s, transform .1s;
}

.sidebar-checkout-btn .woocommerce-Price-amount.amount {
  color: #ffffff !important;
}

.sidebar-checkout-btn .woocommerce-Price-currencySymbol {
  color: #ffffff !important;
}

.sidebar-checkout-btn:hover {
  background: #235530;
  transform: translateY(-1px);
}

.sidebar-view-cart-link {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: #6b7280;
  text-decoration: underline;
  margin-top: 6px;
}

.sidebar-view-cart-link:hover {
  color: #374151;
}

/* =============================================
   MOBILE CART DRAWER
============================================= */
.mobile-cart-drawer {
  display: none; /* shown via JS */
  position: fixed;
  inset: 0;
  z-index: 9998;
}

.mobile-cart-drawer.is-open {
  display: block;
}

.mobile-cart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  animation: cartFadeIn .25s ease;
}

.mobile-cart-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1.25rem 1.5rem;
  max-height: 85vh;
  overflow-y: auto;
  animation: cartSlideUp .3s ease;
}

@keyframes cartSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes cartFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.mobile-cart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.mobile-cart-panel-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.mobile-cart-close {
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-cart-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}

.mobile-cart-footer {
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.farmtab-info-btn-label {
  color: #ffffff;
}

/* =============================================
   HIDE SIDEBAR ON MOBILE, SHOW CART DRAWER ONLY
============================================= */
@media (max-width: 960px) {
  .subsite-layout-wrap {
    display: block;
  }

  .subsite-sidebar {
    display: none;
  }

  .farmtab-subsite-header {
    position: sticky !important;
    top: 0;
  }

  .subsite-products-area {
    width: 100%;
  }
}

/* =============================================
   RESPONSIVE: hero banner
============================================= */
@media (max-width: 640px) {
  .farmtab-hero-banner {
    height: 140px;
  }

  .farmtab-farm-name {
    font-size: 1.1rem;
  }

  .farmtab-profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 8px;
  }

  .farmtab-info-btn-label {
    display: none;
  }
}

/* =============================================
   HEADER: cart button style (was <a>, now <button>)
============================================= */
.farmtab-cart-link {
  position: relative;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: inherit;
  padding: 0;
  display: flex;
  align-items: center;
}

/* =============================================
   MODAL — mobile only show, desktop keep sidebar
   (modal is always available as fallback)
============================================= */
@media (min-width: 961px) {
  /* On desktop, the Info button still works — 
     modal is a fallback/detail view */
}
/* ============================================================
   Distance chip (next to hero Info button)
   ============================================================ */
.farmtab-distance-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;      /* status + button flush right */
  gap: 5px;
  z-index: 6;
}

/* Desktop: overlay the chip into the TOP-right of the hero banner,
   clear of the Info button which sits at the bottom-right. The chip
   lives just after the banner in the DOM (so its editor popover is
   never clipped); we pull it up over the banner with a negative
   top offset. */
@media (min-width: 641px) {
  .farmtab-distance-chip {
    position: absolute;
    top: 1rem;                     /* near the top of the banner */
    right: max(1.25rem, calc((100% - 1400px) / 2 + 1.25rem));
  }

  /* Editor opens downward here — there is room below the top-right chip */
  .farmtab-distance-chip .farmtab-distance-editor {
    top: calc(100% + 6px);
    bottom: auto;
  }
}

.farmtab-distance-main {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background .15s;
  white-space: nowrap;
}

.farmtab-distance-main:hover {
  background: rgba(255,255,255,.28);
}

.farmtab-distance-main svg {
  flex-shrink: 0;
}

/* Status line: in-range / out-of-range message — sits ABOVE the button */
.farmtab-distance-status {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 100%;
  text-align: right;
}

.farmtab-distance-status:empty {
  display: none;
}

.farmtab-distance-status.is-in-range {
  background: rgba(46,150,80,.95);
  color: #fff;
}

.farmtab-distance-status.is-out-range {
  background: rgba(200,70,55,.95);
  color: #fff;
}

.farmtab-distance-status.is-error {
  background: rgba(200,70,55,.95);
  color: #fff;
}

/* Editor popover — floats over the header, opens upward on desktop */
.farmtab-distance-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 30;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.22);
}

.farmtab-distance-editor[hidden] {
  display: none;
}

.farmtab-distance-input {
  border: 1px solid #d5ddd7;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  width: 150px;
  color: #1a2e1c;
}

.farmtab-distance-input:focus {
  outline: none;
  border-color: #2f6f3e;
}

.farmtab-distance-locate {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  background: #2f6f3e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.farmtab-distance-locate:hover {
  background: #3d8a50;
}

.farmtab-distance-chip.is-busy .farmtab-distance-main,
.farmtab-distance-chip.is-busy .farmtab-distance-locate {
  opacity: .6;
  pointer-events: none;
}

/* ── Mobile: chip flows as its own row directly BELOW the banner,
   under the profile image + farm name. No overlay, no squeeze. ── */
@media (max-width: 640px) {
  .farmtab-distance-chip {
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 9px 16px;
    background: #fff;
    border-bottom: 1px solid #e0eae2;
  }

  .farmtab-distance-main {
    background: #f5f7f2;
    color: #1a2e1c;
    border: 1px solid #d5ddd7;
    backdrop-filter: none;
    order: 1;
  }

  .farmtab-distance-main svg {
    color: #2f6f3e;
  }

  .farmtab-distance-status {
    order: 2;
    text-align: left;
  }

  /* Room below on mobile — open the editor downward */
  .farmtab-distance-editor {
    top: calc(100% + 4px);
    bottom: auto;
    left: 16px;
    right: auto;
  }

  .farmtab-distance-input {
    width: 120px;
  }
}
