/* ===================================================
   DESIGN TOKENS — মাটির রং (terracotta) + ধানক্ষেতের সবুজ
   =================================================== */
:root {
  --clay: #8B5A2B;        /* primary - মাটির রং */
  --clay-dark: #6B4423;
  --rice-green: #4A6B3A;  /* secondary - ধানক্ষেত */
  --turmeric: #D98E04;    /* accent - হলুদ */
  --cream: #FBF6EE;       /* background */
  --paper: #FFFFFF;
  --ink: #2B2118;
  --ink-soft: #6B5D4F;
  --line: #E8DDC8;
  --danger: #B3412A;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(43,33,24,0.08);
  --shadow-lift: 0 8px 24px rgba(43,33,24,0.16);

  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Noto Sans Bengali', 'Hind Siliguri', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ===================================================
   TOP BAR
   =================================================== */
.topbar {
  background: var(--clay);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--turmeric);
  color: var(--clay-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text p {
  margin: 0;
  font-size: 0.78rem;
  opacity: 0.85;
}

.cart-btn {
  position: relative;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.cat-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 16px 12px;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: background 0.15s;
}

.cat-chip.active {
  background: var(--turmeric);
  border-color: var(--turmeric);
  color: var(--clay-dark);
  font-weight: 600;
}

/* ===================================================
   SEARCH
   =================================================== */
.search-wrap {
  padding: 14px 16px 6px;
  background: var(--cream);
}

#searchInput {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-size: 0.95rem;
  color: var(--ink);
}
#searchInput:focus {
  outline: none;
  border-color: var(--clay);
}

/* ===================================================
   PRODUCT GRID
   =================================================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 10px 16px 90px;
}

@media (min-width: 600px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}

.product-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #F0E6D2, #E4D5B7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

.product-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.product-name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

.product-unit {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.product-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.product-price {
  font-weight: 700;
  color: var(--rice-green);
  font-size: 0.95rem;
}

.stock-low {
  font-size: 0.68rem;
  color: var(--danger);
  font-weight: 600;
}

.add-btn {
  background: var(--clay);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.add-btn:active { transform: scale(0.96); }

.qty-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--rice-green);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}

.qty-stepper button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-stepper span {
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 16px;
  text-align: center;
}

.qty-input {
  width: 34px;
  text-align: center;
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 3px 0;
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.qty-input:focus { outline: 2px solid var(--turmeric); }

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 20px;
}

/* ===================================================
   FLOATING CART BUTTON
   =================================================== */
.fab-cart {
  position: fixed;
  bottom: 18px;
  left: 16px;
  right: 16px;
  background: var(--rice-green);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 15px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: var(--shadow-lift);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#fabCartCount {
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
}

/* ===================================================
   OVERLAY + DRAWER
   =================================================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(43,33,24,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 40;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--cream);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0,0,0,0.15);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--clay);
  color: #fff;
}
.drawer-head h2 { margin: 0; font-size: 1.1rem; }

.close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cart-line {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.cart-line-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #F0E6D2, #E4D5B7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.cart-line-info { flex: 1; min-width: 0; }
.cart-line-name { font-size: 0.85rem; font-weight: 600; }
.cart-line-price { font-size: 0.78rem; color: var(--ink-soft); }

.cart-line-remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.9rem;
  padding: 4px;
}

.cart-empty-msg {
  text-align: center;
  color: var(--ink-soft);
  margin-top: 40px;
  padding: 0 20px;
}

.drawer-foot {
  padding: 16px 20px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.row { display: flex; align-items: center; justify-content: space-between; }
.total-row { font-size: 1.05rem; margin: 6px 0 12px; }
.total-row strong { color: var(--rice-green); font-size: 1.2rem; }

#subtotalRowWrap {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.discount-row {
  font-size: 0.85rem;
  color: var(--rice-green);
  font-weight: 600;
  margin-bottom: 4px;
}

.coupon-box {
  margin-bottom: 12px;
}

.coupon-input-row {
  display: flex;
  gap: 8px;
}

#couponInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-size: 0.85rem;
  background: var(--paper);
  color: var(--ink);
  text-transform: uppercase;
}
#couponInput:focus { outline: none; border-color: var(--clay); }
#couponInput:disabled { background: #F0EAE0; color: var(--ink-soft); }

#applyCouponBtn {
  background: var(--clay);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.coupon-msg {
  margin: 6px 0 0;
  font-size: 0.78rem;
  min-height: 1em;
}
.coupon-msg.success { color: var(--rice-green); font-weight: 600; }
.coupon-msg.error { color: var(--danger); font-weight: 600; }

.scheme-note {
  background: #FDF3DC;
  border: 1px dashed var(--turmeric);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--clay-dark);
  font-weight: 600;
  margin-bottom: 12px;
}
.scheme-note.active {
  background: #E9F1E4;
  border-color: var(--rice-green);
  color: var(--rice-green);
}

.primary-btn {
  width: 100%;
  background: var(--rice-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 0.98rem;
  font-weight: 700;
}
.primary-btn:active { transform: scale(0.98); }

/* ===================================================
   CHECKOUT FORM
   =================================================== */
#checkoutForm label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

#checkoutForm input,
#checkoutForm textarea {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
}
#checkoutForm input:focus,
#checkoutForm textarea:focus {
  outline: none;
  border-color: var(--clay);
}

.radio-group {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group legend {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 2px;
}

.radio-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

.radio-pill input { accent-color: var(--clay); width: 16px; height: 16px; }

.summary-box {
  background: var(--paper);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: pre-line;
}

.hint-text {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}

/* ===================================================
   TOAST
   =================================================== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 60;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================================================
   INSTALL BANNER
   =================================================== */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  z-index: 35;
}
.install-banner span { flex: 1; }
.install-banner button {
  background: var(--turmeric);
  color: var(--clay-dark);
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}
#dismissInstall {
  background: transparent !important;
  color: #fff !important;
  padding: 4px !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
