/* ==========================================================================
   Fouad Al Shami Supermarket — shared design system
   Palette: bold red (accent/CTA) + rich gold-yellow (brand/identity),
   dark charcoal (header/sidebar), warm cream neutrals.
   No external font/icon requests — system font stack keeps first paint fast.
   ========================================================================== */

:root {
  --brand: #ffe600;
  --brand-dark: #d9c400;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --black: #1c2321;
  --ink: #2b2320;
  --cream: #fffaf0;
  --white: #ffffff;
  --gray-100: #f4f1ec;
  --gray-200: #e7e1d7;
  --gray-400: #b8ada0;
  --gray-600: #7a6f63;
  --success: #1f8a4c;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 6px 20px rgba(26, 22, 19, 0.1);
  --shadow-lg: 0 14px 40px rgba(26, 22, 19, 0.18);
  --font: 'Segoe UI', Tahoma, Geneva, 'Noto Kufi Arabic', Verdana, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--accent); color: var(--white); }

[dir="rtl"] body { direction: rtl; }
[dir="ltr"] body { direction: ltr; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 14px;
}
@media (min-width: 640px) {
  .container { padding: 0 20px; }
}
@media (min-width: 1024px) {
  .container { padding: 0 24px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-weight: 700;
  font-size: 15px;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: var(--accent-dark); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-yellow { background: var(--brand); color: var(--accent-dark); }
.btn-yellow:hover { background: var(--brand-dark); color: var(--accent-dark); }
.btn-dark { background: var(--black); color: var(--white); }
.btn-dark:hover { background: #000; }
.btn-outline { background: transparent; border: 2px solid var(--black); color: var(--black); }
.btn-outline:hover { background: var(--black); color: var(--white); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.item-card .btn-sm { padding: 6px 6px; font-size: 11px; margin-top: 2px; }
@media (min-width: 640px) {
  .item-card .btn-sm { padding: 6px 12px; font-size: 13px; }
}
.btn-danger { background: #fbe3e3; color: var(--accent-dark); }
.btn-danger:hover { background: #f5c1c1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Header ---------- */
:root { --header-h: 58px; }
@media (min-width: 640px) { :root { --header-h: 76px; } }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--black);
  border-bottom: 3px solid var(--brand);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 1 auto;
  min-width: 0;
}
.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}
@media (min-width: 640px) {
  .brand-mark { width: 46px; height: 46px; }
}
.brand-text { color: var(--white); line-height: 1.15; overflow: hidden; min-width: 0; }
.brand-text .name {
  font-weight: 800;
  font-size: clamp(10.5px, 3.6vw, 14px);
  line-height: 1.4;
  color: var(--brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
  padding-bottom: 1px;
}
.brand-text .tag { font-size: 11.5px; color: var(--gray-400); }
@media (min-width: 640px) {
  .brand-text .name { font-size: 16px; }
}

.header-spacer { flex: 1 1 auto; min-width: 0; }

.icon-btn {
  background: var(--white);
  color: var(--black);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 2px solid var(--brand);
}
.search-toggle { display: flex; }
@media (min-width: 640px) {
  .search-toggle { display: none; }
}

.search-box {
  flex: 1 1 320px;
  max-width: 420px;
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: 999px;
  padding: 9px 16px;
  gap: 8px;
}
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  background: transparent;
}

/* On phones the search bar drops below the header as a full-width strip that
   only appears when the search icon is tapped, instead of permanently eating
   header space. */
@media (max-width: 639px) {
  .search-box {
    display: none;
    position: fixed;
    top: var(--header-h);
    inset-inline: 0;
    max-width: none;
    z-index: 49;
    border-radius: 0;
    padding: 10px 14px;
    box-shadow: var(--shadow);
  }
  .search-box.open { display: flex; }
}

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang-toggle {
  background: var(--white);
  color: var(--black);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 12.5px;
  border: 2px solid var(--brand);
}
.cart-btn {
  position: relative;
  background: var(--brand);
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 8px 13px;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
@media (min-width: 640px) {
  .lang-toggle { padding: 8px 14px; font-size: 13px; }
  .cart-btn { padding: 10px 16px; font-size: 14px; }
}
.cart-count {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  background: var(--accent);
  color: var(--white);
  font-size: 11px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--black);
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  padding: 22px 0 26px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 88% 15%, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 2; }
.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(20px, 5vw, 42px);
  font-weight: 900;
  color: var(--accent-dark);
  line-height: 1.2;
}
.hero p { margin: 0; font-size: 14px; color: var(--accent-dark); opacity: 0.85; font-weight: 600; }
@media (min-width: 640px) {
  .hero { padding: 46px 0 54px; }
  .hero p { font-size: 17px; }
}

/* ---------- Section headings ---------- */
.section { padding: 18px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0; font-size: 17px; font-weight: 800; }
.section-head .crumb { font-size: 12px; color: var(--gray-600); }
.crumb a { color: var(--accent); font-weight: 700; }
@media (min-width: 640px) {
  .section { padding: 34px 0; }
  .section-head { margin-bottom: 18px; }
  .section-head h2 { font-size: 22px; }
  .section-head .crumb { font-size: 13px; }
}

/* ---------- Grids / cards ---------- */
.grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 420px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 640px) {
  .grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 1024px) {
  .grid { gap: 18px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
.tile-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  display: block;
}
@media (min-width: 640px) {
  .tile-card { border-radius: var(--radius); }
}
.tile-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.tile-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--gray-200);
  object-fit: cover;
}
.tile-img.placeholder { display: flex; align-items: center; justify-content: center; font-size: 26px; }
.tile-body { padding: 8px 9px; }
.tile-body .t {
  font-weight: 700;
  font-size: 12.5px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}
