:root {
  --ink: #24302c;
  --teal: #1fafa5;
  --teal-dark: #2f918c;
  --yellow: #ffcd3d;
  --yellow-dark: #e0a100;
  --cream: #fffcf5;
  --card: #ffffff;
  --line: #ece5d2;
  --muted: #8a8478;
  --danger: #d1503a;
  --ok: #3d9463;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
}

a { color: inherit; }
.mono, .price, .barcode, .fx-note { font-family: 'IBM Plex Mono', monospace; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--teal-dark);
  color: #fff;
  padding: 14px 24px 0;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
}

.brand-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand-story-link {
  background: var(--yellow);
  color: var(--teal-dark);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  flex: none;
}
.brand-story-link:hover { opacity: 0.88; }
.brand-mark {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand-mark .lemon { color: var(--yellow); }
.brand-mark .young { color: #fff; }
.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.04em;
  display: block;
  margin-top: -2px;
}

.nav-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: rgba(255,255,255,0.55); pointer-events: none; }
#searchInput {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 999px;
  padding: 9px 16px 9px 34px;
  font-size: 13.5px;
  width: 240px;
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
#searchInput::placeholder { color: rgba(255,255,255,0.5); }
#searchInput:focus { background: rgba(255,255,255,0.18); border-color: var(--yellow); }

#categorySelect {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
}
#categorySelect:focus { border-color: var(--yellow); }
#categorySelect option { color: var(--ink); }

