@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --accent-light: #f0fdf4;
  --accent-glow: rgba(34,197,94,0.22);
  --surface: #ffffff;
  --bg: #f6f7f9;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-card: 0 1px 4px rgba(0,0,0,0.05), 0 4px 20px rgba(0,0,0,0.06);
}

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Nunito', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 130px;
  -webkit-font-smoothing: antialiased;
}

/* ── SEARCH ── */
.search-container {
  background: #fff;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}

.search-bar {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  outline: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-bar:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #fff;
}

.search-bar::placeholder { color: var(--text-3); font-weight: 600; }

/* ── CATEGORIES ── */
.categories-container {
  overflow-x: auto;
  white-space: nowrap;
  padding: 12px 16px;
  background: #fff;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.categories-container::-webkit-scrollbar { display: none; }

.category-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.1px;
}

.category-btn:active { transform: scale(0.94); }

.category-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* ── GRID ── */
.container { max-width: 800px; margin: 0 auto; }

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

/* ── PRODUCT CARD ── */
.product {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.product:active { transform: scale(0.97); }

.product-img-container {
  position: relative;
  width: 100%;
  padding-top: 80%;
  background: #f3f4f6;
  overflow: hidden;
}

.product-img-container img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: opacity 0.3s, transform 0.4s;
}

.product-img-container img.loading { opacity: 0; }
.product:hover .product-img-container img { transform: scale(1.03); }

.product-weight {
  position: absolute;
  bottom: 8px; left: 8px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.product-content {
  padding: 11px 12px 13px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.35;
  flex: 1;
}

.product-category {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.product-price {
  font-size: 19px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

/* ── ADD BUTTON ── */
.button-container { min-height: 40px; display: flex; align-items: center; }

.btn-add {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 10px var(--accent-glow);
  letter-spacing: 0.1px;
}

.btn-add:active { background: var(--accent-dark); transform: scale(0.96); }

.qty-controls-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  border: 1.5px solid rgba(34,197,94,0.2);
}

.qty-controls-inline button {
  width: 33px; height: 33px;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.qty-controls-inline button:active { background: var(--accent-dark); transform: scale(0.9); }
.qty-display { flex: 1; text-align: center; font-weight: 900; color: var(--accent); font-size: 15px; }

/* ── SKELETON ── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: #e5e7eb;
  background-image: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

.product-skeleton {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.skeleton-img { width: 100%; padding-top: 80%; position: relative; }
.skeleton-img .skeleton { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 0; }
.skeleton-content { padding: 11px 12px 13px; }
.skeleton-line { height: 12px; margin-bottom: 8px; }
.skeleton-line.short { width: 55%; }
.skeleton-line.medium { width: 80%; }
.skeleton-price { height: 19px; width: 45%; margin-bottom: 10px; }
.skeleton-btn { height: 40px; width: 100%; border-radius: var(--radius-sm); }

/* ── NO RESULTS ── */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: 15px;
  font-weight: 600;
}

.no-results span { display: block; font-size: 40px; margin-bottom: 12px; }

/* ── FLOATING CART ── */
.floating-cart {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  background: linear-gradient(135deg, #15803d, #22c55e);
  color: #fff;
  padding: 15px 20px;
  border-radius: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 8px 32px var(--accent-glow), 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  cursor: pointer;
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floating-cart-left { display: flex; align-items: center; gap: 10px; }

.cart-badge {
  background: rgba(255,255,255,0.25);
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900;
  border: 1.5px solid rgba(255,255,255,0.35);
}

.floating-cart-right { font-size: 17px; font-weight: 900; }

@keyframes slideUp {
  from { transform: translate(-50%, 80px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

.hidden { display: none !important; }

/* ── MODAL ── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  width: 100%; max-width: 600px;
  border-radius: 26px 26px 0 0;
  padding: 8px 18px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: slideUpModal 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
  -webkit-overflow-scrolling: touch;
}

.modal-handle {
  width: 40px; height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin: 12px auto 20px;
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-close {
  position: absolute; top: 20px; right: 18px;
  background: var(--bg); border: none;
  width: 36px; height: 36px;
  border-radius: 50%; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); font-family: 'Nunito', sans-serif;
  font-weight: 700;
}

.modal-content h2 {
  font-size: 21px; font-weight: 900;
  margin: 0 0 18px; letter-spacing: -0.3px;
  color: var(--text);
}

.checkout-items {
  background: var(--bg);
  border-radius: 16px;
  padding: 4px 14px;
  margin-bottom: 14px;
  max-height: 35vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.checkout-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}

.checkout-item:last-child { border-bottom: none; }
.checkout-item-name { font-weight: 700; color: var(--text); flex: 1; }
.checkout-item-qty  { color: var(--text-3); font-size: 13px; font-weight: 600; margin: 0 12px; }
.checkout-item-price { font-weight: 900; color: var(--text); }

.checkout-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: var(--accent-light);
  border-radius: 16px;
  margin-bottom: 16px;
  border: 1.5px solid rgba(34,197,94,0.2);
}

.checkout-total-label  { font-size: 14px; color: var(--text-2); font-weight: 700; }
.checkout-total-amount { font-size: 22px; font-weight: 900; color: var(--accent); letter-spacing: -0.5px; }

#checkout-form { display: flex; flex-direction: column; gap: 10px; }

#checkout-form input {
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  outline: none;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  -webkit-appearance: none;
}

#checkout-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#checkout-form input::placeholder { color: var(--text-3); }

.btn-submit {
  background: linear-gradient(135deg, #15803d, #22c55e);
  color: #fff; border: none;
  padding: 17px; border-radius: 16px;
  font-size: 16px; font-weight: 900;
  font-family: 'Nunito', sans-serif;
  cursor: pointer; margin-top: 4px;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.1px; width: 100%;
  box-shadow: 0 4px 18px var(--accent-glow);
  -webkit-appearance: none;
}

.btn-submit:active { opacity: 0.88; transform: scale(0.98); }
.btn-submit:disabled { background: #d1d5db; box-shadow: none; cursor: not-allowed; }

/* ── SUCCESS ── */
.success-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 20px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.success-content {
  background: #fff; border-radius: 26px;
  padding: 44px 32px; text-align: center;
  width: 100%; max-width: 320px;
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-icon {
  width: 76px; height: 76px;
  background: linear-gradient(135deg, #15803d, #22c55e);
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; margin: 0 auto 22px;
  box-shadow: 0 8px 28px var(--accent-glow);
}

.success-content h2 { font-size: 23px; font-weight: 900; color: var(--text); margin: 0 0 8px; letter-spacing: -0.3px; }
.success-content p  { font-size: 14px; color: var(--text-2); font-weight: 600; margin: 0 0 30px; }

.btn-done {
  background: var(--accent); color: #fff; border: none;
  padding: 15px 44px; border-radius: 14px;
  font-size: 15px; font-weight: 800;
  font-family: 'Nunito', sans-serif; cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-done:active { background: var(--accent-dark); }

@media (max-width: 360px) {
  .grid { gap: 8px; padding: 10px 10px 0; }
}
