/* The reseller portal (v0.17.0). Same look as the app (frontend/css/style.css):
   the same colours, fonts, buttons, fields and boxes, copied here because
   the portal is served from its own folder. */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dde1e6;
  --text: #1f2430;
  --muted: #667085;
  --primary: #2f5fd8;
  --primary-hover: #24499f;
  --danger: #c0392b;
  --danger-bg: #fbeae8;
  --success-bg: #eafaf1;
  --success-text: #1e7e45;
  --info-bg: #eef3fd;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* `hidden` always wins over any display rule below (see the app's style.css). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---- Top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; white-space: nowrap; }
.brand-sub { font-weight: 400; color: var(--muted); }

.topbar-user {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

.topbar-sep { color: var(--border); }

/* ---- Layout and text ---- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.screen h1 { margin-top: 0; font-size: 1.5rem; }

.screen h2 {
  font-size: 1.1rem;
  margin: 2rem 0 0.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.muted { color: var(--muted); font-size: 0.92rem; }
.small { font-size: 0.85rem; }

.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
}

/* ---- Forms ---- */

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

form h2 { margin-top: 1rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"] {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  max-width: 28rem;
}

input[readonly] { background: var(--bg); color: var(--muted); }

input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.code-input {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 1.4rem;
  letter-spacing: 0.3em;
  max-width: 10rem;
}

/* Show / hide password (js/portal.js wraps each password field). */
.password-wrap { position: relative; display: flex; max-width: 28rem; }
.password-wrap input { flex: 1 1 auto; min-width: 0; padding-right: 2.6rem; }
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.password-toggle svg { width: 1.2rem; height: 1.2rem; }

/* ---- Buttons ---- */

.button-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.25rem; }

.btn {
  font: inherit;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: #f0f1f3; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---- Boxes ---- */

.error-box,
.info-box,
.success-box {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  max-width: 40rem;
}
.error-box { background: var(--danger-bg); color: var(--danger); }
.info-box { background: var(--info-bg); color: var(--text); margin-bottom: 1rem; }
.success-box { background: var(--success-bg); color: var(--success-text); margin-bottom: 1rem; }

/* ---- Setup: QR code and key ---- */

.qr-row { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.qr {
  flex: 0 0 auto;
  width: 220px;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr-side { flex: 1 1 16rem; }
.qr-side p { margin-top: 0; }

.credential-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.credential-value {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 1.05rem;
  word-break: break-all;
  margin-bottom: 0.6rem;
  user-select: all;
}

/* ---- Account details ---- */

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.25rem;
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
}
.details dt { color: var(--muted); }
.details dd { margin: 0; word-break: break-word; }

/* ---- Idle warning ---- */

.idle-warning {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 30;
  width: max-content;
  max-width: calc(100% - 2rem);
}
.idle-warning p { margin: 0; font-size: 0.92rem; }
.idle-warning .btn { white-space: nowrap; }

@media (max-width: 560px) {
  .topbar { padding: 0.6rem 1rem; align-items: flex-start; }
  .topbar-user { font-size: 0.82rem; }
  .idle-warning { left: 1rem; right: 1rem; transform: none; width: auto; justify-content: space-between; }
  .qr { width: 200px; height: 200px; }
  .details { grid-template-columns: 1fr; gap: 0 0; }
  .details dd { margin-bottom: 0.5rem; }
}

/* =====================================================================
   v0.18.0: navigation, Terms, buying, vouchers, purchases, printing
   ===================================================================== */

.main-nav { display: flex; gap: 0.25rem; flex: 1 1 auto; margin-left: 1rem; }
.nav-link {
  font: inherit;
  font-size: 0.92rem;
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--primary); background: var(--info-bg); font-weight: 600; }

.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
}
.footer a { color: var(--muted); }

.checkbox-row,
.radio-row {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
}
.checkbox-row input,
.radio-row input { margin-top: 0.3rem; flex: 0 0 auto; }

.warning-box {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: #fff6e0;
  border: 1px solid #f1d38a;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.mono { font-family: "SF Mono", Consolas, monospace; }

/* ---- products ---- */

.product-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.product-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.product-main h3 { margin: 0 0 0.2rem; font-size: 1.05rem; }
.product-main p { margin: 0; }
.product-prices { text-align: right; }
.price { font-size: 1.15rem; font-weight: 600; }
.product-buy { grid-column: 1 / -1; }
.buy-form { flex-direction: row; align-items: flex-end; gap: 0.75rem; margin-top: 0; }
.quantity-label input { width: 6rem; font: inherit; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); }
.buy-confirm { padding: 0.75rem 0.9rem; background: var(--info-bg); border-radius: var(--radius); }
.buy-confirm p { margin: 0 0 0.5rem; }
.product-buy .error-box { margin-top: 0.75rem; }

/* ---- vouchers screen ---- */

