/* ============================================================
   BASE.CSS — Shared Design System for FreshMart & QuickBite
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=DM+Sans:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
  --font-heading: 'Inter', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* Border Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px;
  --r-2xl: 24px; --r-3xl: 32px; --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.16);
  --shadow-xl: 0 16px 48px rgba(0,0,0,.20);
  --shadow-2xl: 0 24px 64px rgba(0,0,0,.28);

  /* Transitions */
  --ease-fast: 150ms ease;
  --ease-std: 250ms ease;
  --ease-slow: 400ms ease;
  --ease-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index layers */
  --z-base: 1; --z-dropdown: 100; --z-sticky: 200;
  --z-overlay: 300; --z-modal: 400; --z-toast: 500;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); line-height: 1.6; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; outline: none; }
h1,h2,h3,h4,h5,h6 { font-family: var(--font-heading); line-height: 1.25; }

/* ── Utilities ── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--sp-6); }
.container-sm { max-width: 960px; margin: 0 auto; padding: 0 var(--sp-6); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); } .gap-8 { gap: var(--sp-8); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.hidden { display: none !important; }
.pointer { cursor: pointer; }
.relative { position: relative; }
.absolute { position: absolute; }
.overflow-hidden { overflow: hidden; }

/* ── Grid System ── */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--r-md);
}
@keyframes skeleton-wave {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast Notifications ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-radius: var(--r-lg);
  background: #1a1a1a; color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-xl);
  pointer-events: all;
  animation: toast-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px; word-break: break-word;
}
.toast.removing { animation: toast-out 0.25s ease forwards; }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-info { border-left: 3px solid #3b82f6; }
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  opacity: 0; visibility: hidden;
  transition: all var(--ease-std);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-box {
  background: #fff; border-radius: var(--r-2xl);
  padding: var(--sp-6); width: 100%; max-width: 540px;
  box-shadow: var(--shadow-2xl);
  transform: scale(0.92) translateY(20px);
  transition: transform var(--ease-bounce);
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.active .modal-box { transform: scale(1) translateY(0); }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: #f5f5f5; display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; transition: background var(--ease-fast);
}
.modal-close:hover { background: #e5e5e5; }

/* ── Quantity Stepper ── */
.qty-stepper {
  display: inline-flex; align-items: center; gap: 0;
  border-radius: var(--r-full); overflow: hidden;
  border: 1.5px solid currentColor;
}
.qty-stepper button {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
  transition: background var(--ease-fast);
}
.qty-stepper span {
  min-width: 36px; text-align: center;
  font-size: 14px; font-weight: 600;
}

/* ── Star Rating ── */
.stars { color: #FBBF24; letter-spacing: 2px; }
.rating-text { font-size: 13px; color: #888; }

/* ── Price ── */
.price-original { text-decoration: line-through; color: #aaa; font-size: 13px; }
.discount-badge {
  display: inline-block; padding: 2px 8px;
  background: #dcfce7; color: #16a34a;
  border-radius: var(--r-full); font-size: 11px; font-weight: 700;
}

/* ── Form Elements ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: #555; }
.form-input {
  padding: 12px 16px; border: 1.5px solid #e5e7eb;
  border-radius: var(--r-md); font-size: 14px; color: #111;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  background: #fff; width: 100%;
}
.form-input:focus {
  border-color: currentColor;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: var(--sp-16) var(--sp-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
}
.empty-state-icon { font-size: 64px; opacity: 0.3; }
.empty-state h3 { font-size: 20px; color: #333; }
.empty-state p { color: #888; font-size: 14px; }

/* ── Chip / Tag ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1.5px solid #e5e7eb; background: #fff;
  transition: all var(--ease-fast); white-space: nowrap;
}
.chip.active, .chip:hover { border-color: transparent; color: #fff; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes float { 0%,100% { transform: translateY(0px); } 50% { transform: translateY(-12px); } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

.animate-fadeIn { animation: fadeIn 0.4s ease; }
.animate-fadeInUp { animation: fadeInUp 0.5s ease; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-bounce { animation: bounce 1.5s ease-in-out infinite; }

/* ── Mobile Menu Drawer ── */
.mobile-menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0; visibility: hidden; transition: all var(--ease-std);
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }
.mobile-menu-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: #fff; z-index: var(--z-modal);
  transform: translateX(-100%); transition: transform var(--ease-slow);
  display: flex; flex-direction: column; overflow-y: auto;
}
.mobile-menu-drawer.open { transform: translateX(0); }
.mobile-menu-header {
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
}
.mobile-menu-links { padding: var(--sp-4); flex: 1; }
.mobile-menu-links a {
  display: flex; align-items: center; gap: 12px;
  padding: var(--sp-4) var(--sp-4); font-size: 16px; font-weight: 500;
  border-radius: var(--r-lg); color: #333;
  transition: background var(--ease-fast); margin-bottom: 4px;
}
.mobile-menu-links a:hover { background: #f9f9f9; }

/* ── Cart Drawer ── */
.cart-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 100vw;
  background: #fff; z-index: var(--z-modal);
  box-shadow: var(--shadow-2xl);
  transform: translateX(100%);
  transition: transform var(--ease-slow);
  display: flex; flex-direction: column;
}
.cart-drawer.open { transform: translateX(0); }
.cart-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0; visibility: hidden;
  transition: all var(--ease-std);
}
.cart-drawer-overlay.active { opacity: 1; visibility: visible; }
.cart-drawer-header {
  padding: var(--sp-5) var(--sp-5); border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.cart-drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-4); }
.cart-drawer-footer { padding: var(--sp-5); border-top: 1px solid #f0f0f0; flex-shrink: 0; }
.cart-item {
  display: flex; gap: var(--sp-3); padding: var(--sp-4) 0;
  border-bottom: 1px solid #f9f9f9; align-items: center;
}
.cart-item-img {
  width: 56px; height: 56px; border-radius: var(--r-md);
  object-fit: cover; background: #f5f5f5;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 14px; font-weight: 600; }
.cart-item-sub { font-size: 12px; color: #888; }

/* ── Section Headers ── */
.section-header { margin-bottom: var(--sp-8); }
.section-eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; margin-bottom: var(--sp-2);
}
.section-title { font-size: 32px; font-weight: 800; line-height: 1.2; }
.section-subtitle { font-size: 16px; color: #666; margin-top: var(--sp-2); }

/* ── Progress Steps ── */
.steps { display: flex; align-items: center; gap: 0; }
.step {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex: 1; position: relative;
}
.step::after {
  content: ''; position: absolute; top: 20px; left: calc(50% + 20px);
  right: calc(-50% + 20px); height: 2px; background: #e5e7eb;
}
.step:last-child::after { display: none; }
.step-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; border: 2px solid #e5e7eb;
  background: #fff; position: relative; z-index: 1;
  transition: all var(--ease-std);
}
.step-label { font-size: 12px; text-align: center; color: #888; font-weight: 500; }
.step.done .step-dot, .step.active .step-dot {
  border-color: transparent; color: #fff;
}
.step.done::after { background: currentColor; }

/* ── Coupon Input ── */
.coupon-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.coupon-row input {
  flex: 1; min-width: 120px; padding: 12px 16px;
  border: 1.5px dashed #d1d5db; border-radius: var(--r-md);
  font-size: 14px; text-transform: uppercase; letter-spacing: 1px;
  background: #fafafa;
}
.coupon-row input:focus { background: #fff; }

/* ── Delivery Slots ── */
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot-item {
  padding: 10px 8px; border: 1.5px solid #e5e7eb;
  border-radius: var(--r-md); text-align: center;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--ease-fast);
}
.slot-item.selected, .slot-item:hover { border-color: transparent; color: #fff; }
.slot-item.disabled { opacity: 0.4; cursor: not-allowed; background: #f9f9f9; }

/* ── Search Bar ── */
.search-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  background: #fff; border-radius: var(--r-full);
  padding: 10px 20px; box-shadow: var(--shadow-md);
  border: 1.5px solid #e5e7eb;
}
.search-bar input {
  flex: 1; border: none; background: transparent;
  font-size: 15px; color: #111; min-width: 0;
}
.search-bar input::placeholder { color: #aaa; }
.search-icon { font-size: 18px; color: #aaa; flex-shrink: 0; }

/* ── Autocomplete Dropdown ── */
.autocomplete-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: #fff; border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl); z-index: var(--z-dropdown);
  overflow: hidden; max-height: 300px; overflow-y: auto;
  border: 1px solid #f0f0f0;
}
.autocomplete-item {
  padding: 12px 20px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: background var(--ease-fast);
}
.autocomplete-item:hover { background: #f9f9f9; }

/* ── Number Counter Animation ── */
.count-up { display: inline-block; }

/* ============================================================
   RESPONSIVE BREAKPOINTS (Mobile-First)
   ============================================================ */

/* ── Tablet (≤1024px) ── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
  .section-title { font-size: 26px; }
  .container { padding: 0 var(--sp-5); }
}

/* ── Mobile-Large (≤768px) ── */
@media (max-width: 768px) {
  .container { padding: 0 var(--sp-4); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .cart-drawer { width: 100%; max-width: 100%; }
  .section-title { font-size: 22px; }
  .modal-box { padding: var(--sp-5); border-radius: var(--r-xl); }
}

/* ── Mobile (≤480px) ── */
@media (max-width: 480px) {
  .container { padding: 0 var(--sp-3); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  #toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
  .section-title { font-size: 20px; }
  .slot-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Very Small (≤360px) ── */
@media (max-width: 360px) {
  html { font-size: 14px; }
  .container { padding: 0 var(--sp-3); }
}
