/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Surface */
  --surface-0: #0E1015;   /* page background */
  --surface-1: #14161C;   /* base panel */
  --surface-2: #1B1E26;   /* raised panel / row hover */
  --surface-3: #232630;   /* input fields, inset */
  --border: #2A2E38;
  --border-soft: #1F222B;

  /* Text */
  --text-primary: #F4F3EE;
  --text-secondary: #B7B9C2;
  --text-muted: #7C7F8A;

  /* Brand */
  --gold: #D9A62B;
  --gold-dim: #8A6B1F;
  --gold-tint: rgba(217, 166, 43, 0.12);

  --teal: #17A589;
  --teal-tint: rgba(23, 165, 137, 0.12);

  --red: #E5484D;
  --red-tint: rgba(229, 72, 77, 0.12);

  /* Type */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-elevate: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* Pengaman: cegah scroll horizontal di seluruh halaman, apapun penyebabnya */
html, body { overflow-x: hidden; width: 100%; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0; }

a { color: inherit; text-decoration: none; }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

img { max-width: 100%; display: block; }

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Focus visibility — accessibility, never remove */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================
   LAYOUT SHELL
   ============================================ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px; /* space for mobile bottom nav */
}

/* ============================================
   TOP BAR
   ============================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(14, 16, 21, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  max-width: 1120px;
  margin: 0 auto;
  min-width: 0;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-shrink: 0;
}
.logo .dot { color: var(--gold); }

.search-field {
  flex: 1;
  min-width: 0;
  position: relative;
  max-width: 460px;
}
.search-field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 38px;
  color: var(--text-primary);
}
.search-field input::placeholder { color: var(--text-muted); }
.search-field input:focus { border-color: var(--gold-dim); outline: none; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.balance-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-tint);
  border: 1px solid rgba(217, 166, 43, 0.3);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 13px;
  max-width: 132px;
  overflow: hidden;
}
.balance-chip .label { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0; }
.balance-chip .amount {
  font-family: var(--font-mono);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--surface-0);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tombol nominal di grid (mis. preset deposit) — teks angka boleh nowrap
   tapi track grid wajib bisa menyusut di bawah lebar kontennya (minmax 0),
   supaya grid tidak mendorong lebar halaman melebihi layar. */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--gold);
  color: #14161C;
}
.btn-primary:hover { background: #e6b23a; }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover { border-color: var(--gold-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); }

.btn-danger {
  background: var(--red-tint);
  color: var(--red);
  border-color: rgba(229, 72, 77, 0.3);
}

.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ============================================
   ROW LIST (signature pattern — price-list style,
   dipakai buat katalog produk & riwayat transaksi
   sebagai pengganti card grid generik)
   ============================================ */
.row-list {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-1);
}

.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--surface-2); }

.row-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
}

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.row-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.row-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
}
.row-value.gold { color: var(--gold); }

.row-chevron { color: var(--text-muted); flex-shrink: 0; }

/* ============================================
   STATUS PILLS (bukan pill button — status label,
   fungsional, bukan dekoratif)
   ============================================ */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-success { background: var(--teal-tint); color: var(--teal); }
.status-pending { background: var(--gold-tint); color: var(--gold); }
.status-failed { background: var(--red-tint); color: var(--red); }
.status-processing { background: rgba(140, 150, 255, 0.12); color: #8C96FF; }

/* ============================================
   PANELS / SECTIONS
   ============================================ */
.section { padding: 32px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 18px; }
.section-link { font-size: 13px; color: var(--gold); }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.field input, .field select {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--gold-dim);
}
.field-hint { font-size: 12px; color: var(--text-muted); }
.field-error { font-size: 12px; color: var(--red); }

/* ============================================
   TOAST
   ============================================ */
.toast-stack {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow-elevate);
  animation: toast-in 0.2s ease;
}
.toast.success { border-left-color: var(--teal); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.7);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
  animation: modal-up 0.22s ease;
}
@keyframes modal-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-lg); }
}

/* ============================================
   BOTTOM NAV (mobile)
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(20, 22, 28, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
  display: flex;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  font-size: 10.5px;
  color: var(--text-muted);
}
.nav-item.active { color: var(--gold); }
.nav-item svg { width: 20px; height: 20px; }

/* ============================================
   SKELETON
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shine {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ============================================
   GAME CARD (dipakai di products.html saat kategori = game:
   grid kotak dengan warna aksen tipis per game, bukan gradient generik)
   ============================================ */
.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 480px) {
  .game-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.game-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  min-width: 0;
}
.game-card:hover { border-color: var(--gold-dim); }
.game-card:active { transform: scale(0.98); }
.game-card .game-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}
.game-card .game-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.game-card .game-provider {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ============================================
   UTILS
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

@media (min-width: 860px) {
  .bottom-nav { display: none; }
  .app-shell { padding-bottom: 0; }
}
@media (max-width: 640px) {
  .search-field { display: none; }
  .balance-chip .label { display: none; }
}
