/* ==========================================================================
   Northstate Supply — asset tag configurator
   Ink-blue and gold identity, rebuilt to hold up on a phone and on a
   keyboard.
   ========================================================================== */

:root {
  --navy: #1c3a5e;
  --navy-deep: #12263e;
  --navy-tint: #eef2f6;
  --accent: #9c6b0a;
  --accent-dark: #7e560a;
  --accent-tint: #f8f0dc;
  --danger: #c0392b;
  --danger-dark: #a5301f;
  --ink: #2b2b2b;
  --muted: #6b7280;
  --faint: #9aa3ad;
  --line: #dcdfe3;
  --paper: #ffffff;
  --shell: #f7f8f9;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 3px rgba(16, 30, 45, .07), 0 8px 24px rgba(16, 30, 45, .06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--shell);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

/* Keyboard focus must always be visible. */
:focus-visible {
  outline: 3px solid #4a90d9;
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--navy); color: #fff;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; top: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 72px; }

/* --- masthead ------------------------------------------------------------ */
.masthead { margin-bottom: 26px; }
.wordmark {
  font-size: 25px; font-weight: 800; color: var(--navy);
  letter-spacing: -.02em; line-height: 1.08;
  display: inline-block; text-decoration: none;
}
.rule { height: 3px; width: 176px; background: var(--accent); margin: 9px 0 13px; }
.tagline { font-size: 15px; color: var(--muted); }

.greeting {
  margin-top: 14px; padding: 11px 15px;
  background: var(--navy-tint); border-left: 3px solid var(--navy);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--navy);
}
.greeting[hidden] { display: none; }

/* --- layout -------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.section { margin-bottom: 26px; }
.section:last-child { margin-bottom: 0; }

.section-title {
  font-size: 12px; font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 0 0 11px;
}

.hint { font-size: 12.5px; color: var(--faint); margin: 6px 0 0; }

/* --- chips --------------------------------------------------------------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 15px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--line); background: var(--paper); color: #444;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--navy); }
.chip[aria-pressed="true"] {
  background: var(--navy); border-color: var(--navy); color: #fff;
}

/* --- material cards ------------------------------------------------------ */
.materials { display: flex; flex-direction: column; gap: 8px; }

.material {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper);
  transition: border-color .12s ease, background .12s ease;
}
.material:hover { border-color: var(--navy); }
.material input { accent-color: var(--navy); margin-top: 3px; flex: none; }
.material:has(input:checked) {
  border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy);
  background: var(--navy-tint);
}
.material-name { font-weight: 600; font-size: 14px; }
.material-desc { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.material-best { font-size: 12.5px; color: var(--navy); margin-top: 3px; }

.badge {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; border-radius: 3px;
  background: var(--navy-tint); color: var(--navy); vertical-align: 1px;
}
.badge.security { background: var(--accent-tint); color: var(--accent); }

/* --- form fields --------------------------------------------------------- */
label.field { display: block; font-size: 13px; color: #555; margin-bottom: 5px; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
textarea,
select {
  font: inherit; font-size: 14px;
  padding: 9px 11px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink);
}
textarea { resize: vertical; min-height: 92px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; min-width: 0; }

.qty-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.qty-row input { width: 150px; flex: none; }

input[type="color"] {
  width: 52px; height: 36px; padding: 2px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); cursor: pointer;
}
.swatch { flex: 0 0 auto; }

