/* Steam Game Orders: shared styles. Dark gaming theme: indigo-black base, electric violet accent. */

:root {
  color-scheme: dark;
  --bg: oklch(0.16 0.025 285);
  --surface: oklch(0.205 0.03 285);
  --surface-2: oklch(0.245 0.035 285);
  --border: oklch(0.30 0.04 285);
  --border-strong: oklch(0.38 0.045 285);
  --text: oklch(0.95 0.01 285);
  --muted: oklch(0.72 0.03 285);
  --faint: oklch(0.58 0.03 285);

  --accent: oklch(0.62 0.23 295);
  --accent-hover: oklch(0.68 0.23 295);
  --accent-soft: oklch(0.30 0.10 295);
  --accent-glow: oklch(0.62 0.23 295 / 0.45);
  --on-accent: oklch(0.985 0.01 295);
  --focus: oklch(0.70 0.20 295 / 0.55);
  --link: oklch(0.80 0.13 300);
  --link-hover: oklch(0.88 0.10 300);

  --pending-bg: oklch(0.29 0.03 285);
  --pending-fg: oklch(0.80 0.03 285);
  --processing-bg: oklch(0.32 0.08 215);
  --processing-fg: oklch(0.87 0.13 210);
  --delivered-bg: oklch(0.33 0.09 145);
  --delivered-fg: oklch(0.89 0.19 140);
  --danger: oklch(0.70 0.19 20);
  --danger-soft: oklch(0.30 0.08 20);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px oklch(0 0 0 / 0.35), 0 8px 24px oklch(0.05 0.03 285 / 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
p { margin: 0; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.9em; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.eyebrow { font-size: 0.8125rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.stack { display: grid; gap: 16px; }

/* ---------- Form controls ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 0.875rem; font-weight: 550; }
.field .hint { font-size: 0.8125rem; color: var(--muted); }
.field .error { font-size: 0.8125rem; color: var(--danger); min-height: 0; }
.field .error:empty { display: none; }

input[type="text"], input[type="email"], input[type="url"], input[type="password"], input[type="search"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input::placeholder { color: var(--faint); }
input:hover { border-color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px oklch(0.6 0.18 27 / 0.3); }
input:disabled { opacity: 0.6; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px;
  font: inherit; font-size: 0.875rem; font-weight: 600; line-height: 1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 100ms var(--ease);
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger.is-confirming { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-lg { height: 46px; padding: 0 20px; font-size: 0.9375rem; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pending { background: var(--pending-bg); color: var(--pending-fg); }
.badge-processing { background: var(--processing-bg); color: var(--processing-fg); }
.badge-delivered { background: var(--delivered-bg); color: var(--delivered-fg); }

/* ---------- Centered pages (login, customer) ---------- */
.page-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth { width: 100%; max-width: 360px; display: grid; gap: 20px; }
.auth h1 { margin-top: -12px; }

/* ---------- Admin shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: baseline; gap: 8px; font-weight: 650; }
.topbar .brand span { font-weight: 450; color: var(--muted); font-size: 0.875rem; }
.topbar form { margin: 0; }

.admin-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 16px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}
.create, .orders { min-width: 0; grid-template-columns: minmax(0, 1fr); }

/* Create order */
.create { display: grid; gap: 14px; }
.create-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 12px;
  align-items: start;
}
.create-form .btn { height: 42px; margin-top: 26px; }

.created {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  animation: rise 250ms var(--ease);
}
.created[hidden] { display: none; }
.created-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.created-head p { font-size: 0.875rem; }
.link-row { display: flex; gap: 8px; }
.link-row input { font-family: var(--mono); font-size: 0.8125rem; background: var(--surface); }

/* Orders toolbar */
.orders { display: grid; gap: 14px; }
.orders-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2);
  border-radius: 9px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  font: inherit; font-size: 0.8125rem; font-weight: 550;
  color: var(--muted);
  background: transparent; border: 0; border-radius: 7px;
  cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.tab:hover { color: var(--text); }
.tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tab .count { font-variant-numeric: tabular-nums; color: var(--faint); font-weight: 500; }
.tab[aria-selected="true"] .count { color: var(--muted); }
.search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { height: 38px; padding-left: 34px; }

/* Orders table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.orders-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.orders-table th {
  text-align: left;
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.orders-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.orders-table tbody tr:last-child td { border-bottom: 0; }
.orders-table tbody tr { transition: background-color 150ms var(--ease); }
.orders-table tbody tr:hover { background: color-mix(in oklch, var(--surface-2) 50%, transparent); }
.orders-table tr.is-new { animation: flash 1.6s var(--ease); }
.cell-game { font-weight: 600; }
.cell-sub { display: block; font-size: 0.8125rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
.cell-customer { max-width: 260px; }
.cell-customer a, .cell-customer span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-customer a { font-size: 0.8125rem; }
.cell-actions { text-align: right; white-space: nowrap; }
.actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.mail-note { display: block; font-size: 0.75rem; margin-top: 4px; color: var(--muted); }
.mail-note.is-error { color: var(--danger); }

/* Overflow menu */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  min-width: 190px;
  display: grid; padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise 150ms var(--ease);
}
.menu-panel .btn { justify-content: flex-start; border: 0; background: transparent; height: 34px; font-weight: 500; }
.menu-panel .btn:hover { background: var(--surface-2); }
.menu-panel .btn-danger.is-confirming { background: var(--danger); color: var(--on-accent); }

/* Empty + loading */
.empty { padding: 48px 20px; text-align: center; display: grid; gap: 6px; justify-items: center; }
.empty p { max-width: 42ch; }
.skeleton-row td { padding: 16px 14px; }
.skeleton { height: 12px; border-radius: 6px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }

/* Toast */
.toast-region {
  position: fixed; left: 50%; bottom: 20px; z-index: 50;
  transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center;
  width: calc(100% - 32px); max-width: 420px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: 0.875rem; font-weight: 500;
  box-shadow: var(--shadow);
  animation: rise 200ms var(--ease);
  pointer-events: auto;
}
.toast.is-error { background: var(--danger); color: var(--on-accent); }

/* ---------- Customer page ---------- */
.activate { width: 100%; max-width: 440px; display: grid; gap: 24px; }
.activate-head { display: grid; gap: 6px; }
.order-summary {
  display: grid; gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.order-summary .game { font-size: 1.0625rem; font-weight: 650; }
.order-summary .meta { font-size: 0.8125rem; color: var(--muted); }
.activate-form { display: grid; gap: 18px; }
.state { display: grid; gap: 14px; justify-items: start; animation: rise 300ms var(--ease); }
.state-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
}
.state-icon svg { width: 24px; height: 24px; }
.state-wait .state-icon { background: var(--processing-bg); color: var(--processing-fg); }
.state-done .state-icon { background: var(--delivered-bg); color: var(--delivered-fg); }
.state-wait .state-icon svg { animation: spin 2.4s linear infinite; }
.state h1 { font-size: 1.375rem; }
.state p { color: var(--muted); max-width: 46ch; }
.details { width: 100%; display: grid; gap: 0; font-size: 0.875rem; border-top: 1px solid var(--border); }
.details div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.details dt { color: var(--muted); white-space: nowrap; }
.details dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 500; }
.footnote { font-size: 0.8125rem; color: var(--faint); }

