/* ===========================================================================
   Cerakote quote builder.

   Rendered in two places with opposite backgrounds: the public Cerakote page is
   a dark section, the admin is a light one. So this file carries its OWN
   palette rather than borrowing tokens from whichever stylesheet happens to be
   loaded — site.css and admin.css both define --graphite, but admin.css has no
   --titanium at all, and --line means a white hairline in one and a black one
   in the other. Depending on those produced dark panels floating in the light
   admin with text that fell back to whatever it inherited.

   Everything below therefore references --est-* only. `.est` is the dark
   default; `.est--light` flips the same tokens for the admin. Nothing here is
   global and nothing leaks out.

   The original module Andy sent came with its own look — rounded cards, blue
   gradients, system fonts. That is replaced rather than imported, so the tool
   reads as part of the site instead of an embedded app.
   =========================================================================== */

.est,
.est-send {
  --est-bg: #17181A;
  --est-panel: #202226;
  --est-line: rgba(255, 255, 255, 0.12);
  --est-text: #E5E6E3;
  --est-muted: #9A9D9F;
  --est-strong: #FFFFFF;
  --est-accent: #3275A8;
  --est-accent-text: #6FA3CE;   /* legends and links, on the dark panel */
  --est-accent-deep: #275C82;   /* hover fills and selected swatches */
  --est-on-accent: #FFFFFF;
  --est-chip-edge: rgba(255, 255, 255, 0.22);
  --est-check-shadow: rgba(0, 0, 0, 0.9);

  color: var(--est-text);
}

/* Light surface, for the admin. Muted and accent text are darkened rather than
   reused — #9A9D9F and #6FA3CE both fall under 3:1 on white, which is where
   "hard to read" starts. */
.est--light,
.est-send--light {
  --est-bg: #FFFFFF;
  --est-panel: #F4F5F2;
  --est-line: rgba(0, 0, 0, 0.13);
  --est-text: #17181A;
  --est-muted: #4B4E51;
  --est-strong: #17181A;
  --est-accent: #3275A8;
  --est-accent-text: #275C82;
  --est-accent-deep: #275C82;
  --est-on-accent: #FFFFFF;
  --est-chip-edge: rgba(0, 0, 0, 0.28);
  --est-check-shadow: rgba(0, 0, 0, 0.55);
}

.est-noscript {
  border: 1px solid var(--est-line);
  padding: 18px;
  font-size: 14.5px;
  color: var(--est-muted);
}
.est-noscript a { color: var(--est-accent-text); }

.est-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1px;
  background: var(--est-line);
  border: 1px solid var(--est-line);
}
.est-build,
.est-summary { background: var(--est-bg); padding: 26px; }

/* ---- category tabs ---- */

.est:not(.est-js) .est-tabs { display: none; }
.est-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin-bottom: 22px;
  background: var(--est-line);
  border: 1px solid var(--est-line);
}
.est-tab {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 14px;
  background: var(--est-bg);
  color: var(--est-muted);
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
}
.est-tab:hover { color: var(--est-text); background: var(--est-panel); }
.est-tab.is-on { background: var(--est-accent); color: var(--est-on-accent); }
.est-tab:focus-visible { outline: 2px solid var(--est-accent-text); outline-offset: -2px; }

/* ---- item lists ---- */

/* Only collapse to tabs once JS is driving. Without it the tabs cannot work,
   so every category stays visible rather than stranding the visitor on the
   first one. */
.est-js .est-panel:not(.is-on) { display: none; }
.est-panel { border: 0; padding: 0; margin: 0 0 22px; }

.est-legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--est-accent-text);
}

/* The admin styles every <label> as a small-caps field label. The item rows
   and swatches ARE labels, so without this they render as uppercase headings
   rather than as choices. Reset inside the builder only. */