.layout-choice { border: none; padding: 0; margin: 0.5rem 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.layout-choice legend { padding: 0; margin-bottom: 0.4rem; }

.code-table { border-collapse: collapse; width: 100%; font-size: 0.92rem; margin-top: 0.5rem; }
.code-table th, .code-table td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
.code-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
#voucherCodes td.mono { font-size: 1rem; letter-spacing: 0.03em; }

/* ---- purchases ---- */

.purchase-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.purchase-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.purchase-summary {
  display: grid;
  grid-template-columns: 10.5rem 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-size: 0.92rem;
}
.p-date { color: var(--muted); }
.p-total { font-weight: 600; }
.purchase-body { padding: 0 1rem 1rem; }
.badge { font-size: 0.78rem; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.badge-completed { background: var(--success-bg); color: var(--success-text); }
.badge-pending { background: #fff6e0; color: #8a5a00; }
.badge-cancelled { background: var(--bg); color: var(--muted); }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .main-nav { order: 3; flex-basis: 100%; margin-left: -0.5rem; }
  .product-card { grid-template-columns: 1fr; }
  .product-prices { text-align: left; }
  .purchase-summary { grid-template-columns: 1fr auto; }
  .p-what { grid-column: 1 / -1; grid-row: 2; }
}

/* ---- printing: only the vouchers ---- */

#printArea { display: none; }

@media print {
  body > *:not(#printArea) { display: none !important; }
  body { background: #fff; }
  #printArea { display: block; color: #000; font-family: Arial, Helvetica, sans-serif; }

  .voucher { break-inside: avoid; page-break-inside: avoid; }
  .v-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 0.3mm solid #000; padding-bottom: 1mm; }
  .v-brand { font-weight: 700; letter-spacing: 0.04em; }
  .v-kind { text-transform: uppercase; letter-spacing: 0.08em; }
  .v-product { font-weight: 700; }
  .v-code-label { text-transform: uppercase; letter-spacing: 0.08em; color: #444; }
  .v-code { font-family: "Courier New", Courier, monospace; font-weight: 700; white-space: nowrap; }
  .v-steps { margin: 0; padding-left: 1.2em; }
  .v-foot { color: #444; border-top: 0.2mm solid #999; }

  /* A4, 8 per sheet: 2 x 4 cards of 90 x 65 mm with dashed cutting lines. */
  .print-a4grid { display: grid !important; grid-template-columns: 95mm 95mm; grid-auto-rows: 68mm; gap: 0; }
  .print-a4grid .voucher { border: 0.3mm dashed #888; padding: 3.5mm 4.5mm; font-size: 8pt; line-height: 1.3; overflow: hidden; }
  .print-a4grid .voucher:nth-child(8n) { break-after: page; page-break-after: always; }
  .print-a4grid .v-brand { font-size: 11pt; }
  .print-a4grid .v-kind { font-size: 6.5pt; }
  .print-a4grid .v-product { font-size: 10pt; margin-top: 1.5mm; }
  .print-a4grid .v-code-label { font-size: 6.5pt; margin-top: 2mm; }
  .print-a4grid .v-code { font-size: 11.5pt; }
  .print-a4grid .v-expiry { font-size: 8pt; margin-top: 0.5mm; }
  .print-a4grid .v-steps { margin-top: 1.5mm; font-size: 7pt; }
  .print-a4grid .v-foot { font-size: 6pt; margin-top: 1.5mm; padding-top: 1mm; }

  /* A4, one per page: a large card at the top of each page. */
  .print-a4page .voucher { border: 0.4mm solid #000; padding: 10mm 12mm; font-size: 12pt; line-height: 1.45; break-after: page; page-break-after: always; }
  .print-a4page .voucher:last-child { break-after: auto; page-break-after: auto; }
  .print-a4page .v-brand { font-size: 20pt; }
  .print-a4page .v-kind { font-size: 10pt; }
  .print-a4page .v-product { font-size: 18pt; margin-top: 6mm; }
  .print-a4page .v-code-label { font-size: 10pt; margin-top: 10mm; }
  .print-a4page .v-code { font-size: 22pt; padding: 3mm 0; }
  .print-a4page .v-expiry { font-size: 13pt; }
  .print-a4page .v-steps { margin-top: 8mm; font-size: 12pt; }
  .print-a4page .v-foot { font-size: 9pt; margin-top: 10mm; padding-top: 2mm; }

  /* 80 mm receipt roll: 72 mm wide, one voucher per "page" (the printer cuts between them). */
  .print-receipt .voucher { width: 72mm; font-size: 8.5pt; line-height: 1.35; break-after: page; page-break-after: always; }
  .print-receipt .voucher:last-child { break-after: auto; page-break-after: auto; }
  .print-receipt .v-brand { font-size: 13pt; }
  .print-receipt .v-kind { font-size: 7pt; }
  .print-receipt .v-product { font-size: 10.5pt; margin-top: 2mm; }
  .print-receipt .v-code-label { font-size: 7pt; margin-top: 3mm; }
  .print-receipt .v-code { font-size: 10.5pt; }
  .print-receipt .v-expiry { font-size: 8.5pt; margin-top: 1mm; }
  .print-receipt .v-steps { margin-top: 2.5mm; font-size: 8pt; }
  .print-receipt .v-foot { font-size: 7pt; margin-top: 3mm; padding-top: 1mm; }
}

/* A pending purchase in Purchases (v0.18.0): confirm or cancel it there. */
.pending-actions { display: flex; flex-direction: column; gap: 0.6rem; margin: 0 0 0.75rem; }
.pending-actions p { margin: 0; }