.nav-links { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.nav-link { color: rgba(255,255,255,0.85); text-decoration: none; white-space: nowrap; }
.nav-link:hover { color: #fff; }
.nav-link-primary {
  background: var(--yellow);
  color: var(--teal-dark) !important;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
}
.nav-link-btn {
  background: none; border: 1px solid rgba(255,255,255,0.3); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.nav-user { color: rgba(255,255,255,0.7); font-size: 13px; }

.cart-link { position: relative; display: inline-flex; align-items: center; color: #fff; text-decoration: none; }
.cart-link svg { width: 22px; height: 22px; }
.cart-badge {
  position: absolute; top: -8px; right: -10px;
  background: var(--yellow); color: var(--teal-dark);
  font-size: 10.5px; font-weight: 700;
  border-radius: 999px; min-width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.chip-row {
  max-width: 1280px; margin: 0 auto; display: flex; gap: 8px;
  overflow-x: auto; padding: 2px 0 14px; scrollbar-width: thin;
}
.chip-row::-webkit-scrollbar { height: 5px; }
.chip-row::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
.chip {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px; font-size: 12.5px;
  color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2); cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chip:hover { background: rgba(255,255,255,0.18); }
.chip.active { background: var(--yellow); border-color: var(--yellow); color: var(--teal-dark); font-weight: 600; }

/* ---------- Main / Result bar ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 18px 24px 40px; }
.result-bar { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px 16px; color: var(--muted); font-size: 13px; }
#resultCount { font-weight: 600; color: var(--teal); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(7,110,121,0.12); border-color: var(--yellow); }

.card-img { aspect-ratio: 1/1; background: #fbf9f4; display: flex; align-items: center; justify-content: center; padding: 18px; cursor: pointer; position: relative; }
.card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-img .noimg { color: var(--muted); font-size: 12px; }

.prod-badges { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
.prod-badge { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.02em; }
.prod-badge-new { background: var(--yellow); color: var(--teal-dark); }
.prod-badge-oos { background: rgba(35,38,31,0.75); color: #fff; }

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-no { font-size: 11px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.card-name-vi { font-size: 14.5px; font-weight: 600; line-height: 1.3; color: var(--ink); cursor: pointer; }
.card-name-en { font-size: 12px; font-style: italic; color: var(--muted); line-height: 1.25; }
.card-cat { display: inline-block; align-self: flex-start; margin-top: 2px; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; background: rgba(7,110,121,0.1); color: var(--teal); font-weight: 600; letter-spacing: 0.03em; }

.card-price-block { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; align-items: baseline; justify-content: space-between; }
.card-price-final { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; color: var(--teal-dark); }
.card-price-krw { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); }

.card-cart-row { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.qty-stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.qty-stepper button { background: var(--cream); border: none; width: 26px; height: 26px; cursor: pointer; font-size: 14px; color: var(--teal-dark); }
.qty-stepper input { width: 34px; border: none; text-align: center; font-size: 13px; font-family: 'IBM Plex Mono', monospace; -moz-appearance: textfield; }
.qty-stepper input::-webkit-outer-spin-button, .qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.btn {
  border: none; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s; text-align: center; text-decoration: none; display: inline-block;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-yellow { background: var(--yellow); color: var(--teal-dark); }
.btn-outline { background: none; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: none; color: var(--danger); border: 1px solid rgba(181,72,44,0.3); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state button { margin-top: 12px; }

.site-footer { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(35,38,31,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 18px; max-width: 520px; width: 100%; max-height: 88vh; overflow-y: auto; position: relative; padding: 28px; }
.modal-close { position: absolute; top: 14px; right: 14px; background: var(--cream); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; cursor: pointer; color: var(--ink); line-height: 1; }
.modal-img { width: 100%; aspect-ratio: 1/1; background: #fbf9f4; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; overflow: hidden; position: relative; }
.modal-img img { max-width: 70%; max-height: 70%; object-fit: contain; }
.modal-name-vi { font-size: 20px; font-weight: 600; font-family: 'Fraunces', serif; }
.modal-name-en { font-size: 13.5px; font-style: italic; color: var(--muted); margin-top: 4px; }
.modal-cat { margin-top: 10px; }

.spec-table { margin-top: 18px; width: 100%; border-collapse: collapse; font-size: 13.5px; }
.spec-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.spec-table td:first-child { color: var(--muted); width: 42%; }
.spec-table td:last-child { font-family: 'IBM Plex Mono', monospace; text-align: right; }
.spec-table .final-row td { font-weight: 700; color: var(--teal-dark); font-size: 15px; }

.promo-video-modal { max-width: 720px; padding: 12px; }
.promo-video-frame { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.promo-video-modal .modal-close {
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  box-shadow: none;
  z-index: 5;
}
.promo-video-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- Auth pages ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; padding: 0 20px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; }
.auth-title { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 600; margin: 0 0 6px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--teal); }
.form-error { background: #fbeae5; color: var(--danger); font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; display: none; }
.form-error.show { display: block; }
.form-note { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.form-note a { color: var(--teal); font-weight: 600; text-decoration: none; }

/* ---------- Cart / Orders ---------- */
.page-title { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; margin: 8px 0 20px; }

.cart-table { width: 100%; border-collapse: collapse; }
.cart-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
.cart-table td { padding: 14px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cart-row-thumb { display: flex; align-items: center; gap: 12px; }
.cart-row-thumb img { width: 52px; height: 52px; object-fit: contain; background: #fbf9f4; border-radius: 8px; padding: 4px; }
.cart-row-name { font-size: 13.5px; font-weight: 600; }
.cart-row-en { font-size: 11.5px; color: var(--muted); font-style: italic; }
.cart-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 12px; }

.cart-summary { margin-top: 20px; display: flex; justify-content: flex-end; }
.cart-summary-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; min-width: 280px; }
.cart-summary-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.cart-summary-total { font-weight: 700; font-size: 17px; color: var(--teal-dark); font-family: 'IBM Plex Mono', monospace; }
.cart-summary-box .btn { margin-top: 14px; }

.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn.active { color: var(--teal-dark); border-bottom-color: var(--yellow); }

.order-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 14px; }
.order-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }
.order-id { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--muted); }
.order-date { font-size: 12px; color: var(--muted); }
.status-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; letter-spacing: 0.02em; }
.status-pending { background: #fdf1d9; color: var(--yellow-dark); }
.status-confirmed { background: #e2f2e7; color: var(--ok); }
.status-active { background: #e2f2e7; color: var(--ok); }
.status-disabled { background: #fbeae5; color: var(--danger); }
.order-items { font-size: 13px; color: var(--ink); margin: 8px 0; }
.order-items div { padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
.order-total { text-align: right; font-weight: 700; font-family: 'IBM Plex Mono', monospace; color: var(--teal-dark); margin-top: 8px; }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-filter-row { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; }
.access-denied { text-align: center; padding: 80px 20px; color: var(--muted); }

.story-stack { display: flex; flex-direction: column; }
.story-stack img { width: 100%; height: auto; display: block; }

/* ---------- Hamburger (mobile nav toggle) ---------- */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.hamburger svg { width: 22px; height: 22px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 760px) {
  .hamburger { display: flex; }

  .brand-sub { display: none; }
  .brand-mark { font-size: 18px; }
  .brand-story-link { font-size: 11.5px; padding: 5px 10px; }

  .nav-right {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding-top: 14px;
    padding-bottom: 16px;
    order: 3;
  }
  .nav-right.open { display: flex; }

  .controls { flex-direction: column; align-items: stretch; gap: 10px; }
  #searchInput { width: 100%; }
  #categorySelect { width: 100%; }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 10px;
  }
  #accountArea { display: block; width: 100%; }
  .nav-links .nav-link,
  .nav-links .nav-link-btn,
  .nav-links .cart-link,
  .nav-links .nav-user {
    display: block;
    width: 100%;
    padding: 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    text-align: left;
  }
  .nav-links .nav-link-primary { display: block; text-align: center; margin-top: 8px; border-bottom: none; }
  .cart-link { display: flex; align-items: center; gap: 10px; position: relative; }
  .cart-link::after { content: 'Giỏ hàng'; }
  .cart-badge { position: static; margin-left: auto; flex: none; width: auto; min-width: 20px; }
  .nav-links .nav-link-btn { border: none; border-radius: 0; background: none; text-align: left; }

  .modal { padding: 20px; }
  .admin-filter-row { flex-wrap: wrap; }

  /* 2-column product grid on phones instead of a single column */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card-body { padding: 9px 10px 10px; }
  .card-name-vi { font-size: 13px; }
  .card-cart-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .qty-stepper { justify-content: center; }

  /* Cart table -> stacked cards */
  .cart-table thead { display: none; }
  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td { display: block; width: 100%; }
  .cart-table tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
  }
  .cart-table td { border: none; padding: 6px 0; }
  .cart-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .cart-row-thumb { align-items: center; }

  /* Promo video popup: keep background dimly visible around the edges,
     just size it comfortably for mobile screens */
  .promo-video-modal {
    max-width: calc(100% - 24px);
    padding: 14px;
  }
  .promo-video-frame { max-height: 50vh; }
  .promo-video-actions { flex-wrap: wrap; }
}

