/* ==========================================================================
   Komponen
   ========================================================================== */

/* Tombol ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background: var(--primary-strong);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover {
  background: var(--primary-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--body);
  border-color: var(--hairline);
}

.btn-ghost:hover {
  background: var(--surface-warm);
  color: var(--ink);
}

.btn-wa {
  min-height: 52px;
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
}

.btn-wa:hover {
  background: var(--primary-strong);
  color: #fff;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  padding: 8px 4px;
  min-height: 44px;
  font-size: var(--fs-caption);
}

.btn-danger:hover {
  text-decoration: underline;
}

.btn[disabled],
.btn-disabled {
  background: var(--surface-warm);
  color: var(--muted);
  border-color: transparent;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: var(--fs-caption);
}

/* Chip kategori ----------------------------------------------------------- */

.chip-rail {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-bottom: 2px;
}

.chip-rail::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--body);
  font-size: var(--fs-label);
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: start;
}

.chip:hover {
  border-color: var(--muted);
  text-decoration: none;
}

.chip[aria-pressed='true'],
.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Kartu produk ------------------------------------------------------------ */

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

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

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

.product-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}

.product-card:hover {
  border-color: var(--muted);
}

.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-sm);
  background: var(--surface-warm);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  padding: var(--s-2);
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-name {
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.product-name a {
  color: var(--ink);
}

.product-card .stock-chip {
  align-self: flex-start;
}

.product-card .btn {
  margin-top: auto;
  width: 100%;
}

/* Harga ------------------------------------------------------------------- */

.price {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.price .unit {
  font-size: var(--fs-caption);
  font-weight: 400;
  color: var(--muted);
}

.price-old {
  display: inline-block;
  margin-right: var(--s-2);
  font-size: var(--fs-caption);
  font-weight: 400;
  color: var(--danger);
  text-decoration: line-through;
}

.price-lg {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.price-lg .unit {
  font-size: var(--fs-caption);
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}

/* Chip stok --------------------------------------------------------------- */

.stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-caption);
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.stock-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.stock-tersedia {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.stock-terbatas {
  background: var(--accent-soft);
  color: var(--warning);
}

.stock-habis {
  background: var(--surface-warm);
  color: var(--muted);
}

.stock-preorder {
  background: var(--surface);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.stock-habis::before,
.stock-preorder::before {
  display: none;
}

/* Keranjang: stepper ------------------------------------------------------ */

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}

.qty button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}

.qty button:hover:not([disabled]) {
  background: var(--surface-warm);
}

.qty button[disabled] {
  color: var(--muted);
  cursor: not-allowed;
}

.qty input,
.qty output {
  width: 40px;
  height: 44px;
  border: 0;
  border-left: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
  text-align: center;
  font-size: var(--fs-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--ink);
}

.qty input:focus {
  outline-offset: -2px;
}

/* Form -------------------------------------------------------------------- */

.field {
  margin-top: var(--s-4);
}

.field:first-child {
  margin-top: 0;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--fs-label);
  font-weight: 600;
}

.field .hint {
  margin-top: 6px;
  font-size: var(--fs-caption);
  color: var(--muted);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: var(--primary);
}

.input[aria-invalid='true'],
.select[aria-invalid='true'] {
  border-color: var(--danger);
}

.error-text {
  display: block;
  margin-top: 6px;
  font-size: var(--fs-caption);
  color: var(--danger);
}

.input-error {
  padding: 12px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--r-sm);
  background: #fef2f2;
  color: var(--danger);
  font-size: var(--fs-caption);
}

/* Pilihan berbentuk kartu (radio) ---------------------------------------- */

.check-line {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  margin-top: var(--s-3);
  font-size: var(--fs-label);
  font-weight: 600;
  cursor: pointer;
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.choice-list {
  display: grid;
  gap: var(--s-2);
}

.choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
}

.choice:hover {
  border-color: var(--muted);
}

.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice-mark {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.choice-mark::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
}

.choice input:checked ~ .choice-mark {
  border-color: var(--primary);
}

.choice input:checked ~ .choice-mark::after {
  background: var(--primary);
}

.choice input:checked ~ .choice-body .choice-title {
  color: var(--primary-strong);
}

.choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice input:focus-visible ~ .choice-mark {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.choice-body {
  flex: 1;
  min-width: 0;
}

.choice-title {
  display: block;
  font-size: var(--fs-label);
  font-weight: 600;
}

.choice-desc {
  display: block;
  font-size: var(--fs-caption);
  color: var(--body);
  margin-top: 2px;
}

/* Bilah lengket ----------------------------------------------------------- */

.order-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--hairline);
  box-shadow: var(--shadow-2);
}

.order-bar .meta {
  flex: 1;
  min-width: 0;
}

.order-bar .count {
  font-size: var(--fs-caption);
  color: var(--body);
}

.order-bar .total {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.order-bar .btn {
  flex: 0 0 auto;
}

@media (min-width: 1024px) {
  .order-bar {
    display: none;
  }
}

/* Banner status ----------------------------------------------------------- */

.shop-banner {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 12px var(--gutter);
  font-size: var(--fs-label);
  font-weight: 600;
}

.shop-banner-tutup {
  background: var(--accent-soft);
  color: var(--warning);
}

.shop-banner-buka {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

/* Kartu umum -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--s-4);
}

.card-tight {
  padding: var(--s-3);
}

/* Progress minimum belanja ------------------------------------------------ */

.progress {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-warm);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width 0.15s ease;
}

/* Notifikasi ringkas ------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-label);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Kondisi kosong ---------------------------------------------------------- */

.empty {
  display: grid;
  justify-items: center;
  gap: var(--s-3);
  padding: var(--s-7) var(--s-4);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--hairline);
  border-radius: var(--r-md);
}

.empty h2 {
  font-size: var(--fs-h2);
}

.empty p {
  color: var(--body);
  max-width: 42ch;
}

/* Tabel ------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.table th {
  padding: 10px 12px;
  background: var(--surface-warm);
  color: var(--body);
  font-size: var(--fs-caption);
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-top: 1px solid var(--hairline);
  font-size: var(--fs-label);
  height: 44px;
}

.table td.nums {
  font-variant-numeric: tabular-nums;
}

/* Akordeon (FAQ) ---------------------------------------------------------- */

.accordion {
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.accordion + .accordion {
  margin-top: var(--s-2);
}

.accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 52px;
  padding: 12px var(--s-4);
  font-size: var(--fs-label);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary::after {
  content: '+';
  font-size: 18px;
  font-weight: 400;
  color: var(--muted);
}

.accordion[open] summary::after {
  content: '-';
}

.accordion .accordion-body {
  padding: 0 var(--s-4) var(--s-4);
  font-size: var(--fs-label);
  color: var(--body);
}

/* Remah roti -------------------------------------------------------------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: var(--fs-caption);
  color: var(--muted);
  margin-bottom: var(--s-4);
}

.breadcrumb a {
  color: var(--body);
}

.breadcrumb span[aria-current] {
  color: var(--ink);
}

/* Label kecil ------------------------------------------------------------- */

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--body);
}

.divider {
  height: 1px;
  background: var(--hairline);
  border: 0;
  margin: var(--s-4) 0;
}

/* Kerangka muat ----------------------------------------------------------- */

.skeleton {
  background: var(--surface-warm);
  border-radius: var(--r-sm);
  min-height: 14px;
}
