/* =========================================================
   NovaStore — Digital Products Marketplace
   Theme: midnight + violet, glassmorphism, modern
   ========================================================= */

:root {
  --bg: #0b0f1a;
  --bg-2: #0f1424;
  --surface: rgba(20, 26, 45, 0.72);
  --surface-solid: #141a2d;
  --surface-hover: rgba(30, 38, 64, 0.85);
  --border: rgba(139, 92, 246, 0.16);
  --border-strong: rgba(139, 92, 246, 0.34);

  --text: #e8ecf5;
  --text-2: #aab2c8;
  --muted: #6b7390;

  --accent: #a78bfa;          /* violet */
  --accent-2: #7c3aed;
  --accent-3: #22d3ee;        /* cyan */
  --accent-grad: linear-gradient(135deg, #a78bfa 0%, #7c3aed 50%, #22d3ee 100%);

  --success: #34d399;
  --warning: #fbbf24;
  --danger:  #f87171;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --shadow-sm: 0 4px 16px rgba(0,0,0,0.25);
  --shadow:    0 12px 36px rgba(0,0,0,0.40);
  --shadow-glow: 0 0 32px rgba(167, 139, 250, 0.18);

  --transition: 0.22s cubic-bezier(.4,0,.2,1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

[data-theme="light"] {
  --bg: #f5f4fb;
  --bg-2: #ecebf6;
  --surface: rgba(255,255,255,0.78);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255,255,255,0.95);
  --border: rgba(124, 58, 237, 0.16);
  --border-strong: rgba(124, 58, 237, 0.34);
  --text: #1a1f33;
  --text-2: #4b5172;
  --muted: #6b7390;
  --accent: #7c3aed;
  --accent-2: #6d28d9;
  --shadow-sm: 0 4px 16px rgba(30, 30, 60, 0.08);
  --shadow: 0 12px 36px rgba(30, 30, 60, 0.12);
  --shadow-glow: 0 0 32px rgba(124, 58, 237, 0.10);
}

/* ============================================================
   Festival theme presets — applied via data-style="..." on <html>.
   These override the accent palette + the --accent-grad used by
   buttons and brand text. Pair with the .seasonal-decor overlay
   for falling emoji animations. The admin can pick a preset or a
   custom accent color from Admin → Settings → Site theme.
   ============================================================ */
[data-style="halloween"] {
  --accent:   #ff8a3d;
  --accent-2: #c2410c;
  --accent-3: #facc15;
  --accent-grad: linear-gradient(135deg, #facc15 0%, #ff8a3d 50%, #6b21a8 100%);
  --shadow-glow: 0 0 32px rgba(255, 138, 61, 0.28);
}
[data-theme="light"][data-style="halloween"] {
  --accent:   #c2410c;
  --accent-2: #9a3412;
}

[data-style="christmas"] {
  --accent:   #ef4444;
  --accent-2: #166534;
  --accent-3: #fde68a;
  --accent-grad: linear-gradient(135deg, #166534 0%, #ef4444 50%, #fde68a 100%);
  --shadow-glow: 0 0 32px rgba(239, 68, 68, 0.28);
}
[data-theme="light"][data-style="christmas"] {
  --accent:   #b91c1c;
  --accent-2: #14532d;
}

[data-style="songkran"] {
  --accent:   #22d3ee;
  --accent-2: #0e7490;
  --accent-3: #fde68a;
  --accent-grad: linear-gradient(135deg, #38bdf8 0%, #22d3ee 50%, #2dd4bf 100%);
  --shadow-glow: 0 0 32px rgba(34, 211, 238, 0.28);
}
[data-theme="light"][data-style="songkran"] {
  --accent:   #0e7490;
  --accent-2: #155e75;
}

[data-style="newyear"] {
  --accent:   #fbbf24;
  --accent-2: #d97706;
  --accent-3: #f472b6;
  --accent-grad: linear-gradient(135deg, #f472b6 0%, #fbbf24 50%, #f59e0b 100%);
  --shadow-glow: 0 0 32px rgba(251, 191, 36, 0.32);
}
[data-theme="light"][data-style="newyear"] {
  --accent:   #b45309;
  --accent-2: #92400e;
}

/* ---- Seasonal floating-emoji decor (full-page overlay) ----
   A fixed, pointer-events: none container above the background but
   below all clickable UI. Spans inside it animate downward / upward
   to create snow / pumpkins / water-splash / confetti effects. */
.seasonal-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}
.seasonal-decor span {
  position: absolute;
  top: -10vh;
  font-size: 1.6rem;
  user-select: none;
  opacity: 0.85;
  animation-name: decor-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.18));
}
@keyframes decor-fall {
  0%   { transform: translate3d(0, -10vh, 0) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translate3d(20px, 110vh, 0) rotate(360deg); opacity: 0; }
}
@keyframes decor-rise {
  0%   { transform: translate3d(0, 110vh, 0) scale(0.8);  opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: translate3d(-20px, -10vh, 0) scale(1.1); opacity: 0; }
}
[data-style="songkran"] .seasonal-decor span {
  animation-name: decor-rise;
}
@media (prefers-reduced-motion: reduce) {
  .seasonal-decor { display: none; }
}

/* ---- Decoration GIF sticker (custom, uploaded by admin) ----
   A small floating image at the bottom-right of every page, with a
   close button so visitors can dismiss it for the session. */
.decor-gif {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 96px;
  height: 96px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35), 0 0 0 1px var(--border-strong);
  background: var(--surface-solid);
  z-index: 30;
  animation: decor-pop 0.4s ease-out;
}
.decor-gif img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.decor-gif .decor-close {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.decor-gif .decor-close:hover { background: rgba(0,0,0,0.8); }
@keyframes decor-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@media (max-width: 480px) {
  .decor-gif { width: 72px; height: 72px; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 120% 70% at 12% -20%, rgba(167,139,250,0.10), transparent 60%),
    radial-gradient(ellipse 90% 60% at 100% 0%,  rgba(34,211,238,0.06),  transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(124,58,237,0.05), transparent 60%);
  background-attachment: fixed;
}
[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 120% 70% at 10% 0%, rgba(124,58,237,0.06), transparent 60%),
    radial-gradient(ellipse 80% 50% at 100% 10%, rgba(34,211,238,0.04), transparent 60%);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ================== LAYOUT ================== */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ================== HEADER / NAV ================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(11,15,26,0.85), rgba(11,15,26,0.55));
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .site-header {
  background: linear-gradient(180deg, rgba(245,244,251,0.92), rgba(245,244,251,0.7));
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
  font-size: 1.15rem;
  color: var(--text);
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-grad);
  display: inline-grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: var(--shadow-glow);
}
.brand-name {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tag {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 6px;
}

.nav {
  display: flex; gap: 6px; align-items: center;
}
.nav-pill {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.nav-pill:hover { color: var(--text); background: var(--surface); }
.nav-pill.active { color: var(--accent); border-color: var(--border-strong); background: var(--surface); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions .icon-btn { border: 1px solid var(--border); }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--surface-hover); transform: translateY(-1px); }
.icon-btn .badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
  line-height: 1;
}

/* Mobile nav */
.menu-toggle { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .menu-toggle { display: inline-grid; }
  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%; left: 0; right: 0;
    padding: 12px 20px;
    background: var(--surface-solid);
    border-bottom: 1px solid var(--border);
    align-items: stretch;
  }
  .nav.open .nav-pill { width: 100%; }
}