.est label {
  /* Deliberately NOT setting display: this selector out-specifies .est-item and
     .est-swatch, which need their own grid/flex. */
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
  margin: 0;
}
.est-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--est-line);
  cursor: pointer;
  font-size: 14.5px;
}
.est-item:last-child { border-bottom: 0; }
.est-item:hover .est-item-name { color: var(--est-strong); }
.est-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--est-accent);
  cursor: pointer;
  margin: 0;
}
.est-item-name { color: var(--est-text); min-width: 0; }
.est-item-price { color: var(--est-muted); font-size: 13.5px; white-space: nowrap; }
.est-sub { color: var(--est-muted); font-size: 12.5px; }
.est-quoted {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--est-accent-text);
}

/* ---- finish options ---- */

.est-finish { border-top: 1px solid var(--est-line); padding-top: 20px; }

.est-colors {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 11px 2px;
  border-bottom: 1px solid var(--est-line);
}
.est-colors-label { flex: 1 1 auto; font-size: 14.5px; }
.est-colors-rate { color: var(--est-muted); font-size: 13.5px; }

.est-stepper { display: flex; align-items: center; border: 1px solid var(--est-line); }
.est-stepper button {
  width: 34px;
  height: 32px;
  background: var(--est-panel);
  color: var(--est-text);
  border: 0;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.est-stepper button:hover { background: var(--est-accent-deep); color: var(--est-on-accent); }
.est-stepper button:focus-visible { outline: 2px solid var(--est-accent-text); outline-offset: -2px; }
.est-stepper output {
  min-width: 42px;
  text-align: center;
  font-size: 14px;
  color: var(--est-text);
}

.est-hint { font-size: 12.5px; color: var(--est-muted); margin: 8px 0 0; }

.est-add { margin-top: 20px; }
.est-add .btn { width: 100%; }

/* ---- color swatches ----
   A grid of stocked Cerakote codes. The chip is an approximation of the real
   finish and the copy says so — a screen cannot promise a color match, and
   implying one is how a customer ends up disappointed at collection. */
.est-colorpick { border-top: 1px solid var(--est-line); padding-top: 20px; }
.est-swatch-intro { margin-bottom: 12px; }

.est-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 1px;
  background: var(--est-line);
  border: 1px solid var(--est-line);
}
.est-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 4px 7px;
  background: var(--est-bg);
  cursor: pointer;
}
.est-swatch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.est-swatch-chip {
  width: 100%;
  height: 30px;
  border: 1px solid var(--est-chip-edge);
}
.est-swatch-code { font-size: 11px; color: var(--est-muted); letter-spacing: 0.02em; }
.est-swatch:hover { background: var(--est-panel); }
.est-swatch:hover .est-swatch-code { color: var(--est-text); }

/* Selection has to read without relying on color alone, since the thing being
   selected IS a color — hence the outline, the tint and the check together. */
.est-swatch:has(input:checked) { background: var(--est-accent-deep); }
.est-swatch:has(input:checked) .est-swatch-chip { outline: 2px solid var(--est-on-accent); outline-offset: -1px; }
.est-swatch:has(input:checked) .est-swatch-code { color: var(--est-on-accent); font-weight: 700; }
.est-swatch:has(input:checked)::after {
  content: "\2713";
  position: absolute;
  top: 10px;
  right: 7px;
  font-size: 13px;
  line-height: 1;
  color: var(--est-on-accent);
  text-shadow: 0 0 3px var(--est-check-shadow);
}
.est-swatch:focus-within { outline: 2px solid var(--est-accent-text); outline-offset: -2px; }

/* ---- running total ---- */

.est-summary { align-self: start; position: sticky; top: 90px; }
.est-summary-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--est-accent-text);
  margin-bottom: 14px;
}
.est-empty { color: var(--est-muted); font-size: 13.5px; }

.est-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--est-line);
  font-size: 13.5px;
}
.est-line-text { color: var(--est-text); }
.est-line-amt { color: var(--est-text); white-space: nowrap; }
.est-line-remove {
  background: none;
  border: 0;
  color: var(--est-muted);
  font-size: 17px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.est-line-remove:hover { color: var(--est-strong); }

.est-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--est-accent);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--est-muted);
}
.est-total strong { font-size: 25px; color: var(--est-strong); letter-spacing: 0; text-transform: none; }

