:root {
  --primary: #ee4d2d;
  --primary-dark: #d73211;
  --bg: #f5f5f5;
  --card: #ffffff;
  --text: #222;
  --muted: #777;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: #fff5ee url("./pattern.svg") repeat;
  background-size: 200px 200px;
  color: var(--text);
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Header */
.header {
  background: var(--primary);
  color: #fff;
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header__inner { display: flex; align-items: center; gap: 16px; }
.logo { font-weight: 700; font-size: 22px; text-decoration: none; color: #fff; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.logo__img { width: 40px; height: 40px; background: #fff; border-radius: 10px; padding: 3px; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.search { flex: 1; display: flex; min-width: 0; }
.search input {
  flex: 1; padding: 8px 12px; border: none; border-radius: 6px 0 0 6px; font-size: 14px; outline: none; min-width: 0;
}
.search button {
  border: none; background: #fff; color: var(--primary);
  border-radius: 0 6px 6px 0; cursor: pointer; font-size: 16px; padding: 8px 12px;
}
.cart-btn {
  background: rgba(255, 255, 255, 0.15); color: #fff; border: none;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 18px; position: relative;
}
.cart-btn:hover { background: rgba(255, 255, 255, 0.25); }
.cart-btn__count {
  position: absolute; top: -6px; right: -6px; background: #fff; color: var(--primary);
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 6px;
}

/* Hero */
.hero { background: linear-gradient(135deg, #ee4d2d, #f97f62); color: #fff; padding: 28px 0; margin-bottom: 16px; box-shadow: inset 0 -4px 12px rgba(0,0,0,0.06); }
.hero__inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero__logo { width: 96px; height: 96px; background: #fff; border-radius: 20px; padding: 10px; box-shadow: 0 3px 10px rgba(0,0,0,0.18); flex-shrink: 0; }
.hero h1 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0; opacity: 0.95; }

/* Layout */
.main { display: grid; grid-template-columns: 200px 1fr; gap: 20px; padding-bottom: 40px; align-items: start; }
.sidebar { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid #ffe3d6; }
.sidebar h2 { font-size: 15px; margin: 0 0 10px; }
.categories { display: flex; flex-direction: column; gap: 4px; }
.category {
  text-align: left; border: none; background: transparent; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text);
}
.category:hover { background: #fff0ee; }
.category.is-active { background: var(--primary); color: #fff; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; }
.sort { font-size: 13px; color: var(--muted); }
.sort select { padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; background: #fff; }

/* Grid produk */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid #ffe3d6;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); }
.card__media {
  height: 150px; display: flex; align-items: center; justify-content: center;
  font-size: 56px; background: #fff3ea; border-bottom: 1px solid #ffe3d6;
}
.card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card__name { font-size: 14px; line-height: 1.3; min-height: 36px; }
.card__name, .card__desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card__desc { font-size: 12px; color: var(--muted); margin: 0; }
.card__price { font-weight: 700; color: var(--primary); }
.card__price s { color: var(--muted); font-weight: 400; font-size: 12px; margin-right: 6px; }
.card__badge {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; width: fit-content;
  background: #fff8e1; color: #b8860b; border: 1px solid #ffe08a;
}
.card__rating { font-size: 12px; color: #f5a623; }
.card__add { margin-top: auto; }

.btn {
  border: none; border-radius: 6px; padding: 9px 14px; font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid #ddd; }
.btn-full { width: 100%; }

.empty { color: var(--muted); text-align: center; padding: 32px 0; grid-column: 1 / -1; }

/* Drawer keranjang */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(380px, 92vw);
  background: #fff; z-index: 50; display: flex; flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}
.drawer__header, .drawer__footer { padding: 14px 16px; border-bottom: 1px solid #eee; }
.drawer__header { display: flex; justify-content: space-between; align-items: center; border-top: none; }
.drawer__header h2 { margin: 0; font-size: 16px; }
.icon-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; }
.drawer__items { flex: 1; overflow-y: auto; padding: 8px 16px; }
.drawer__footer { border-bottom: none; border-top: 1px solid #eee; }
.total { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 15px; }
.total strong { color: var(--primary); }

.cart-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.cart-item__emoji { font-size: 32px; background: #f0f0f0; border-radius: 8px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.cart-item__name { font-size: 13px; flex: 1; }
.cart-item__price { font-size: 13px; color: var(--primary); font-weight: 600; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.qty-btn { border: 1px solid #ddd; background: #fff; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-weight: 700; }
.remove-btn { border: none; background: transparent; color: #e53935; font-size: 12px; cursor: pointer; padding: 0; margin-left: auto; }

/* Dialog checkout */
.dialog {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dialog__card {
  background: #fff; border-radius: var(--radius); padding: 20px; width: min(440px, 100%);
  max-height: 90dvh; overflow-y: auto;
}
.dialog__card h2 { margin: 0 0 12px; font-size: 18px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.summary-total { border-top: 1px solid #eee; margin-top: 6px; padding-top: 8px; font-weight: 700; }
.checkout-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.checkout-form label { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.checkout-form input, .checkout-form textarea {
  padding: 9px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit;
}
.checkout-form button[type="submit"] { margin-top: 6px; }
.form-note { font-size: 12px; color: var(--muted); margin: 0; }
.success-box { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 12px 4px 4px; }
.success-lead { margin: 0; font-size: 14px; line-height: 1.5; }
.success-box .btn-primary { text-decoration: none; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 70; animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Footer */
.footer { background: #fff; border-top: 1px solid #eee; padding: 18px 0; color: var(--muted); font-size: 13px; }

/* Bilah keranjang tetap di bawah layar — aktif hanya di ponsel */
.mobile-cart-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  align-items: center; justify-content: space-between; gap: 12px;
  background: #fff; border-top: 1px solid #ffe3d6;
  padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -3px 14px rgba(0, 0, 0, 0.14);
}
.mobile-cart-bar__info { display: flex; align-items: center; gap: 10px; }
.mobile-cart-bar__count {
  background: var(--primary); color: #fff; font-weight: 700;
  border-radius: 999px; padding: 3px 12px; font-size: 13px;
}
.mobile-cart-bar__total { font-weight: 700; color: var(--primary); font-size: 15px; }
.mobile-cart-bar .btn { padding: 11px 16px; }

body { overflow-x: clip; }

@media (max-width: 720px) {
  .main { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .sidebar .categories { flex-direction: row; flex-wrap: wrap; }
  .hero { padding: 20px 0; }
  .hero h1 { font-size: 20px; }
  .hero__inner { flex-direction: column; text-align: center; }
  .hero__logo { width: 76px; height: 76px; }

  /* Header agar pas di layar ponsel */
  .header__inner { gap: 8px; }
  .logo { font-size: 17px; gap: 6px; }
  .logo__img { width: 30px; height: 30px; border-radius: 8px; }
  .search input { font-size: 16px; padding: 8px 10px; } /* 16px = iOS tidak zoom-in otomatis */
  .search button { padding: 8px 10px; }
  .cart-btn { padding: 8px 10px; font-size: 16px; }

  /* Grid produk nyaman dijentik: 2 kartu per baris */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card__media { height: 120px; font-size: 44px; }
  .card__body { padding: 8px 10px 10px; }
  .btn { padding: 10px 12px; font-size: 14px; }
  .toolbar h2 { font-size: 16px; }

  /* Tampilkan bilah keranjang di bawah + beri ruang agar footer tidak tertutup */
  .mobile-cart-bar { display: flex; }
  body.has-cart-bar { padding-bottom: 74px; }
}