/* ================== BUTTONS ================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all var(--transition);
}
.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* "Busy" state for buttons doing async work (login, register, save).
   Adds a spinner + dims the button + ignores clicks so users on a
   slow network can't fire the same request 5 times in a row. */
.btn.is-busy {
  cursor: progress;
  pointer-events: none;
  opacity: 0.85;
}
.btn.is-busy::after {
  /* subtle shimmer sweep across the button while it's working */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.18),
    transparent
  );
  background-size: 200% 100%;
  animation: btn-shimmer 1.4s linear infinite;
  pointer-events: none;
}
.btn-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: -0.18em;
}
.btn-busy-label { font-weight: 600; }
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
@keyframes btn-shimmer {
  0%   { background-position: -100% 0; }
  100% { background-position:  200% 0; }
}

.btn-primary {
  background: var(--accent-grad);
  color: white;
  border: none;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.45);
  transform: translateY(-1px);
}
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-success { background: var(--success); border-color: var(--success); color: #062a1a; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #3a2604; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }

/* ================== CARDS ================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card-hover { transition: all var(--transition); cursor: pointer; }
.card-hover:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--shadow-glow);
}

/* ================== HERO ================== */
.hero {
  position: relative;
  padding: 60px 0 40px;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 40px;
  align-items: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin: 0 0 16px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero h1 .grad {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p { color: var(--text-2); font-size: 1.05rem; max-width: 520px; margin: 0 0 22px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats {
  display: flex; gap: 28px; margin-top: 28px;
}
.hero-stat .num {
  font-size: 1.6rem; font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-stat .lbl { color: var(--muted); font-size: 0.8rem; }

.hero-art {
  position: relative;
  aspect-ratio: 1.05 / 1;
  display: grid;
  place-items: center;
}
.hero-orb {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(167,139,250,0.35), transparent 60%);
  filter: blur(20px);
}
.hero-card-stack {
  position: relative;
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: center;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.hero-card .ic {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-grad);
  color: white; font-weight: 800;
}
.hero-card .ttl { font-weight: 700; font-size: 0.95rem; }
.hero-card .sub { color: var(--text-2); font-size: 0.8rem; }
.hero-card.float-1 { transform: translateX(-12px); }
.hero-card.float-2 { transform: translateX(28px); }
.hero-card.float-3 { transform: translateX(-4px); }

@media (max-width: 760px) {
  .hero { padding: 30px 0 20px; }
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-art { display: none; }
  .hero-stats { gap: 16px; flex-wrap: wrap; }
}

/* ================== SECTION TITLES ================== */
.section { padding: 36px 0; }
.section-head {
  display: flex; justify-content: space-between; align-items: end;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.section-head h2 {
  margin: 0; font-size: 1.35rem; font-weight: 700;
}
.section-head .sub { color: var(--text-2); font-size: 0.9rem; }

/* ================== FILTER BAR ================== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 18px;
}
.filter-chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }
.filter-chip.active {
  color: white;
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(124,58,237,0.35);
}
.search {
  flex: 1;
  min-width: 220px;
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.search input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 0.9rem;
}
.search svg { color: var(--muted); margin-right: 6px; flex-shrink: 0; }

/* ================== PRODUCT GRID ================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.product-card {
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.product-thumb {
  aspect-ratio: 1.6 / 1;
  background:
    linear-gradient(135deg, rgba(167,139,250,0.18), rgba(34,211,238,0.12)),
    var(--surface-solid);
  position: relative;
  display: grid; place-items: center;
  overflow: hidden;
}
.product-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.product-thumb .placeholder {
  font-size: 3rem; opacity: 0.6;
}
.product-tag {
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 6px;
  background: rgba(124, 58, 237, 0.18);
  color: var(--accent);
  border: 1px solid var(--border-strong);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Light theme: a translucent dark tint on a bright product image makes
   the violet text wash out. Flip the chip to a solid white pill with
   strong violet text + a subtle shadow so the category stays legible
   on any background. */
[data-theme="light"] .product-tag {
  background: rgba(124, 58, 237, 0.12);
  color: var(--accent-2);
  border-color: rgba(124, 58, 237, 0.40);
}
.product-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.product-title {
  font-weight: 700; font-size: 1rem; margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-desc {
  color: var(--text-2); font-size: 0.85rem;
  margin: 0 0 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.product-price { font-weight: 800; font-size: 1.05rem; color: var(--accent); }
.product-price small { color: var(--muted); font-weight: 500; font-size: 0.7rem; }

/* ================== PRODUCT DETAIL ================== */
.product-detail {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  margin-top: 24px;
}
.detail-art {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  aspect-ratio: 1.6/1;
  display: grid; place-items: center;
  position: relative;
}
.detail-art img { width: 100%; height: 100%; object-fit: cover; }
.detail-meta { display: flex; flex-direction: column; gap: 14px; }
.detail-meta h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; }
.detail-meta .price-row {
  display: flex; align-items: end; gap: 12px;
  font-size: 1.6rem; font-weight: 800; color: var(--accent);
}
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li {
  display: flex; align-items: start; gap: 10px;
  padding: 6px 0;
  color: var(--text-2);
  font-size: 0.9rem;
}
.feature-list li::before {
  content: "✓";
  color: var(--success);
  font-weight: 800;
}
@media (max-width: 760px) {
  .product-detail { grid-template-columns: 1fr; }
}

/* ================== CART / CHECKOUT ================== */
.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 12px;
}
.cart-item .ci-thumb {
  width: 60px; height: 60px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(167,139,250,0.2), rgba(34,211,238,0.12));
  display: grid; place-items: center; font-size: 1.5rem;
}
.cart-item .ci-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.cart-item .ci-name { font-weight: 600; }
.cart-item .ci-meta { color: var(--muted); font-size: 0.8rem; }
.qty {
  display: inline-flex; align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.qty button {
  width: 28px; height: 28px;
  background: transparent; border: none; color: var(--text);
  cursor: pointer; font-size: 1rem;
}
.qty span { width: 28px; text-align: center; font-weight: 600; }

.cart-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 760px) { .cart-grid { grid-template-columns: 1fr; } }

.summary-row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary-row.total { font-weight: 800; font-size: 1.15rem; color: var(--text); border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 12px; }

/* ================== FORMS ================== */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 0.85rem; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
/* Checkboxes/radios should never stretch to 100% — they belong inline. */
.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.field-error { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }
.file-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}
.file-drop:hover { border-color: var(--accent); background: var(--surface-hover); }
.file-drop.has-file { border-style: solid; border-color: var(--success); }
.file-preview { max-height: 240px; margin-top: 10px; border-radius: var(--radius-sm); margin-inline: auto; }

/* ================== AUTH ================== */
.auth-wrap {
  max-width: 460px; margin: 60px auto;
  padding: 32px;
}
.auth-wrap h1 { margin: 0 0 6px; font-size: 1.6rem; }
.auth-wrap p.sub { color: var(--text-2); margin: 0 0 22px; }
.auth-switch { color: var(--text-2); font-size: 0.85rem; margin-top: 14px; text-align: center; }
.auth-switch a { font-weight: 600; }

/* Telegram login block + "or use email" divider */
.tg-login-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}
.tg-login-host {
  display: flex;
  justify-content: center;
  min-height: 44px;
  width: 100%;
}
.tg-login-host iframe {
  border-radius: 10px !important;
}
.auth-divider {
  position: relative;
  text-align: center;
  margin: 18px 0;
  color: var(--text-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.auth-divider span {
  padding: 0 10px;
  background: var(--bg-1);
}

/* Telegram "Get updates" deep-link button */
.tg-deep-link {
  background: linear-gradient(135deg, #2aabee 0%, #229ed9 100%);
  color: #fff !important;
  border: none;
  font-weight: 600;
}
.tg-deep-link:hover { filter: brightness(1.08); }

/* ================== TABLES ================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table.t {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
table.t th, table.t td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
table.t th {
  background: var(--surface-solid);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.t tr:last-child td { border-bottom: none; }
table.t tbody tr { transition: background var(--transition); }
table.t tbody tr:hover { background: var(--surface-hover); }

/* ================== STATUS PILLS ================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid;
}
.pill-pending  { color: #fbbf24; border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.1); }
.pill-approved { color: #34d399; border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.1); }
.pill-rejected { color: #f87171; border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.1); }
.pill-delivered{ color: #a78bfa; border-color: rgba(167,139,250,0.4); background: rgba(167,139,250,0.1); }
.pill-active   { color: #34d399; border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.1); }
.pill-blocked  { color: #f87171; border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.1); }

/* ================== ADMIN ================== */
.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}
.admin-side {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.admin-side .side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem; font-weight: 500;
}
.admin-side .side-link:hover { background: var(--surface-hover); color: var(--text); }
.admin-side .side-link.active {
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 6px 16px rgba(124,58,237,0.35);
}
.admin-main { padding: 28px; }
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.admin-head h1 { margin: 0; font-size: 1.5rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card { padding: 18px; }
.stat-card .lbl { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; font-weight: 500; }
.stat-card .num { font-size: 1.7rem; font-weight: 800; }
.stat-card .num.grad {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-side { display: flex; flex-direction: row; overflow-x: auto; padding: 12px; gap: 6px; border-right: none; border-bottom: 1px solid var(--border); }
  .admin-side .side-link { white-space: nowrap; }
  .admin-main { padding: 18px; }
}

/* ================== TOASTS ================== */
#toast-root {
  position: fixed; top: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  min-width: 220px; max-width: 320px;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  border-left: 4px solid var(--accent);
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--danger); }

@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateX(20px); opacity: 0; } }

/* ================== MODALS ================== */
#modal-root {
  position: fixed; inset: 0; z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(5, 8, 18, 0.7);
  backdrop-filter: blur(6px);
  padding: 20px;
}
#modal-root.open { display: flex; }
.modal {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ================== EMPTY STATE ================== */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-2);
}
.empty .ic { font-size: 3rem; margin-bottom: 8px; opacity: 0.6; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 1.1rem; }

