/* =============================================================================
   Mobile-first styles for the vegetable store PWA.
   ============================================================================= */

:root {
  --green-700: #1b5e20;
  --green-600: #2e7d32;
  --green-500: #43a047;
  --green-100: #e8f5e9;
  --green-50:  #f1f8f2;
  --ink:       #1c2820;
  --muted:     #6b7a70;
  --line:      #e2e8e3;
  --bg:        #f7f9f7;
  --white:     #ffffff;
  --danger:    #c62828;
  --radius:    14px;
  --shadow:    0 2px 10px rgba(27, 94, 32, .09);
  --tap:       46px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Gujarati", "Noto Sans", system-ui, -apple-system,
               "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, p { margin: 0 0 .6em; }
a { color: var(--green-700); }
img { display: block; max-width: 100%; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ------------------------------- Header ------------------------------------ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--green-600);
  color: var(--white);
  padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
}

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .2px;
}
.brand-mark { font-size: 1.3rem; }

.lang-toggle,
.cart-button {
  min-width: var(--tap);
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .12);
  color: var(--white);
  border-radius: 10px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  padding: 0 10px;
  -webkit-tap-highlight-color: transparent;
}
.lang-toggle:active, .cart-button:active { background: rgba(255, 255, 255, .25); }

.cart-button { position: relative; font-size: 1.15rem; }
.cart-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ffd54f;
  color: var(--ink);
  font-size: .72rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}

/* -------------------------------- Layout ----------------------------------- */

.page { max-width: 760px; margin: 0 auto; }

.section { padding: 18px 14px 28px; }

.hero {
  background: linear-gradient(135deg, var(--green-600), var(--green-500));
  color: var(--white);
  padding: 26px 18px 30px;
}
.hero-content { max-width: 760px; margin: 0 auto; }
.hero-kicker { font-size: 1.5rem; letter-spacing: 6px; }
.hero h1 { font-size: 1.6rem; line-height: 1.25; margin: 8px 0; }
.hero p { font-size: .98rem; opacity: .95; margin: 0; }

.section-title { font-size: 1.15rem; margin: 4px 0 12px; }
.page-title { font-size: 1.5rem; margin: 4px 0 16px; }

.page-intro { text-align: center; margin-bottom: 18px; }
.page-emoji { font-size: 2.4rem; }
.page-intro h1 { font-size: 1.5rem; }
.lead { color: var(--muted); }

/* ------------------------------- Search ------------------------------------ */

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.search-wrap input {
  flex: 1;
  min-height: var(--tap);
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--green-600); border-color: var(--green-600); color: var(--white); }

