/* ============================================================
   Farm Habit Vendor PWA — Global Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --green:         #2D5016;
  --green-hover:   #3a6820;
  --green-light:   #EAF2DF;
  --bg:            #FAF8F4;
  --surface:       #FFFFFF;
  --border:        #E8E4DE;
  --text:          #1C1C1C;
  --text-muted:    #6B6B6B;
  --red:           #B91C1C;
  --red-bg:        #FEF2F2;
  --red-border:    #FECACA;
  --amber:         #92400E;
  --amber-bg:      #FFFBEB;
  --amber-border:  #FDE68A;
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.06);
  --shadow:        0 1px 4px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --radius:        12px;
  --radius-sm:     8px;
  --max-w:         520px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

img { display: block; max-width: 100%; }
a  { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout wrapper ── */
.page-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ============================================================
   HOME — Header
   ============================================================ */
.home-header {
  background: var(--green);
  padding: 20px 20px 18px;
  text-align: center;
}

.home-header .logo {
  height: 48px;
  width: auto;
  margin: 0 auto;
  object-fit: contain;
}

.home-header .tagline {
  color: rgba(255,255,255,0.75);
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ── Day group ── */
.home-main { padding: 24px 16px 48px; max-width: var(--max-w); margin: 0 auto; }

.day-group { margin-bottom: 28px; }

.day-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
  margin-bottom: 8px;
}

/* ── Market card (home) ── */
.market-card {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.market-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}

.market-card:active { transform: scale(0.99); box-shadow: var(--shadow-sm); }

.market-card-body { flex: 1; }

.market-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.market-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.market-card-arrow {
  color: var(--border);
  font-size: 1.25rem;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ============================================================
   MARKET PAGE — Top nav
   ============================================================ */
.market-nav {
  background: var(--green);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  color: rgba(255,255,255,0.85);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.back-btn:hover { color: #fff; text-decoration: none; }

.back-btn svg { width: 16px; height: 16px; }

.nav-market-name {
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   BANNERS
   ============================================================ */
.banner {
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.banner-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.4; }

.banner-body { flex: 1; }

.banner-title {
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 2px;
}

.banner-text { font-size: 0.875rem; line-height: 1.45; }

.banner-cancel {
  background: var(--red-bg);
  border-bottom: 1px solid var(--red-border);
  color: var(--red);
}

.banner-message {
  background: var(--amber-bg);
  border-bottom: 1px solid var(--amber-border);
  color: var(--amber);
}

/* ============================================================
   MARKET PAGE — Hero
   ============================================================ */
.market-hero {
  background: var(--green);
  padding: 22px 20px 24px;
  text-align: center;
}

.hero-name {
  color: #fff;
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.2;
}

.hero-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.badge {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Info grid ── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.info-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.info-item:nth-child(odd):not(.info-full) {
  border-right: 1px solid var(--border);
}

.info-full { grid-column: 1 / -1; }

.info-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.info-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.info-value a {
  color: var(--green);
  font-weight: 500;
}

/* ── Manager card ── */
.manager-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.manager-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.manager-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.manager-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1px;
}

/* ── Weather ── */
.weather-inner {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-icon { font-size: 2.5rem; line-height: 1; flex-shrink: 0; }

.weather-temp {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.weather-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.weather-wind {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.weather-unavailable {
  padding: 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Documents list ── */
.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: var(--bg); }
.doc-item:active { background: var(--border); }

.doc-item-left { display: flex; align-items: center; gap: 10px; }

.doc-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #FEE2E2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  color: #DC2626;
}

.doc-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.doc-arrow { color: var(--text-muted); font-size: 0.875rem; }

/* ── Rules accordion ── */
.rule-item { border-bottom: 1px solid var(--border); }
.rule-item:last-child { border-bottom: none; }

.rule-header {
  width: 100%;
  background: none;
  border: none;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.rule-header:hover { background: var(--bg); }

.rule-category {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.rule-chevron {
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.rule-item.open .rule-chevron { transform: rotate(180deg); }

.rule-body {
  display: none;
  padding: 0 16px 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.rule-item.open .rule-body { display: block; }

/* ============================================================
   VENDOR MESSAGE FORM
   ============================================================ */
.form-inner { padding: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form-field { margin-bottom: 10px; }

.form-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.form-field input,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--green);
  background: var(--surface);
}

.form-field input[readonly] {
  background: var(--green-light);
  color: var(--green);
  font-weight: 600;
  cursor: default;
}

.form-field textarea {
  resize: none;
  height: 100px;
  line-height: 1.5;
}

.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -6px;
  margin-bottom: 14px;
}

.char-counter.near-limit { color: var(--amber); }
.char-counter.at-limit   { color: var(--red); }

.submit-btn {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover { background: var(--green-hover); }
.submit-btn:active { opacity: 0.9; }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }

/* ── Form note ── */
.form-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
  line-height: 1.5;
}

/* ============================================================
   FOOTER
   ============================================================ */
.market-footer {
  text-align: center;
  padding: 32px 16px 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.market-footer a { color: var(--text-muted); }
.market-footer a:hover { color: var(--green); }

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #f0ede8 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 1em;
  display: inline-block;
  width: 120px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 540px) {
  .market-nav { padding: 12px 24px; }
  .market-hero { padding: 28px 24px 30px; }
  .hero-name { font-size: 1.875rem; }
}