/* ================== FOOTER ================== */
.site-footer {
  margin-top: auto;
  padding: 30px 0 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.foot-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}
.foot-grid h4 { color: var(--text); margin: 0 0 10px; font-size: 0.95rem; }
.foot-grid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.foot-grid a { color: var(--text-2); }
.foot-grid a:hover { color: var(--accent); }
.foot-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 760px) { .foot-grid { grid-template-columns: 1fr; } }

/* ============================================================
   Site theme settings panel (Admin → Settings → Site theme)
   ============================================================ */
.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.theme-preset {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
}
.theme-preset:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.theme-preset.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent) inset, var(--shadow-sm);
}
.theme-preset-swatch {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
}
.theme-preset[data-preset="default"]   .theme-preset-swatch { background: linear-gradient(135deg, #a78bfa, #7c3aed, #22d3ee); }
.theme-preset[data-preset="halloween"] .theme-preset-swatch { background: linear-gradient(135deg, #facc15, #ff8a3d, #6b21a8); }
.theme-preset[data-preset="christmas"] .theme-preset-swatch { background: linear-gradient(135deg, #166534, #ef4444, #fde68a); }
.theme-preset[data-preset="songkran"]  .theme-preset-swatch { background: linear-gradient(135deg, #38bdf8, #22d3ee, #2dd4bf); }
.theme-preset[data-preset="newyear"]   .theme-preset-swatch { background: linear-gradient(135deg, #f472b6, #fbbf24, #f59e0b); }
.theme-preset-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.theme-preset-label strong { font-size: 0.92rem; }
.theme-preset-label small  { font-size: 0.8rem; margin-top: 2px; }

.theme-gif-preview {
  margin-top: 10px;
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  text-align: center;
}
.theme-gif-preview img { width: 100%; height: 100%; object-fit: cover; }
.theme-gif-preview .muted { font-size: 0.78rem; padding: 0 8px; }

/* ================== UTILITIES ================== */
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 14px; }
.mt-3 { margin-top: 22px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.mb-3 { margin-bottom: 22px; }
.tac { text-align: center; }
.hide-mobile { }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }

/* Watermark overlay (download protection) */
.watermark-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0.05;
  background-image: var(--wm, none);
  background-repeat: repeat;
  display: none;
}
.watermark-overlay.show { display: block; }

/* =========================================================
   POLISH — smoother buttons, mobile tap targets, fluid grids,
   loading spinner, payment info block
   ========================================================= */

html { scroll-behavior: smooth; }
body { overflow-x: hidden; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Button feel ---- */
.btn {
  position: relative;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
  will-change: transform, box-shadow;
}
.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  transition-duration: 0.08s;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.btn-primary {
  background-size: 200% 200%;
  background-position: 0% 50%;
  transition: background-position 0.4s ease, transform var(--transition),
              box-shadow var(--transition), filter var(--transition);
}
.btn-primary:hover:not(:disabled) {
  background-position: 100% 50%;
}

/* ---- Loading button (spinner instead of text on submit) ---- */
.btn.is-loading {
  pointer-events: none;
  position: relative;
  color: rgba(255,255,255,0.95);
}
.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

/* ---- Filter chip polish ---- */
.filter-chip {
  -webkit-tap-highlight-color: transparent;
}
.filter-chip:active { transform: scale(0.96); }
.filter-chip.active { letter-spacing: 0.02em; }

/* ---- Card hover refinement ---- */
.card-hover { will-change: transform; }
.card-hover:active { transform: translateY(-1px) scale(0.995); }

/* ---- Payment info block on checkout ---- */
.pay-info { display: flex; flex-direction: column; gap: 12px; }
.pay-info h4 { margin: 0; font-size: 1rem; color: var(--accent); letter-spacing: 0.01em; }
.pay-row {
  display: flex; flex-direction: column; gap: 6px;
}
.pay-label {
  font-size: 0.72rem; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.pay-value-wrap {
  display: flex; align-items: center; gap: 8px;
}
.pay-value {
  flex: 1;
  background: var(--bg-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  color: var(--text);
  border: 1px solid var(--border);
  word-break: break-all;
  min-width: 0;
}
.pay-note {
  margin: 0;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ---- Storefront subtle skeleton while products are hydrating ---- */
.product-grid:empty {
  min-height: 240px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent, rgba(167,139,250,0.06), transparent) 0 0/200% 100%,
    var(--surface);
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
@keyframes skeletonShimmer {
  0%   { background-position: -100% 0, 0 0; }
  100% { background-position:  100% 0, 0 0; }
}

/* ---- Mobile / tablet refinements ---- */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .container { padding: 0 14px; }
  .section { padding: 24px 0; }
  .btn { padding: 12px 18px; font-size: 0.92rem; min-height: 44px; }
  .btn-sm { padding: 8px 12px; font-size: 0.8rem; min-height: 36px; }
  .btn-lg { padding: 14px 20px; font-size: 0.98rem; min-height: 48px; }
  .icon-btn { width: 42px; height: 42px; }
  .filter-chip { padding: 9px 14px; font-size: 0.85rem; min-height: 36px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
  .product-thumb .placeholder { font-size: 2.4rem; }
  .product-body { padding: 12px 14px 14px; }
  .product-title { font-size: 0.95rem; }
  .product-desc { font-size: 0.8rem; }
  /* On narrow product cards the price + "Add to Cart" button can't fit
     on one line — stack them vertically and let the button take the
     full card width so nothing overflows the rounded edge. */
  .product-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .product-price { font-size: 1rem; }
  .product-foot .btn,
  .product-foot .btn-sm {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .card { padding: 16px; border-radius: 14px; }
  .stat-card { padding: 14px; }
  .stat-card .num { font-size: 1.4rem; }
  table.t th, table.t td { padding: 10px 12px; font-size: 0.82rem; }
  .modal { padding: 18px; border-radius: 14px; }
  #toast-root { top: 12px; right: 12px; left: 12px; }
  .toast { min-width: auto; max-width: none; }
  .hero-actions .btn { flex: 1; }
}

/* Extra small phones */
@media (max-width: 380px) {
  .product-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero h1 { font-size: 1.55rem; }
  .header-inner { padding: 12px 0; }
  .brand-tag { display: none; }
}

/* Larger desktops */
@media (min-width: 1280px) {
  .container { padding: 0 24px; }
}