/* --- logo upload --------------------------------------------------------- */
.logo-drop {
  display: flex; align-items: center; gap: 13px;
  padding: 13px; border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm); background: #fcfcfd;
}
.logo-drop.dragover { border-color: var(--navy); background: var(--navy-tint); }
.logo-thumb {
  width: 46px; height: 46px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 5px;
  background: #fff; overflow: hidden;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-thumb.empty { color: var(--faint); font-size: 10px; text-align: center; }

.linkish {
  background: none; border: none; padding: 0; font: inherit; font-size: 13px;
  color: var(--navy); text-decoration: underline; cursor: pointer;
}
.linkish.danger { color: var(--danger); }

/* --- preview + price ----------------------------------------------------- */
.sticky { position: sticky; top: 20px; }

.tag-stage {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px 22px;
  display: flex; flex-direction: column; align-items: center;
}

.tag {
  width: 100%; max-width: 340px;
  border: 1px solid #c4c8cc; border-radius: 7px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 6% 7%; overflow: hidden; text-align: center;
}
.tag-logo { max-width: 42%; max-height: 22%; object-fit: contain; margin-bottom: 3%; }
.tag-org { font-weight: 700; line-height: 1.18; word-break: break-word; }
.tag-code { display: flex; gap: 1.5px; align-items: flex-end; margin: 4% 0 2%; flex-shrink: 0; }
.tag-code[hidden] { display: none; }
.tag-code span { background: #111; display: block; }
.tag-qr {
  background: repeating-conic-gradient(#111 0% 25%, transparent 0% 50%) 0 0 / 7px 7px;
  border: 2px solid #111; margin: 4% 0 2%; flex-shrink: 0;
}
.tag-serial { font-family: var(--mono); letter-spacing: .08em; }

/* Banner: a color band across the top, bled to the card's edges, plain body below */
.tag--banner { justify-content: flex-start; }
.tag--banner .tag-org {
  margin: -6% -7% 0; padding: 5% 7% 0;
  border-radius: 6px 6px 0 0;
}
.tag--banner .tag-line2 { margin: 0 -7%; padding: 0 7% 2%; }

/* Minimal: no color, left-aligned — everything else already follows from that */
.tag--minimal { align-items: flex-start; text-align: left; }

/* Logo-forward: the mark leads, the org name shrinks to a caption */
.tag--logo .tag-logo { max-width: 48%; max-height: 30%; margin-bottom: 4%; }
.tag--logo .tag-org { font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Logo left / Logo right: logo and text share a row, barcode/QR/serial stay
   centered below spanning the full width. Grid, not flex, so the logo can
   span both text rows (line1 + line2) while everything below lays out
   normally. Numeric grid-row/grid-column, not named grid-template-areas —
   named areas don't reliably survive being cloned into a standalone SVG
   snapshot for the emailed proof (see captureTagProof() in app.js), numeric
   line placement does. */
.tag--side, .tag--sideRight {
  display: grid;
  align-items: center; column-gap: 6%;
}
.tag--side { grid-template-columns: minmax(0, 38%) 1fr; }
.tag--sideRight { grid-template-columns: 1fr minmax(0, 38%); }

.tag--side .tag-logo, .tag--sideRight .tag-logo {
  /* max-height is set inline by renderPreview() in app.js, not here — a
     row sized to its own content needs an explicit pixel budget, a CSS
     percentage isn't reliable there. See the comment at that assignment. */
  max-width: 100%; margin-bottom: 0; justify-self: center;
  grid-row: 1 / 3;
}
.tag--side .tag-logo { grid-column: 1; }
.tag--sideRight .tag-logo { grid-column: 2; }

.tag--side .tag-org, .tag--sideRight .tag-org { grid-row: 1; }
.tag--side .tag-org { grid-column: 2; text-align: left; }
.tag--sideRight .tag-org { grid-column: 1; text-align: right; }

.tag--side .tag-line2, .tag--sideRight .tag-line2 { grid-row: 2; }
.tag--side .tag-line2 { grid-column: 2; text-align: left; }
.tag--sideRight .tag-line2 { grid-column: 1; text-align: right; }
.tag--sideRight .tag-line2 { grid-column: 1; }

.tag--side .tag-code, .tag--sideRight .tag-code,
.tag--side .tag-qr, .tag--sideRight .tag-qr,
.tag--side .tag-serial, .tag--sideRight .tag-serial { grid-column: 1 / 3; justify-self: center; }

.scale-note {
  margin-top: 13px; font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.price-card {
  margin-top: 18px; padding: 21px;
  background: var(--navy); color: #fff; border-radius: var(--radius);
}
.price-label { font-size: 12.5px; opacity: .78; margin-bottom: 3px; }
.price-big { font-size: 37px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.price-big small { font-size: 16px; font-weight: 400; opacity: .8; }
.price-big.loading { opacity: .45; }

.price-line {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; margin-top: 7px;
}
.price-line.first {
  margin-top: 13px; padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.2);
}
.price-line dt { opacity: .8; margin: 0; }
.price-line dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.price-line.total dd { font-weight: 700; font-size: 18px; }

.price-error {
  margin-top: 13px; padding: 11px 14px;
  background: #fbeae7; border-left: 3px solid var(--danger);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13.5px; color: #7d2418;
}
.price-error[hidden] { display: none; }

.terms {
  margin: 13px 0 0; padding: 0; list-style: none;
  font-size: 12.5px; color: var(--muted);
}
.terms li { padding-left: 15px; position: relative; margin-bottom: 3px; }
.terms li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--faint);
}

/* --- buttons ------------------------------------------------------------- */
.btn {
  font: inherit; font-size: 15px; font-weight: 700;
  width: 100%; padding: 14px 18px; margin-top: 11px;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary {
  background: var(--paper); color: var(--navy);
  border: 1.5px solid var(--navy);
}
.btn-secondary:hover { background: var(--navy-tint); }
.btn-quiet {
  background: none; color: var(--muted); font-weight: 600;
  font-size: 13.5px; padding: 9px; margin-top: 5px;
}
.btn-quiet:hover { color: var(--navy); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- dialog -------------------------------------------------------------- */
dialog {
  border: none; border-radius: var(--radius); padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(16, 30, 45, .28);
  color: var(--ink);
}
dialog::backdrop { background: rgba(16, 30, 45, .5); }

.dialog-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; padding: 20px 22px 0;
}
.dialog-head h2 { margin: 0; font-size: 19px; color: var(--navy); }
.dialog-head p { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); }
.dialog-body { padding: 18px 22px 22px; }
.dialog-body .section { margin-bottom: 15px; }
.close-x {
  background: none; border: none; cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--faint); padding: 0 4px;
}
.close-x:hover { color: var(--ink); }

.form-status { font-size: 13.5px; margin-top: 11px; }
.form-status.error { color: var(--danger); }
.form-status.ok { color: #1d7a4c; }

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

.success-note {
  padding: 18px; background: #edf7f1;
  border-left: 3px solid #1d7a4c; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.success-note h3 { margin: 0 0 6px; font-size: 16px; color: #1d7a4c; }
.success-note p { margin: 0; font-size: 14px; }

/* --- footer -------------------------------------------------------------- */
.foot {
  margin-top: 42px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--faint);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.foot a { color: var(--muted); }

/* --- phones -------------------------------------------------------------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .sticky { position: static; }
  .wrap { padding: 20px 15px 56px; }
  .panel { padding: 17px; }
  .price-big { font-size: 33px; }
  /* Price and preview above the options on a phone, so the number is the
     first thing seen rather than the last. */
  .col-summary { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  body { background: #fff; }
  .btn, .foot, .greeting { display: none; }
}

/* ==========================================================================
   Additions: numbering, proof approval, sharing, resolution warnings
   ========================================================================== */

.warn {
  margin: 9px 0 0; padding: 9px 12px;
  background: #fdf4e3; border-left: 3px solid #c98a12;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px; color: #7a5405;
}
.warn[hidden] { display: none; }
.warn.bad { background: #fbeae7; border-left-color: var(--danger); color: #7d2418; }
.warn.good { background: #edf7f1; border-left-color: #1d7a4c; color: #14603a; }

/* --- extra batches -------------------------------------------------------- */
.batch-row {
  position: relative;
  padding: 13px 40px 13px 13px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper);
}
.batch-row .row { gap: 10px; }
.batch-row .field { font-size: 12px; margin-bottom: 4px; }
.batch-remove {
  position: absolute; top: 10px; right: 10px;
  width: 24px; height: 24px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer;
}
.batch-remove:hover { border-color: var(--danger); color: var(--danger); }

/* --- checkboxes ---------------------------------------------------------- */
.check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 14px; cursor: pointer; line-height: 1.45;
}
.check[hidden] { display: none; }
.check + .check { margin-top: 11px; }
.check input { accent-color: var(--navy); margin-top: 2px; flex: none; }

.rush-check {
  margin-top: 13px; padding: 11px 13px;
  background: var(--accent-tint); border-radius: var(--radius-sm);
}
.rush-check #rushPct { color: var(--accent); }

#serialFields[hidden] { display: none; }

/* --- proof --------------------------------------------------------------- */
.proof-stage {
  display: flex; justify-content: center;
  padding: 22px 18px; margin-bottom: 16px;
  background: var(--shell); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.proof-stage .tag { max-width: 300px; }

.spec {
  margin: 0 0 16px; padding: 0;
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 16px; font-size: 13.5px;
}
.spec dt { color: var(--muted); }
.spec dd { margin: 0; font-weight: 600; }

.proof-checks {
  padding: 14px; margin-bottom: 4px;
  background: var(--navy-tint); border-radius: var(--radius-sm);
}

/* Applied to a checked-but-not-yet-filled-in optional field block (tax
   exempt, give-back) — a quiet nudge for why "Approve and continue" is
   still disabled, not a hard error since they haven't tried to submit yet. */
.incomplete {
  border-left: 3px solid var(--danger);
  padding-left: 10px;
  margin-left: -13px;
}

/* --- share --------------------------------------------------------------- */
.share-box {
  margin-top: 13px; padding: 14px;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.share-box[hidden] { display: none; }
.share-label {
  margin: 0 0 8px; font-size: 12px; font-weight: 700;
  color: var(--navy); text-transform: uppercase; letter-spacing: .05em;
}
.share-row { display: flex; gap: 7px; }
.share-row input { font-size: 13px; font-family: var(--mono); }
.share-row .chip { flex: none; }

/* ==========================================================================
   Additions: custom size, second tag line, best-seller badge
   ========================================================================== */

.tag-line2 {
  font-size: 78%; font-weight: 500; opacity: .85;
  line-height: 1.2; word-break: break-word; margin-top: -2%;
}

.badge.best-seller {
  background: var(--accent); color: #fff;
}

#customSizeFields .row { margin-bottom: 4px; }