.est-smallprint { margin-top: 14px; font-size: 12px; line-height: 1.55; color: var(--est-muted); }

/* ---- the enquiry form under the public build ---- */

.est-send {
  margin-top: 1px;
  background: var(--est-bg);
  border: 1px solid var(--est-line);
  border-top: 0;
  padding: 26px;
  color: var(--est-text);
}
.est-send h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--est-accent-text);
  margin-bottom: 6px;
}
.est-send-lead { color: var(--est-muted); font-size: 13.5px; margin-bottom: 16px; max-width: 60ch; }

/* ---- staff-only additions ---- */

.est-staff { margin-top: 22px; border-top: 1px solid var(--est-line); padding-top: 18px; }
.est-saved-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--est-line);
  font-size: 13px;
}

@media (max-width: 920px) {
  .est-grid { grid-template-columns: 1fr; }
  .est-summary { position: static; }
}

@media (max-width: 600px) {
  .est-build, .est-summary, .est-send { padding: 18px; }
  .est-tab { flex: 1 1 100%; }
  .est-item { grid-template-columns: auto 1fr; row-gap: 2px; }
  .est-item-price { grid-column: 2; justify-self: start; }
  .est-swatches { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}

/* ===========================================================================
   The printed quote — a branded document, not a printed web page.

   @page margin is ZERO on purpose. Browsers draw their own header and footer
   (tab title, URL, date, page numbers) in the page margin, and there is no CSS
   switch to turn that off — but with no margin there is nowhere to draw it, so
   it disappears. The real page margins then come from padding inside the
   document, which also lets the masthead and footer bleed to the paper edge
   the way a designed PDF does.

   print-color-adjust is set because browsers drop background colours when
   printing by default. Everything here is still legible without them: the
   masthead text would simply go dark on white rather than white on dark.
   =========================================================================== */

.qdoc { display: none; }

@media print {
  /* Hide the app, show the document. #quote-doc is a direct child of the
     admin's .a-wrap, so the sibling selector reaches everything else. */
  .a-head,
  .a-main > .a-wrap > *:not(#quote-doc),
  body > footer { display: none !important; }

  .a-main, .a-main > .a-wrap {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    background: #fff !important;
  }

  @page { size: letter; margin: 0; }

  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }

  .qdoc {
    display: block;
    color: #17181A;
    font-family: 'Inter', sans-serif;
    font-size: 10pt;
    line-height: 1.45;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* ---- masthead ---- */

  .qdoc-band { background: #17181A; color: #E5E6E3; padding: 8mm 14mm 7mm; }
  .qdoc-band-in {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16mm;
  }
  .qdoc-id { display: flex; align-items: center; gap: 5mm; }
  .qdoc-logo { width: 13mm; height: auto; display: block; }
  .qdoc-brand {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 25pt;
    line-height: 0.95;
    letter-spacing: 0.02em;
    color: #fff;
  }
  .qdoc-tag {
    font-size: 7.5pt;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #9A9D9F;
    margin-top: 1.5mm;
  }
  .qdoc-contact { text-align: right; font-size: 8.5pt; line-height: 1.5; color: #C9CBC8; }
  .qdoc-contact p + p { margin-top: 2.5mm; }

  .qdoc-rule-accent { height: 2mm; background: #3275A8; }

  /* ---- body ---- */

  /* Bottom padding reserves the strip the fixed footer occupies, so content
     can never slide underneath it. */
  .qdoc-body { padding: 7mm 14mm 20mm; }

  .qdoc-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12mm;
    padding-bottom: 4mm;
    border-bottom: 0.4mm solid #17181A;
  }
  .qdoc-title h2 { font-size: 16pt; letter-spacing: -0.01em; line-height: 1.1; }
  .qdoc-subtitle {
    font-size: 7.5pt;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #6B7075;
    margin-top: 1.5mm;
  }
  .qdoc-stamp { border-collapse: collapse; font-size: 9pt; }
  .qdoc-stamp th {
    text-align: right;
    font-weight: 400;
    color: #6B7075;
    padding: 0.6mm 3mm 0.6mm 0;
    font-size: 7.5pt;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .qdoc-stamp td { text-align: right; padding: 0.6mm 0; white-space: nowrap; }

  .qdoc h3 {
    font-size: 7.5pt;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #3275A8;
    margin-bottom: 2mm;
  }

  .qdoc-party { margin: 4.5mm 0 5mm; }
  .qdoc-kv { border-collapse: collapse; width: 100%; }
  .qdoc-kv th {
    text-align: left;
    font-weight: 400;
    width: 24mm;
    padding: 0.8mm 0;
    vertical-align: top;
    font-size: 8.5pt;
    color: #6B7075;
  }
  .qdoc-kv td { padding: 0.8mm 0; vertical-align: top; }

  /* ---- line items ---- */

  .qdoc-items { width: 100%; border-collapse: collapse; }
  .qdoc-items thead th {
    text-align: left;
    font-size: 7.5pt;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: #17181A;
    color: #fff;
    padding: 2.2mm 3mm;
  }
  .qdoc-items thead th:last-child { text-align: right; }
  .qdoc-items tbody td {
    padding: 2.6mm 3mm;
    border-bottom: 0.2mm solid #D8DAD6;
    vertical-align: top;
  }
  .qdoc-items tbody tr:nth-child(even) td { background: #F4F5F2; }
  .qdoc-amt { text-align: right; white-space: nowrap; font-family: 'IBM Plex Mono', monospace; }

  .qdoc-totalrow {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8mm;
    margin-top: 3mm;
    padding: 3mm 3mm 0;
    border-top: 0.6mm solid #17181A;
    font-size: 8.5pt;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #6B7075;
  }
  .qdoc-totalrow strong {
    font-size: 17pt;
    color: #17181A;
    letter-spacing: 0;
    text-transform: none;
  }

  .qdoc-quoted { font-size: 8.5pt; color: #6B7075; margin-top: 3mm; padding: 0 3mm; }

  /* ---- terms and signatures ---- */

  .qdoc-terms { margin-top: 6mm; }
  .qdoc-terms p { font-size: 7.5pt; line-height: 1.5; color: #4B4E51; margin-bottom: 2mm; }

  .qdoc-ack { font-size: 8.5pt; margin: 4mm 0 7mm; }

  .qdoc-sign { display: grid; grid-template-columns: 1fr 42mm; gap: 8mm 9mm; }
  .qdoc-rule { display: block; border-bottom: 0.3mm solid #17181A; height: 7.5mm; }
  .qdoc-sign-label {
    display: block;
    margin-top: 1.5mm;
    font-size: 7pt;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6B7075;
  }

  /* ---- footer ---- */

  .qdoc-foot {
    display: flex;
    justify-content: space-between;
    gap: 8mm;
    /* Fixed to the page box, NOT pushed down by the layout.
    
       The previous approach made the document a 100vh flex column, which put
       the footer on the bottom edge when saving to PDF and left it stranded
       partway up on a real printer: a printer uses its own paper (A4 rather
       than the letter we ask for) and scales to its printable area, so the
       sheet is not the page we laid out for. Fixed positioning is measured
       against the page box the browser actually produced, so it lands on the
       bottom edge whatever the paper turns out to be. */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3.5mm 14mm;
    background: #F4F5F2;
    border-top: 0.2mm solid #D8DAD6;
    font-size: 7.5pt;
    color: #6B7075;
  }

  .qdoc-terms, .qdoc-ack, .qdoc-sign, .qdoc-totalrow { break-inside: avoid; }

  /* A long quote runs to a second page, where a zero page margin means content
     starts hard against the paper edge. The items table repeating its dark
     header row softens that and reads as deliberate. Adding top padding to the
     terms and signature blocks would soften it further, but at the cost of
     height on EVERY quote to improve a second page most quotes never reach —
     so it is left off. */
  .qdoc-items thead { display: table-header-group; }
  .qdoc-items tbody tr { break-inside: avoid; }
  .qdoc-band, .qdoc-foot { break-inside: avoid; }
}
