:root {
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --sale: #dc2626;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.loader {
  width: 40px;
  height: 40px;
  margin: 30vh auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-card, .success-card {
  max-width: 420px;
  margin: 20vh auto;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.success-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #16a34a;
  color: #fff;
  font-size: 1.75rem;
  line-height: 56px;
}

/* Header */
.shop-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.shop-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.shop-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1 1 180px;
  min-width: 0;
}

.shop-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.shop-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.shop-search-wrap { flex: 2 1 220px; }

.shop-search {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.95rem;
  background: var(--bg);
  outline: none;
}

.shop-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Hero */
.shop-hero {
  position: relative;
  max-height: 220px;
  overflow: hidden;
}

.shop-hero-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.shop-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.55), transparent);
}

.shop-hero-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  color: #fff;
  font-size: 0.95rem;
}

.promo-banner {
  max-width: 1100px;
  margin: 0.75rem auto;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  text-align: center;
}

/* Info */
.shop-info {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.shop-info-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.shop-info-item {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.shop-info-icon { font-size: 1.25rem; }

.shop-info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.shop-link-btn {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.shop-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.shop-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  background: #25d366;
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.shop-social { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.shop-social a {
  padding: 0.45rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
}

/* Gallery */
.shop-gallery {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 1rem;
}

.shop-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.shop-gallery-grid button {
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
}

.shop-gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Products */
.shop-products {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
}

.shop-products-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.shop-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.shop-product-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.cat-pills-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
  -webkit-overflow-scrolling: touch;
}

.cat-pills {
  display: flex;
  gap: 0.4rem;
  padding-bottom: 0.25rem;
}

.cat-pills button {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pills button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}

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

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 4.5rem;
  text-align: center;
  transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.product-card.out-of-stock { opacity: 0.72; }

.product-img-wrap {
  position: relative;
  aspect-ratio: unset;
  height: auto;
  min-height: 0;
  background: transparent;
  padding: 0.55rem 0.75rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.product-img-wrap img,
.product-img-placeholder {
  display: none !important;
}

.product-badge {
  position: static;
  display: inline-block;
  margin: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.product-badge.sale { background: var(--sale); color: #fff; }
.product-badge.sold { background: #475569; color: #fff; }

.product-body {
  padding: 0.85rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.product-name {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.28;
}

.product-desc {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-sku {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.product-prices {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.product-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f766e;
}

.product-compare {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: line-through;
}

.product-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.6rem;
  width: 100%;
  justify-content: center;
}

.product-actions .photo-btn {
  display: none !important;
}

.product-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.product-btn-primary {
  background: var(--accent);
  color: #fff;
}

.product-btn-ghost {
  background: var(--accent-soft);
  color: var(--accent);
}

.product-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.shop-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.shop-order-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  z-index: 40;
}

.shop-order-btn {
  display: block;
  max-width: 420px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  background: var(--accent);
  color: #fff;
  text-align: center;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
}

/* Lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.photo-lightbox img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
}

.photo-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

#photo-lightbox-caption {
  color: #fff;
  margin-top: 0.75rem;
  text-align: center;
}

/* PWA banner */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: 1rem;
  background: var(--text);
  color: #fff;
}

body.pwa-banner-visible .shop-order-bar { bottom: 88px; }

.pwa-banner-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.pwa-banner-btn {
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Order page */
.order-page { background: var(--bg); }

.order-header {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

.order-back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.order-header h1 {
  margin: 0.5rem 0 0;
  font-size: 1.35rem;
}

.order-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.order-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.order-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem;
}

.order-panel-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.order-type-toggle {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.order-type-btn {
  flex: 1;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
}

.order-type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.order-field {
  display: block;
  margin-bottom: 0.65rem;
}

.order-field span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.order-field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.order-maps-btn {
  margin-top: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.85rem;
}

.order-form-error {
  color: var(--sale);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.order-submit-btn {
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.order-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.order-cart-count {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.order-cart-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.order-cart-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.order-cart-line-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.order-cart-total-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  font-size: 1.05rem;
}

.order-cat-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  overflow-x: scroll;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: thin;
  padding: 0.25rem 0;
}

.order-cat-nav button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: #2d2d44;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}

.order-cat-nav button.active {
  background: #ff6b35;
  border-color: transparent;
  color: #fff;
}

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

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

.order-menu-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  font: inherit;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.order-menu-item-photo {
  display: block;
  width: 100%;
  aspect-ratio: 1.1 / 1;
  background: #fff;
  overflow: hidden;
}

.order-menu-item-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #fff;
}

.order-menu-item-name {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.25;
  padding: 0.4rem 0.35rem 0.1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.order-menu-item-price {
  font-weight: 800;
  color: var(--accent);
  font-size: 0.84rem;
  padding: 0 0.35rem;
}
.order-menu-item-add {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.15rem 0.35rem 0.45rem;
}

.order-menu-empty, .order-cart-empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.order-page .product-card.out-of-stock .order-menu-item { pointer-events: none; }
