/* ਮੰਡੀ ਭਾਅ — Punjab Rate Board */

:root {
  --m-green: #145A28;
  --m-green-dark: #0E4420;
  --m-green-pale: rgba(20,90,40,0.08);
  --m-gold: #B8860B;
  --m-gold-bright: #D4A017;
  --m-gold-soft: rgba(184,134,11,0.10);
  --m-saffron: #D46A1A;
  --m-bg: #F3ECDB;
  --m-surface: #FDFAF2;
  --m-ink: #1C1008;
  --m-ink-mid: #6B5D4C;
  --m-ink-light: #A0927E;
  --m-rule: #DDD5C5;
  --m-rule-strong: #C4BAA8;
  --m-shadow-sm: 0 1px 2px rgba(28,16,8,0.04);
  --m-shadow: 0 1px 3px rgba(28,16,8,0.05), 0 4px 12px rgba(28,16,8,0.03);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

.mandi-dark {
  --m-green: #6AAF5E;
  --m-green-dark: #4A8F44;
  --m-green-pale: rgba(106,175,94,0.10);
  --m-gold: #D4A017;
  --m-gold-bright: #ECBE30;
  --m-gold-soft: rgba(212,160,23,0.12);
  --m-saffron: #E88040;
  --m-bg: #0E0C08;
  --m-surface: #181410;
  --m-ink: #E4DCC8;
  --m-ink-mid: rgba(228,220,200,0.55);
  --m-ink-light: rgba(228,220,200,0.30);
  --m-rule: rgba(228,220,200,0.08);
  --m-rule-strong: rgba(228,220,200,0.14);
  --m-shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --m-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.15);
  background: var(--m-bg);
  color: var(--m-ink);
}

body.mandi-app {
  font-family: 'Noto Sans Gurmukhi', system-ui, sans-serif;
  font-weight: 500;
  line-height: 1.45;
  background: var(--m-bg);
  color: var(--m-ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Display font for prices — rounder numerals, high legibility */
.font-display {
  font-family: 'Mukta Mahee', 'Noto Sans Gurmukhi', system-ui, sans-serif;
}

[x-cloak] { display: none !important; }

/* ── Grain texture ── */
body.mandi-app::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  opacity: 0.02;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ═══════════════════════════════
   Header
   ═══════════════════════════════ */

.mandi-hdr {
  background: var(--m-green);
  border-bottom: 2.5px solid var(--m-gold);
}
.mandi-dark .mandi-hdr {
  background: var(--m-green-dark);
}

.mandi-hdr-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  transition: all 120ms ease;
}
.mandi-hdr-btn:active {
  background: rgba(255,255,255,0.12);
  color: #FFF;
  transform: scale(0.92);
}

/* ═══════════════════════════════
   Date navigation strip
   ═══════════════════════════════ */

.mandi-date-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--m-surface);
  border: 1px solid var(--m-rule);
  border-radius: 12px;
  padding: 4px;
  box-shadow: var(--m-shadow-sm);
}

.mandi-date-center {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
}

.mandi-nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--m-green);
  background: var(--m-green-pale);
  transition: all 120ms ease;
  flex-shrink: 0;
}
.mandi-nav-btn:active {
  transform: scale(0.9);
  background: var(--m-green);
  color: #FFF;
}
.mandi-nav-btn[disabled] {
  opacity: 0.2;
  pointer-events: none;
  background: transparent;
}
.mandi-dark .mandi-nav-btn {
  color: var(--m-gold-bright);
  background: var(--m-gold-soft);
}
.mandi-dark .mandi-nav-btn:active {
  background: var(--m-gold);
  color: var(--m-bg);
}

/* ═══════════════════════════════
   Search
   ═══════════════════════════════ */

.mandi-search {
  background: var(--m-surface);
  border: 1.5px solid var(--m-rule);
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  transition: border-color 200ms, box-shadow 200ms;
  box-shadow: var(--m-shadow-sm);
}
.mandi-search:focus-within {
  border-color: var(--m-green);
  box-shadow: 0 0 0 3px var(--m-green-pale);
}
.mandi-dark .mandi-search:focus-within {
  border-color: var(--m-gold);
  box-shadow: 0 0 0 3px var(--m-gold-soft);
}

/* ═══════════════════════════════
   District sections
   ═══════════════════════════════ */

