/* ══════════════════════════════════════════════
   rates.css
   AgriMandi.Farm | Public Live Rates (Gudur Lemon Market)
   ══════════════════════════════════════════════ */

body {
  background: var(--green);
}

.wrapper {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 40px;
}

/* Tablet+ (iPad/Android tabs and up) — widen the card instead of
   leaving it stretched thin in a sea of empty green. Rates List
   and Village Leaderboard deliberately stay single-column even
   here: both show a rank number (1, 2, 3...) meant to be read
   top-to-bottom, and snaking that into 2 columns (1 top-left, 2
   top-right, 3 bottom-left...) breaks the ranking at a glance —
   they just get more breathing room from the wider wrapper. */
@media (min-width: 600px) {
  .wrapper {
    max-width: 700px;
  }
}

/* Header is a two-row block: the compact icon/logo/badge row, then
   a small full-text status line — both live INSIDE <header> so the
   yellow border-bottom sits under both rows together, not wedged
   between them. */
header {
  background: linear-gradient(
    135deg,
    var(--green) 0%,
    var(--green-md) 100%
  );
  border-bottom: 3px solid var(--lemon);
  padding: 10px 12px 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Row 1 — everything sized to always fit on one line, even on
   ~320-360px low-end Android widths. clamp() scales the wordmark
   with viewport width instead of relying on fixed breakpoints, so
   it stays readable from small phones up to tablets without a
   wrap (the old wrap — 🍋 landing on its own line above
   "AgriMandi.Farm" — was the root cause of the previous overlap
   bug). */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  overflow: hidden;
}

header .logo {
  font-family: "Playfair Display", serif;
  font-size: clamp(0.95rem, 5vw, 1.35rem);
  color: var(--lemon);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

header .logo span {
  color: var(--white);
}

.live-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--red);
  color: #fff;
  font-size: clamp(0.58rem, 2.4vw, 0.68rem);
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  animation: blink 1s infinite;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Row 2 — full, un-abbreviated status text (the badge in Row 1
   only has room for a short word like "LIVE"/"CLOSED"). Free to
   wrap to a second line on very narrow phones since it's no
   longer squeezed between other flex siblings. */
.header-status-line {
  text-align: center;
  font-size: clamp(0.68rem, 3vw, 0.78rem);
  color: rgba(255, 255, 255, 0.7);
  margin-top: 6px;
}

/* Icon-only (no "Home" label) so it stays a fixed, small footprint
   on every screen size — the wordmark in the center gets the
   space instead. */
.btn-home {
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--lemon);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-home:hover {
  background: var(--lemon);
  color: var(--green);
}

.status-bar {
  /* Bottom margin 0 (was 14px, the page's only bottom margin — made the
     status-banner → View Today's Rates pair a 22px outlier gap): the
     next card's own top margin governs the gap instead, per this page's
     zero-bottom card convention (.hero-card/.state-card/.leaderboard). */
  margin: 14px 16px 0;
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.9rem;
}

.status-open {
  background: rgba(76, 175, 115, 0.25);
  border: 1.5px solid var(--green-lt);
  color: var(--green-lt);
}
.status-closed {
  background: rgba(229, 57, 53, 0.2);
  border: 1.5px solid var(--red);
  color: #ff6b6b;
}
.status-icon {
  font-size: 1.4rem;
}

/* ── Live activity ticker ─────────────────────── */
.ticker-wrap {
  /* 6px top (same standard value .hero-card/.state-card use) — keeps
     the ticker from sitting flush under the status banner now that the
     banner's own bottom margin is gone. */
  margin: 6px 16px 0;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 0;
  overflow: hidden;
  white-space: nowrap;
  border-radius: 8px;
}
.ticker-track {
  display: inline-flex;
  font-size: 0.72rem;
  color: var(--lemon);
  font-weight: 700;
  animation: tickerScroll 22s linear infinite;
}
.ticker-seg {
  white-space: nowrap;
  padding-right: 60px;
}
@keyframes tickerScroll {
  0% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ── Generic state card (closed / holiday / opening-soon /
   waiting-for-first-sale / no-sales-today) ─────────────── */
.state-card {
  margin: 6px 16px 0;
  text-align: center;
  padding: 30px 16px 22px;
  color: rgba(255, 255, 255, 0.5);
}
.state-card .icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
}
.state-card .icon.lemon-loader {
  display: inline-block;
  animation: lemonGrow 1.5s ease-in-out infinite;
}
@keyframes lemonGrow {
  0% {
    transform: scale(0.4);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(0.4);
    opacity: 0.45;
  }
}
.state-card .title {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
}
.state-card .sub {
  font-size: 0.78rem;
  margin-top: 4px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 16px 4px;
  margin-top: 14px;
}