@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
@keyframes pulse { 50% { opacity: 0.5; } }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .admin-main { padding-top: 20px; gap: 26px; }
  .create-form { grid-template-columns: 1fr; }
  .create-form .btn { margin-top: 0; width: 100%; }
  .search { flex: none; width: 100%; max-width: none; min-width: 0; }
  .toolbar { flex-direction: column-reverse; align-items: stretch; }
  .tabs { align-self: flex-start; }

  /* Table rows become stacked items */
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .orders-table thead { display: none; }
  .orders-table, .orders-table tbody, .orders-table tr, .orders-table td { display: block; }
  .orders-table tbody { display: grid; gap: 10px; }
  .orders-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .orders-table tbody tr:hover { background: var(--surface); }
  .orders-table td { padding: 0; border: 0; }
  .orders-table td.cell-game { grid-column: 1; }
  .orders-table td.cell-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .orders-table td.cell-customer, .orders-table td.cell-date { grid-column: 1 / -1; max-width: none; }
  .orders-table td.cell-date { font-size: 0.8125rem; color: var(--muted); }
  .orders-table td.cell-date::before { content: "Created "; }
  .orders-table td.cell-customer:empty { display: none; }
  .orders-table td.cell-actions { grid-column: 1 / -1; text-align: left; padding-top: 4px; }
  .orders-table td.cell-actions .actions { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
  .orders-table td.cell-actions .actions > .btn-primary { flex: 1; }
  .menu-panel { right: 0; }
  .skeleton-row td { padding: 0; }
  .link-row { flex-direction: column; }
  .link-row .btn { width: 100%; }
}

/* ---------- Gaming theme accents ---------- */
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, oklch(0.35 0.14 295 / 0.35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, oklch(0.40 0.12 210 / 0.20), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.topbar { background: oklch(0.18 0.03 285 / 0.92); }
.topbar .brand::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  align-self: center;
}
.topbar .brand { align-items: center; }

.btn-primary { box-shadow: 0 0 0 0 transparent, 0 4px 14px oklch(0.62 0.23 295 / 0.30); }
.btn-primary:hover { box-shadow: 0 0 0 1px oklch(0.75 0.2 295 / 0.5), 0 6px 22px var(--accent-glow); }
.btn-primary:disabled, .btn-primary[aria-busy="true"] { box-shadow: none; }

.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px oklch(0.62 0.23 295 / 0.45); }
.tab[aria-selected="true"] .count { color: var(--link); }

.badge-processing { box-shadow: inset 0 0 0 1px oklch(0.75 0.13 210 / 0.35); }
.badge-delivered { box-shadow: inset 0 0 0 1px oklch(0.80 0.19 140 / 0.35); }
.badge-processing::before { box-shadow: 0 0 8px currentColor; animation: pulse 1.6s ease-in-out infinite; }
.badge-delivered::before { box-shadow: 0 0 8px currentColor; }

.table-wrap { box-shadow: var(--shadow); }
.cell-sub.mono { color: var(--link); opacity: 0.85; }
.created { border: 1px solid oklch(0.62 0.23 295 / 0.45); box-shadow: 0 0 28px oklch(0.62 0.23 295 / 0.18); }

.order-summary {
  border-color: oklch(0.62 0.23 295 / 0.40);
  background: linear-gradient(135deg, oklch(0.27 0.08 295), var(--surface) 70%);
}
.order-summary .meta { color: var(--link); }
.state-wait .state-icon { box-shadow: 0 0 28px oklch(0.75 0.13 210 / 0.35); }
.state-done .state-icon { box-shadow: 0 0 32px oklch(0.80 0.19 140 / 0.40); }
.state-done h1 { color: var(--delivered-fg); }
.toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