.status { margin: 4px 0 10px; }
.notice {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .85rem;
  color: var(--muted);
}
.notice-ok     { color: var(--green-700); background: var(--green-50); border-color: #cfe6d2; }
.notice-warn   { color: #8a5a00; background: #fff8e1; border-color: #ffe0a6; }
.notice-info   { color: var(--green-700); background: var(--green-50); border-color: #cfe6d2; margin-top: 16px; }
.link-btn {
  border: 0; background: none; padding: 0 2px;
  color: var(--green-700); font: inherit; font-weight: 700;
  text-decoration: underline; cursor: pointer;
}

/* ------------------------------- Products ---------------------------------- */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.product-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.product-image { position: relative; aspect-ratio: 4 / 3; background: var(--green-100); }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-card.is-oos .product-image img { filter: grayscale(1); opacity: .55; }
.product-card.is-oos { background: #fafafa; }

.oos-ribbon {
  position: absolute;
  left: 8px; top: 8px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: .7rem;
  padding: 4px 8px;
  border-radius: 6px;
}

.product-body { padding: 10px 11px 12px; display: flex; flex-direction: column; flex: 1; }
.product-category { font-size: .7rem; text-transform: uppercase; letter-spacing: .4px; color: var(--green-600); font-weight: 700; }
.product-name { font-size: .98rem; margin: 2px 0 4px; line-height: 1.25; }
.product-price { font-weight: 800; font-size: 1.05rem; margin: 0 0 10px; }
.product-price span { font-weight: 500; font-size: .8rem; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: .92rem;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--green-600); color: var(--white); }
.btn-primary:active { background: var(--green-700); }
.btn-success { background: #128c3e; color: var(--white); }
.btn-success:active { background: #0b7a34; }
.btn-ghost { background: var(--white); color: var(--green-700); border-color: var(--line); }
.btn-block { width: 100%; margin-top: 10px; }
.btn-large { min-height: 54px; font-size: 1rem; }
.add-btn { width: 100%; margin-top: auto; }

.oos-badge {
  margin-top: auto;
  display: block;
  text-align: center;
  padding: 12px 6px;
  border-radius: 10px;
  background: #eeeeee;
  color: #777;
  font-size: .85rem;
  font-weight: 700;
}

/* --------------------------------- Info ------------------------------------ */

.info-card,
.summary-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.info-card p:last-child { margin-bottom: 0; }

.info-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-icon { font-size: 1.3rem; line-height: 1.2; }
.info-row div { display: flex; flex-direction: column; }
.info-label { font-size: .8rem; color: var(--muted); }
.info-row strong { font-size: .96rem; }

/* ------------------------------- Checkout ---------------------------------- */

.checkout-form label { display: block; margin-bottom: 14px; }
.checkout-form label > span { display: block; font-size: .88rem; font-weight: 700; margin-bottom: 6px; }
.checkout-form input,
.checkout-form textarea,
.checkout-form select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font: inherit;
  color: var(--ink);
  outline: none;
  resize: vertical;
}
.checkout-form input:focus,
.checkout-form textarea:focus,
.checkout-form select:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(67, 160, 71, .14); }
.checkout-form select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--green-600) 50%), linear-gradient(135deg, var(--green-600) 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.form-error {
  background: #ffebee;
  color: var(--danger);
  border: 1px solid #ffcdd2;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .88rem;
}

.summary-line,
.summary-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.summary-line + .summary-line { border-top: 1px solid var(--line); }
.summary-total {
  border-top: 2px solid var(--line);
  margin-top: 6px;
  padding-top: 12px;
  font-size: 1.1rem;
  color: var(--green-700);
}

.empty-state { text-align: center; padding: 32px 16px; grid-column: 1 / -1; color: var(--muted); }
.empty-illustration { font-size: 2.5rem; margin-bottom: 6px; }

/* ----------------------------- Bottom nav ---------------------------------- */

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--white);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.nav-item {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  font: inherit;
  font-size: .72rem;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-icon { font-size: 1.25rem; line-height: 1; filter: grayscale(.5); }
.nav-item.active { color: var(--green-700); font-weight: 700; }
.nav-item.active .nav-icon { filter: none; }

/* ---------------------------- Cart drawer ---------------------------------- */

.cart-overlay { position: fixed; inset: 0; z-index: 50; }
.cart-overlay[hidden] { display: none; }
.cart-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .42); }

.cart-drawer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up .2s ease-out;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@keyframes slide-up { from { transform: translateY(30px); opacity: .7; } to { transform: none; opacity: 1; } }

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cart-head h2 { font-size: 1.1rem; margin: 0; }
.icon-btn {
  min-width: 40px; min-height: 40px;
  border: 0; background: var(--bg); border-radius: 10px;
  font-size: 1rem; cursor: pointer;
}

.cart-items { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cart-line {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  grid-template-areas: "thumb info qty" "thumb price qty";
  align-items: center;
  gap: 2px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.cart-line-thumb { grid-area: thumb; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--green-100); }
.cart-line-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-line-info { grid-area: info; display: flex; flex-direction: column; min-width: 0; }
.cart-line-info strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-price { grid-area: price; color: var(--green-700); font-size: .9rem; }
.qty-control {
  grid-area: qty;
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.qty-control button {
  width: 40px; height: 40px;
  border: 0; background: var(--green-50); color: var(--green-700);
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.qty-control span { min-width: 28px; text-align: center; font-weight: 700; }

.cart-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); background: var(--white); }
.cart-total { display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem; }
.cart-total strong { font-size: 1.2rem; color: var(--green-700); }
.cart-foot .btn { margin-top: 8px; }

/* ------------------------------ Responsive --------------------------------- */

@media (min-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .section { padding: 22px 18px 34px; }
  .cart-drawer {
    left: auto; right: 0; top: 0; bottom: 0;
    width: min(420px, 100%);
    max-height: none;
    border-radius: 18px 0 0 18px;
    animation: slide-in .2s ease-out;
  }
  @keyframes slide-in { from { transform: translateX(30px); opacity: .7; } to { transform: none; opacity: 1; } }
}

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