.section-head h2 {
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  color: var(--lemon);
  font-weight: 700;
  white-space: nowrap;
}

.section-head .section-note {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

/* ── Hero "today's top rate" card ─────────────── */
.hero-card {
  margin: 6px 16px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(247, 224, 58, 0.3);
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hero-left {
  text-align: left;
  min-width: 0;
}
.hero-right {
  text-align: right;
  flex-shrink: 0;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 107, 107, 0.15);
  color: #ff8a8a;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hero-label {
  font-size: 0.7rem;
  color: #2ecc71;
  font-weight: 700;
  margin-top: 0;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hero-mark {
  font-family: "Playfair Display", serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  margin-top: 2px;
}
.hero-village {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.5);
}
.hero-rate-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}
.hero-rate {
  font-family: "Playfair Display", serif;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--lemon);
  line-height: 1;
}
.hero-rate-unit {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}
.hero-trend {
  font-size: 0.72rem;
  font-weight: 600;
  margin-left: 4px;
}
.hero-trend.up {
  color: var(--green-lt);
}
.hero-trend.down {
  color: #ff8a8a;
}

/* ── Mini stats ────────────────────────────────── */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px 16px 0;
}
.mini-stat-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.mini-stat-card .num {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
}
.mini-stat-card .label {
  font-size: 0.64rem;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}

/* ── Top 3 podium ──────────────────────────────── */
.podium-row {
  display: flex;
  gap: 8px;
  padding: 0 16px;
}
.podium-card {
  flex: 1;
  min-width: 0;
  border-radius: 14px;
  padding: 8px 4px;
  text-align: center;
}
.podium-1 {
  background: linear-gradient(
    160deg,
    #d4b800 0%,
    #f7e03a 55%,
    #ffb800 100%
  );
  box-shadow: 0 6px 20px rgba(247, 224, 58, 0.25);
}
.podium-2 {
  background: linear-gradient(160deg, #c0c0c0 0%, #eee 100%);
}
.podium-3 {
  background: linear-gradient(160deg, #cd7f32 0%, #e0a868 100%);
}
.podium-medal {
  font-size: 1rem;
}
.podium-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: #173821;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-village {
  font-size: 0.52rem;
  font-weight: 600;
  color: rgba(23, 56, 33, 0.65);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-rate {
  font-family: "Playfair Display", serif;
  font-size: 0.9rem;
  font-weight: 900;
  color: #173821;
  margin-top: 3px;
}

/* ── Shop-wise Low / Avg / Top (collapsible) ───── */
.shop-range-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 32px);
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(247, 224, 58, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: var(--lemon);
  font-family: "DM Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.shop-range-toggle:hover {
  background: rgba(247, 224, 58, 0.08);
}

.shop-range-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 16px 0;
}
.shop-range-panel.hidden {
  display: none;
}

.shop-range-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.045);
  color: var(--white);
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
}
.shop-range-row:active {
  background: rgba(247, 224, 58, 0.08);
}

.sr-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.sr-code {
  background: rgba(247, 224, 58, 0.15);
  color: var(--lemon);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
}
.sr-range {
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--lemon);
  white-space: nowrap;
}

.sr-track {
  position: relative;
  height: 6px;
  margin: 12px 7px 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, #ff8a65, var(--lemon), #4ade80);
}
/* Low / Avg / Top colours repeat in the legend dots below the bar. */
.sr-dot-low { --dot: #ff8a65; }
.sr-dot-avg { --dot: var(--lemon); }
.sr-dot-top { --dot: #4ade80; }
.sr-dot {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--dot);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 8px var(--dot);
  transform: translate(-50%, -50%);
}

.sr-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}
.sr-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.sr-key {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 5px var(--dot);
}

/* ── Filters ───────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  padding: 14px 16px 0;
}
.filter-row select,
.filter-row input {
  flex: 1;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 42, 24, 0.95);
  color: #fff;
  font-family: "DM Sans", sans-serif;
  font-size: 0.8rem;
  outline: none;
}

/* ── Glassy Shop filter (attachGlassySelect(), common.js) ──
   The page doesn't load dashboard-common.css (public page, kept light), so
   only the bits this one dropdown needs live here. The native open list is
   OS-painted (blue/white) — this menu replaces it with the app's look. */
