/* =============================================================================
   KUANGTALIN GAME CATALOG & COMMERCE HUB - Design System
   ============================================================================= */

:root {
  --bg-deep: #060911;
  --bg-surface: #0c1222;
  --bg-glass: rgba(12, 18, 34, 0.82);
  --bg-card: rgba(16, 24, 46, 0.85);
  --bg-input: rgba(7, 11, 22, 0.9);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-glow: rgba(0, 240, 255, 0.28);
  --border-glow-hover: rgba(0, 240, 255, 0.65);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --cyan: #00f0ff;
  --amber: #ffb834;
  --violet: #a855f7;
  --emerald: #10b981;
  --rose: #f43f5e;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 15% 15%, rgba(0, 240, 255, 0.08), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(168, 85, 247, 0.08), transparent 40%);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

.text-muted { color: var(--text-muted); }
.text-cyan { color: var(--cyan); }
.text-amber { color: var(--amber); }
.text-violet { color: var(--violet); }
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 0;
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: 0.03em;
  font-size: 0.94rem;
  white-space: nowrap;
}

.nav-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.78);
  padding: 4px;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  max-width: 100%;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.is-active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(99, 102, 241, 0.28));
  color: var(--text-main);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.45);
}

.nav-tab-arcade {
  color: #67e8f9;
  background: rgba(0, 240, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.22);
}

.nav-tab-arcade:hover {
  background: rgba(0, 240, 255, 0.16);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.5);
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.nav-tab-ops {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.78);
  padding: 6px 11px;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border-subtle);
  max-width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  flex-shrink: 0;
}

#api-status-text {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* --- Buttons & Inputs --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  border-color: var(--border-glow-hover);
  background: rgba(30, 41, 59, 1);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.35);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-success {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.28);
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  transition: var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 240, 255, 0.15);
}

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

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.28);
  white-space: nowrap;
}

.badge-amber {
  background: rgba(255, 184, 52, 0.12);
  color: var(--amber);
  border-color: rgba(255, 184, 52, 0.32);
}

.badge-emerald {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.32);
}

.badge-violet {
  background: rgba(168, 85, 247, 0.12);
  color: #d8b4fe;
  border-color: rgba(168, 85, 247, 0.32);
}

.badge-rose {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.32);
}

.badge-slate {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.28);
}

/* --- Layout Sections --- */
.main-content {
  padding: 32px 0 64px;
}

.hero-banner {
  background: linear-gradient(135deg, rgba(14, 24, 48, 0.92), rgba(15, 23, 42, 0.72));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.hero-banner h1 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero-banner p {
  color: var(--text-muted);
  max-width: 680px;
  font-size: 0.95rem;
}

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 28px 0 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
}

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

.filter-bar .input,
.filter-bar .select {
  width: auto;
  min-width: 160px;
}

/* --- Cards & Grids --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  position: relative;
}

.game-card:hover {
  border-color: var(--border-glow-hover);
  transform: translateY(-2px);
}

.game-card.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 12px 30px -12px rgba(0, 240, 255, 0.35);
}

.game-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.game-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 10px;
}

.game-icon-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  font-size: 0.72rem;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
}

.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

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

.product-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.price-tag {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

/* --- KPI Cards --- */
.kpi-card {
  padding: 18px 20px;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  margin-top: 4px;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  vertical-align: middle;
}

.data-table th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tr:hover td {
  background: rgba(30, 41, 59, 0.35);
}

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

/* --- Switch Toggle --- */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #334155;
  border-radius: 9999px;
  transition: 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--emerald);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* --- Admin Sub-tabs --- */
.subtabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.subtab-group {
  display: flex;
  gap: 8px;
}

.subtab-btn {
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.subtab-btn.is-active {
  background: rgba(0, 240, 255, 0.14);
  color: var(--cyan);
  border-color: rgba(0, 240, 255, 0.45);
}

/* --- Modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 84px 20px 24px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  background: #0f172a;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.modal-open .toast-container,
body:has(.modal-backdrop:not(.hidden)) .toast-container {
  top: 16px;
  right: 16px;
  bottom: auto;
  flex-direction: row-reverse;
  align-items: flex-start;
  max-width: calc(100vw - 32px);
}

body.modal-open .toast-container .toast:not(:last-child),
body:has(.modal-backdrop:not(.hidden)) .toast-container .toast:not(:last-child) {
  display: none;
}

body.modal-open .toast-container .toast,
body:has(.modal-backdrop:not(.hidden)) .toast-container .toast {
  padding: 10px 14px;
  line-height: 1.3;
}

.toast {
  background: #0f172a;
  border: 1px solid var(--border-glow);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  min-width: 260px;
  pointer-events: auto;
  max-width: min(360px, calc(100vw - 32px));
}

.toast.error {
  border-color: rgba(244, 63, 94, 0.6);
  color: #fecdd3;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.6);
  color: #a7f3d0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
}

.footer {
  border-top: 1px solid var(--border-subtle);
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.footer-links a {
  color: var(--cyan);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* --- Meta-Gallery & Provenance --- */
.curator-pill {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.curator-pill:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}
.curator-pill.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 10px 26px -12px rgba(0, 240, 255, 0.35);
}
.gallery-art-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gallery-art-card:hover {
  border-color: var(--border-glow-hover);
  transform: translateY(-2px);
}
.gallery-svg-frame {
  display: flex;
  align-items: center;
  gap: 14px;
}
.gallery-svg-frame svg {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.provenance-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.provenance-step {
  padding: 10px 12px;
  border-left: 2px solid var(--cyan);
  background: rgba(15, 23, 42, 0.72);
  border-radius: 0 8px 8px 0;
  font-size: 0.84rem;
}

/* --- Storefront Arcade Lab Strip --- */
.arcade-strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.arcade-strip-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(16, 24, 46, 0.94), rgba(10, 15, 30, 0.92));
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  color: var(--text-main);
  transition: var(--transition);
}

.arcade-strip-card:hover {
  border-color: var(--border-glow-hover);
  transform: translateY(-2px);
}

.arcade-strip-thumb {
  width: 100%;
  aspect-ratio: 920 / 430;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(0, 240, 255, 0.16), rgba(8, 12, 24, 0.95));
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.arcade-strip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.arcade-strip-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .container {
    padding: 0 14px;
  }
  .nav-brand {
    white-space: normal;
  }
  .badge {
    white-space: normal;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .hero-banner {
    padding: 20px 16px;
  }
  .nav-divider {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar .input,
  .filter-bar .select {
    width: 100%;
  }
}