.dist-section + .dist-section { margin-top: 6px; }

.dist-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--m-surface);
  border: 1px solid var(--m-rule);
  border-radius: 10px;
  transition: all 120ms ease;
  box-shadow: var(--m-shadow-sm);
}
.dist-btn:active {
  transform: scale(0.985);
  background: var(--m-bg);
}

.dist-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--m-green);
  background: var(--m-green-pale);
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: 6px;
}
.mandi-dark .dist-count {
  color: var(--m-gold-bright);
  background: var(--m-gold-soft);
}

/* ═══════════════════════════════
   View toggle (segmented control)
   ═══════════════════════════════ */

.view-toggle {
  display: flex;
  background: var(--m-rule);
  border-radius: 8px;
  padding: 2px;
}
.view-toggle-btn {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--m-ink-mid);
  transition: all 150ms ease;
}
.view-toggle-active {
  background: var(--m-surface);
  color: var(--m-green);
  box-shadow: var(--m-shadow-sm);
}
.mandi-dark .view-toggle {
  background: var(--m-rule-strong);
}
.mandi-dark .view-toggle-active {
  background: var(--m-surface);
  color: var(--m-gold-bright);
}

/* ═══════════════════════════════
   Rate table
   ═══════════════════════════════ */

.rate-wrap {
  background: var(--m-surface);
  border: 1px solid var(--m-rule);
  border-top: none;
  border-radius: 0 0 10px 10px;
  margin-top: -1px;
  overflow: hidden;
  box-shadow: var(--m-shadow);
}

.rate-table {
  width: 100%;
  border-collapse: collapse;
}

.rate-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--m-ink-light);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--m-rule);
}
.rate-table th:last-child { text-align: right; }

.rate-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--m-rule);
  vertical-align: top;
}
.rate-table tr:last-child td { border-bottom: none; }

.rate-commodity {
  font-size: 16px;
  font-weight: 700;
  color: var(--m-ink);
  line-height: 1.35;
}

.rate-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--m-ink-light);
  background: var(--m-rule);
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 2px;
}
.mandi-dark .rate-tag {
  background: var(--m-rule-strong);
}

.rate-mandi {
  font-size: 13px;
  font-weight: 500;
  color: var(--m-ink-mid);
  margin-top: 2px;
  line-height: 1.35;
}

.rate-price {
  font-family: 'Mukta Mahee', 'Noto Sans Gurmukhi', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--m-green);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.mandi-dark .rate-price {
  color: var(--m-gold-bright);
}

.rate-best {
  color: var(--m-green) !important;
  position: relative;
}
.mandi-dark .rate-best {
  color: var(--m-gold-bright) !important;
}

.rate-range {
  font-size: 12px;
  font-weight: 500;
  color: var(--m-ink-light);
  text-align: right;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ═══════════════════════════════
   Progress bar
   ═══════════════════════════════ */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  background: var(--m-gold);
  z-index: 60;
  transition: width 200ms var(--ease-expo);
  pointer-events: none;
}

/* ═══════════════════════════════
   Toast
   ═══════════════════════════════ */

.mandi-toast {
  background: var(--m-surface);
  border: 1px solid var(--m-rule-strong);
  border-radius: 12px;
  box-shadow: var(--m-shadow), 0 12px 40px rgba(28,16,8,0.08);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mandi-toast-btn {
  background: var(--m-green);
  color: #FFF;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 6px;
}

/* ═══════════════════════════════
   Empty state
   ═══════════════════════════════ */

.mandi-empty {
  text-align: center;
  padding: 3rem 1.5rem;
}

/* ═══════════════════════════════
   Animations
   ═══════════════════════════════ */

@keyframes card-up {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.card-enter { animation: card-up 250ms var(--ease-expo) both; }

@keyframes spin {
  to { transform: rotate(360deg); }
}
.refresh-spin { animation: spin 800ms linear infinite; }

.htmx-swapping { opacity: 0; transition: opacity 100ms ease; }
.htmx-settling { opacity: 1; transition: opacity 100ms ease; }

/* ═══════════════════════════════
   Utility
   ═══════════════════════════════ */

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { scrollbar-width: none; }

input::placeholder {
  color: var(--m-ink-light);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .card-enter { animation: none; }
  .refresh-spin { animation: none; }
  .progress-bar { transition: none; }
  body.mandi-app::after { display: none; }
}