.filter-row .glassy-select {
  position: relative;
  flex: 1;
  min-width: 0;
}
.glassy-select-native {
  display: none;
}
.glassy-select-trigger {
  display: block;
  width: 100%;
  position: relative;
  padding: 9px 28px 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(18, 42, 24, 0.95);
  color: #fff;
  font-family: "DM Sans", sans-serif;
  font-size: 0.8rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.glassy-select-trigger::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lemon);
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}
.glassy-select-trigger.open {
  border-color: rgba(247, 224, 58, 0.4);
}
.glassy-select-trigger.open::after {
  transform: translateY(-50%) rotate(180deg);
}
.glassy-select-menu {
  display: none;
  position: fixed;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(23, 56, 33, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(247, 224, 58, 0.2);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 99999;
}
.glassy-select-menu.show {
  display: block;
}
.glassy-select-option {
  display: block;
  position: relative;
  width: 100%;
  padding: 11px 28px 11px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-family: "DM Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.glassy-select-option:last-child {
  border-bottom: none;
}
.glassy-select-option:hover {
  background: rgba(255, 255, 255, 0.06);
}
.glassy-select-option.active {
  color: var(--lemon);
  font-weight: 700;
  background: rgba(247, 224, 58, 0.08);
}
.glassy-select-option.active::after {
  content: "✓";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

/* ── All rates list ────────────────────────────── */
.rates-list {
  padding: 8px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rate-row {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rate-rank {
  width: 18px;
  text-align: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 700;
  flex-shrink: 0;
}

.rate-shop-badge {
  background: rgba(247, 224, 58, 0.15);
  color: var(--lemon);
  font-size: 0.63rem;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rate-info {
  flex: 1;
  min-width: 0;
}

.rate-mark {
  font-weight: 600;
  color: var(--white);
  font-size: 0.84rem;
}

.rate-village {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 1px;
}

.rate-status-badge {
  font-size: 0.64rem;
  margin-top: 2px;
}
.rate-status-live {
  color: var(--green-lt);
}
.rate-status-ended {
  color: rgba(255, 255, 255, 0.4);
}

.rate-value-col {
  text-align: right;
  flex-shrink: 0;
}

.rate-value {
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--lemon);
}

.rate-trend {
  font-size: 0.62rem;
  margin-top: 1px;
}
.rate-trend.up {
  color: var(--green-lt);
}
.rate-trend.down {
  color: #e08a8a;
}

.view-all-btn {
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(247, 224, 58, 0.25);
  color: var(--lemon);
  font-size: 0.8rem;
  font-weight: 600;
  margin: 8px 16px 4px;
  cursor: pointer;
  background: none;
  width: calc(100% - 32px);
}
.view-all-btn:hover {
  background: rgba(247, 224, 58, 0.08);
}

.view-arrow {
  display: inline-block;
  transition: transform 0.25s ease;
}
.view-arrow.open {
  transform: rotate(180deg);
}

/* ── All Rates pagination (expanded view, 10/page) ──────
   Same .pagination-controls block every paginated page carries its own
   copy of (billing/transport/stock-entry/sales-entry CSS — see
   billing.css's comment for why it's per-page). This page doesn't load
   dashboard-common.css, so the buttons can't inherit .btn-secondary —
   they take the page's own .view-all-btn outline values instead (same
   border/color, no new design constants). */
.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
}

.pagination-controls button {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid rgba(247, 224, 58, 0.25);
  color: var(--lemon);
  background: none;
  cursor: pointer;
}

.pagination-controls button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination-controls span {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
}

/* ── Village leaderboard ───────────────────────── */
.leaderboard {
  margin: 8px 16px 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}

.lb-header {
  background: rgba(247, 224, 58, 0.08);
  padding: 9px 14px;
  display: grid;
  grid-template-columns: 26px 1fr 70px;
  gap: 8px;
  font-size: 0.6rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 700;
}

.lb-row {
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 26px 1fr 70px;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-pos {
  font-weight: 700;
  color: var(--lemon);
  font-size: 0.82rem;
}
.lb-village {
  color: var(--white);
  font-size: 0.83rem;
  font-weight: 600;
}
.lb-meta {
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 1px;
}
.lb-rate {
  font-family: "Playfair Display", serif;
  color: var(--lemon);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

.update-time {
  text-align: center;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 20px;
  letter-spacing: 1px;
}

.empty-state {
  text-align: center;
  padding: 20px 16px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.8rem;
}

.loader {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(247, 224, 58, 0.2);
  border-top-color: var(--lemon);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}