@media (min-width: 640px) {
  .tile-img.placeholder { font-size: 34px; }
  .tile-body { padding: 12px 14px; }
  .tile-body .t { font-weight: 800; font-size: 15px; }
}

.item-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 420px) {
  .item-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 640px) {
  .item-grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (min-width: 1024px) {
  .item-grid { gap: 18px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
.item-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) {
  .item-card { border-radius: var(--radius); }
}
.item-card .tile-img { aspect-ratio: 1 / 1; }
.item-card .body { padding: 8px 9px 9px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.item-card .name {
  font-weight: 700;
  font-size: 12.5px;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}
.item-card .desc { display: none; }
.price-line { font-weight: 800; color: var(--accent-dark); font-size: 12px; line-height: 1.3; }
.price-line small { font-weight: 600; color: var(--gray-600); font-size: 10.5px; }
.badge-stock {
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  background: var(--brand);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}
.item-media { position: relative; }
.item-card .body .spacer { flex: 1; }
@media (min-width: 640px) {
  .item-card .body { padding: 12px 14px 14px; gap: 6px; }
  .item-card .name { font-weight: 800; font-size: 15px; }
  .item-card .desc {
    display: -webkit-box; font-size: 12.5px; color: var(--gray-600); margin: 0;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .price-line { font-size: 14.5px; }
  .price-line small { font-size: 12px; }
  .badge-stock { top: 8px; inset-inline-start: 8px; font-size: 11px; padding: 3px 8px; }
}

/* ---------- Modal (item detail / cart / checkout) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,16,13,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.overlay.open { opacity: 1; pointer-events: auto; }
@media (min-width: 720px) {
  .overlay { align-items: center; }
}
.modal {
  background: var(--white);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  transform: translateY(24px);
  transition: transform .18s ease;
}
@media (min-width: 720px) {
  .modal { border-radius: 18px; }
}
.overlay.open .modal { transform: translateY(0); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: var(--white);
}
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-close { background: var(--gray-100); border-radius: 999px; width: 34px; height: 34px; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 18px; }
.modal-foot { padding: 16px 18px; border-top: 1px solid var(--gray-200); position: sticky; bottom: 0; background: var(--white); }

.variant-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.variant-chip {
  border: 2px solid var(--gray-200);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  background: var(--white);
}
.variant-chip.active { border-color: var(--accent); background: #fbe3e3; color: var(--accent-dark); }

.qty-stepper { display: flex; align-items: center; gap: 10px; }
.qty-stepper button {
  width: 34px; height: 34px; border-radius: 999px; border: none;
  background: var(--gray-100); font-size: 18px; font-weight: 800;
}
.qty-stepper span { min-width: 26px; text-align: center; font-weight: 800; }

/* ---------- Cart ---------- */
.cart-line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.cart-line img { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; background: var(--gray-200); }
.cart-line .info { flex: 1; }
.cart-line .info .n { font-weight: 700; font-size: 14px; }
.cart-line .info .v { font-size: 12px; color: var(--gray-600); }
.cart-line .remove { color: var(--accent); font-size: 12px; font-weight: 700; background: none; border: none; padding: 0; }
.cart-totals { display: flex; justify-content: space-between; font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.cart-totals small { font-weight: 600; color: var(--gray-600); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-600); }
.empty-state .emoji { font-size: 42px; margin-bottom: 8px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--black);
  color: var(--gray-400);
  padding: 34px 0 24px;
  margin-top: 30px;
  font-size: 13.5px;
}
.site-footer .container { display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-between; align-items: center; }
.site-footer .fname { color: var(--brand); font-weight: 800; font-size: 15px; }
.footer-credit {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11.5px;
  color: var(--gray-400);
  text-align: center;
  direction: ltr;
}

/* ---------- Payment methods notice (homepage, informational only) ---------- */
.payment-info {
  background: var(--white);
  border-top: 3px solid var(--brand);
  border-bottom: 3px solid var(--accent);
  padding: 14px 0;
}
.payment-info .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  text-align: center;
}
.payment-info .pi-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray-600);
}
.payment-info .pi-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.payment-info .pi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-100);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-dark);
}
.payment-info .pi-chip .ic { font-size: 15px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Skeleton loading ---------- */
.skeleton { background: linear-gradient(90deg, var(--gray-200) 25%, #f3efe6 37%, var(--gray-200) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- Utility ---------- */
.mt-0 { margin-top: 0; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; }

@media (max-width: 640px) {
  .brand-text .tag { display: none; }
  .hero { padding: 22px 0 28px; }
  /* Free up header space so the full store name shows instead of truncating */
  #cartLabel { display: none; }
  .cart-btn { padding: 8px 10px; }
  .lang-toggle { padding: 7px 10px; }
  .search-toggle.icon-btn { width: 32px; height: 32px; min-width: 32px; font-size: 14px; }
}