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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-mid: #dbeafe;
  --accent: #06b6d4;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --card-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
}

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 110px;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ── */
.app-header {
  background: var(--primary);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -1px;
  backdrop-filter: blur(4px);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-title {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
}

.logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

/* ── SEARCH ── */
.search-container {
  background: var(--primary);
  padding: 0 16px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-bar {
  width: 100%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.25);
  padding: 10px 16px 10px 40px;
  border-radius: 12px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: border-color 0.18s;
}

.search-bar::placeholder { color: rgba(255,255,255,0.55); }
.search-bar:focus { border-color: rgba(255,255,255,0.6); background-color: rgba(255,255,255,0.2); }

/* ── CATEGORIES ── */
.categories-container {
  overflow-x: auto;
  white-space: nowrap;
  padding: 12px 16px;
  background: var(--surface);
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(15,23,42,0.05);
}

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

.category-btn {
  display: inline-block;
  padding: 7px 14px;
  margin-right: 8px;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.18s ease;
}

.category-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

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

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

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

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

.product-img-container {
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: var(--primary-light);
  overflow: hidden;
}

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

.product-img-container img.loading {
  opacity: 0;
}

.product-weight {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

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

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

.product-price {
  font-size: 17px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
  letter-spacing: -0.3px;
}

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

.btn-add {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.qty-controls-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--primary-light);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.qty-controls-inline button {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  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(--primary-dark);
  transform: scale(0.93);
}

.qty-display {
  flex: 1;
  text-align: center;
  font-weight: 800;
  color: var(--primary);
  font-size: 15px;
}

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

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

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

.skeleton-img {
  width: 100%;
  padding-top: 100%;
  position: relative;
}

.skeleton-img .skeleton {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.skeleton-content {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 13px;
}

.skeleton-line.medium { width: 80%; }
.skeleton-line.short  { width: 45%; }

.skeleton-price {
  height: 18px;
  width: 55%;
  border-radius: 6px;
}

.skeleton-btn {
  height: 38px;
  border-radius: 10px;
  margin-top: 4px;
}

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

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

/* ── FLOATING CART ── */
.floating-cart {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  background: var(--primary);
  color: #fff;
  padding: 15px 20px;
  border-radius: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.35);
  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: #fff;
  color: var(--primary);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
}

.floating-cart-right {
  font-size: 16px;
  font-weight: 800;
  color: rgba(255,255,255,0.9);
}

@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(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 600px;
  border-radius: 24px 24px 0 0;
  padding: 8px 16px env(safe-area-inset-bottom, 20px);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  max-height: 88vh;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  animation: slideUpModal 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 18px;
}

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

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

.modal-content h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -0.3px;
  color: var(--text);
}

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

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

.checkout-item:last-child { border-bottom: none; }

.checkout-item-name { font-weight: 500; color: #333; flex: 1; }
.checkout-item-qty { color: #aaa; font-size: 13px; margin: 0 12px; }
.checkout-item-price { font-weight: 700; color: var(--text); }

.checkout-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--primary-light);
  border-radius: 14px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.checkout-total-label { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.checkout-total-amount { font-size: 20px; font-weight: 900; color: var(--primary); letter-spacing: -0.5px; }

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

#checkout-form input {
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.18s;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
}

#checkout-form input:focus { border-color: var(--primary); }

.btn-submit {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: -0.2px;
  width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
}

.btn-submit:active { background: var(--primary-dark); transform: scale(0.98); }
.btn-submit:disabled { background: #94a3b8; cursor: not-allowed; transform: none; }

/* ── SUCCESS ── */
.success-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(6px);
  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: var(--surface);
  border-radius: 24px;
  padding: 40px 30px;
  text-align: center;
  width: 100%;
  max-width: 340px;
  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: 72px;
  height: 72px;
  background: var(--primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
}

.success-content h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.3px;
}

.success-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
}

.btn-done {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 40px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}

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

/* ── RESPONSIVE ── */
@media (max-width: 360px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px 10px 0;
  }
}
