/* ============================================================
   TCG.SG Giveaway — app.css
   Public entry pages + admin console
   ============================================================ */
:root {
  --rose: #e11d48;
  --rose-dark: #be123c;
  --ink: #0f172a;
  --body: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 24px rgba(15,23,42,.06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--body);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
}
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
a { color: var(--rose); }
code {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 6px; font-size: .92em;
}

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 18px; }
.main { padding-top: 26px; padding-bottom: 40px; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page .site-foot { margin-top: auto; }

/* ---------- Public header / footer ---------- */
.site-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--rose); color: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .03em;
}
.brand-name { font-size: 1.02rem; }

.site-foot { background: #0f172a; color: #cbd5e1; padding: 22px 0; margin-top: 30px; }
.site-foot .disclaimer { font-weight: 600; color: #e2e8f0; margin: 0 0 8px; font-size: .9rem; }
.site-foot .fineprint { font-size: .82rem; color: #94a3b8; margin: 0 0 10px; }
.site-foot .copyright { font-size: .8rem; color: #64748b; margin: 0; }

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { font-size: 1.8rem; }
.lede { color: var(--muted); font-size: 1.04rem; margin: .4em 0 0; }
.deadline-note { margin: 12px 0 0; font-size: .92rem; color: var(--body); }
.deadline-note strong { color: var(--rose-dark); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 0 0 18px;
}

/* ---------- Forms ---------- */
.form .field, .field { margin-bottom: 16px; }
.field > label, .field > span:first-child { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: .94rem; }
.req { color: var(--rose); }
.opt { color: var(--muted); font-weight: 400; font-size: .85em; }
.hint { display: block; color: var(--muted); font-size: .82rem; margin-top: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 11px 12px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 92px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(225,29,72,.15);
}
.field-err { display: block; color: var(--err); font-size: .85rem; margin-top: 5px; }

.radios { display: flex; flex-wrap: wrap; gap: 10px; }
.radio, .check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.radio { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 14px; }
.radio input, .check input { width: auto; accent-color: var(--rose); }
.check { align-items: flex-start; }
.check span { font-size: .95rem; }

/* honeypot */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  padding: 10px 18px; border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn-primary:hover { background: var(--rose-dark); border-color: var(--rose-dark); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--body); }
.btn-block { width: 100%; padding: 13px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; font-size: .88rem; }
.btn-xs { padding: 5px 9px; font-size: .8rem; }

/* ---------- Notes ---------- */
.note { border-radius: var(--radius-sm); padding: 13px 15px; margin: 0 0 18px; font-size: .94rem; border: 1px solid transparent; }
.note p { margin: 6px 0 0; }
.note-err { background: var(--err-bg); border-color: #fecaca; color: #991b1b; }
.note-warn { background: var(--warn-bg); border-color: #fde68a; color: #92400e; }
.note-ok { background: var(--ok-bg); border-color: #bbf7d0; color: #166534; }

/* ---------- Success page ---------- */
.success-badge {
  display: inline-grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok);
  font-size: 34px; margin-bottom: 12px; border: 2px solid #bbf7d0;
}
.summary .stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1 1 140px; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; text-align: center; }
.stat-num { display: block; font-size: 2rem; font-weight: 800; color: var(--rose-dark); line-height: 1; }
.stat-label { display: block; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.accepted { margin: 16px 0 0; font-size: .95rem; }
.accepted code { margin-right: 4px; }
.cta { text-align: center; }
.cta h2 { color: var(--rose-dark); }
.cta .btn { margin: 6px 0; }
.back { text-align: center; }

/* ============================================================
   ADMIN
   ============================================================ */
body.admin { background: var(--bg); }
.admin-head { background: var(--ink); color: #e2e8f0; }
.admin-head-in { display: flex; align-items: center; gap: 18px; padding: 12px 18px; flex-wrap: wrap; }
.admin-head .brand { color: #fff; }
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; }
.admin-nav a { color: #cbd5e1; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: .92rem; }
.admin-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-nav a.is-active { background: var(--rose); color: #fff; }
.admin-user { display: flex; align-items: center; gap: 12px; }
.admin-user .muted { color: #94a3b8; text-decoration: none; }
.admin-main { max-width: 1100px; padding-top: 24px; padding-bottom: 50px; }
.admin-foot { border-top: 1px solid var(--line); padding: 16px 0; }

/* admin uses a wider wrap */
.admin .wrap { max-width: 1100px; }

/* metrics */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.metric-num { display: block; font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1; }
.metric-label { display: block; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.metric-accent { background: var(--rose); border-color: var(--rose); }
.metric-accent .metric-num, .metric-accent .metric-label { color: #fff; }

/* actions / chips */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.actions-tight { gap: 6px; margin-top: 6px; }
.actions form { display: inline; margin: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; background: #f1f5f9; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: .85rem; text-decoration: none; color: var(--body); }
.chip:hover { background: #e2e8f0; }

/* generate */
.form-inline { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-inline .field { margin-bottom: 0; }
.form-inline .field input, .form-inline .field select { min-width: 150px; }
.codeblock { font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: .9rem; margin-top: 12px; background: #f8fafc; }

/* filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.filter-bar input, .filter-bar select { width: auto; flex: 1 1 160px; }
.filter-bar .btn { flex: 0 0 auto; }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .76rem; font-weight: 700; text-transform: capitalize; }
.badge-unused { background: #eff6ff; color: #1d4ed8; }
.badge-used { background: var(--ok-bg); color: #166534; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }

.copyable { cursor: pointer; user-select: all; }
.copyable:hover { border-color: var(--rose); }
.copyable.copied { background: var(--ok-bg); border-color: #86efac; color: #166534; }
.codelist { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.codelist code { font-size: .78rem; }

.nowrap { white-space: nowrap; }
.small { font-size: .85rem; }
.center { text-align: center; }
.muted { color: var(--muted); }

/* pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }

/* login */
body.admin-login { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 24px; }
.login-card { text-align: center; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 18px; }
.login-card .field { text-align: left; }
.login-brand { margin-bottom: 14px; }
.login-brand .brand-mark { width: 46px; height: 46px; font-size: 15px; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 1.55rem; }
  .card { padding: 18px; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline .field input, .form-inline .field select { width: 100%; }
  .admin-nav { width: 100%; order: 3; }
  .admin-user { margin-left: auto; }
}
