/* ==========================================================================
   Quotation page — configurator + quotation document
   ========================================================================== */
.qt-layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 36px; align-items: start; }
.qt-card {
  background: var(--paper-0); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-md);
}
.qt-step { padding: 20px 0; border-bottom: 1px solid var(--line); }
.qt-step:first-child { padding-top: 0; }
.qt-step:last-of-type { border-bottom: none; }
.qt-step h4 { display: flex; align-items: center; gap: 10px; font-size: 0.98rem; margin-bottom: 12px; }
.qt-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--blue-500); color: #fff;
  display: grid; place-items: center; font-family: var(--font-head); font-size: 0.78rem; font-weight: 700; flex-shrink: 0;
}
.qt-step .sub-label { font-size: 0.8rem; font-weight: 600; color: var(--ink-500); margin: 14px 0 8px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; max-width: 100%; }
.chip span { max-width: 100%; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: block; padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--paper-50); color: var(--ink-700);
  font-size: 0.9rem; transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.chip span small { display: block; font-size: 0.74rem; font-weight: 400; color: var(--ink-500); margin-top: 3px; line-height: 1.4; }
#optType { flex-direction: column; }
#optType .chip span { width: 100%; }
.chip:hover span { border-color: var(--blue-400); }
.chip input:checked + span { background: var(--blue-500); border-color: var(--blue-500); color: #fff; box-shadow: var(--shadow-sm); }
.chip input:checked + span small { color: rgba(255,255,255,.85); }
.chip input:focus-visible + span { outline: 2px solid var(--blue-400); outline-offset: 2px; }

.qt-field { margin-bottom: 12px; }
.qt-field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-700); margin-bottom: 6px; }
.qt-field input, .qt-field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; font-size: 0.95rem; font-family: var(--font-body);
  background: var(--paper-50); color: var(--ink-900);
}
.qt-field textarea { resize: vertical; min-height: 64px; }
.qt-field input:focus, .qt-field textarea:focus { outline: 2px solid var(--blue-400); outline-offset: -1px; }
.qt-priv { font-size: 0.76rem; color: var(--ink-500); line-height: 1.5; margin-top: 4px; }

.qt-total { margin-top: 8px; padding: 18px 20px; background: var(--paper-100); border-radius: var(--radius-sm); }
.qt-total .lbl { font-size: 0.78rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.04em; }
.qt-total .num { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; color: var(--blue-500); line-height: 1.2; font-variant-numeric: tabular-nums; }
.qt-total .note { font-size: 0.78rem; color: var(--ink-500); margin-top: 4px; }
.qt-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.qt-actions .btn { width: 100%; justify-content: center; }
.qt-actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.qt-actions-row .btn { flex: 1; justify-content: center; min-width: 120px; }
.qt-msg { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: #fef3e2; border: 1px solid #f0d9ad; color: #7a4a0a; font-size: 0.86rem; }

.qt-preview-col { position: sticky; top: 96px; }
.qt-preview-title { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); margin-bottom: 12px; }
#quotePreview {
  position: relative; width: 100%; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden;
}
#quotePreview .qd { transform-origin: top left; }

#pdfStage { position: fixed; left: -10000px; top: 0; width: 794px; }

/* ---- the quotation document (A4 @ 96dpi = 794 x 1123) ---- */
.qd {
  width: 794px; height: 1122px; padding: 40px 44px 28px; background: #fff; color: #0b1220;
  font-family: "Inter", "Segoe UI", "Leelawadee UI", "Tahoma", "Noto Sans Thai", sans-serif;
  font-size: 12.5px; line-height: 1.5; box-sizing: border-box; overflow: hidden; position: relative;
}
.qd * { box-sizing: border-box; }
.qd table { border-collapse: collapse; width: 100%; }
.qd-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 16px; border-bottom: 3px solid #2f6fed; }
.qd-brand { display: flex; align-items: center; gap: 12px; }
.qd-mark { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #4f8bff, #38d4d8); color: #fff; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.qd-brand strong { display: block; font-size: 18px; letter-spacing: 0.02em; }
.qd-brand span:not(.qd-mark) { display: block; font-size: 11px; color: #6b7690; }
.qd-co { text-align: right; font-size: 11px; color: #384358; line-height: 1.55; }
.qd-co strong { display: block; font-size: 12.5px; color: #0b1220; margin-bottom: 2px; }
.qd-titlebar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 20px 0 16px; }
.qd-titlebar h2 { font-size: 26px; letter-spacing: 0.04em; color: #0b1220; margin: 0; line-height: 1.2; }
.qd-titlebar p { margin: 2px 0 0; color: #6b7690; font-size: 12px; }
.qd-meta { width: auto !important; font-size: 12px; }
.qd-meta td { padding: 3px 0 3px 16px; }
.qd-meta td:first-child { color: #6b7690; padding-left: 0; }
.qd-meta td:last-child { font-weight: 600; text-align: right; }
.qd-two { display: flex; gap: 14px; margin-bottom: 16px; }
.qd-box { flex: 1; border: 1px solid #e3e8f2; border-radius: 8px; padding: 12px 14px; background: #f6f8fc; }
.qd-box h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #2f6fed; }
.qd-box td { padding: 2px 0; vertical-align: top; word-break: break-word; }
.qd-box .qd-k { width: 82px; color: #6b7690; white-space: nowrap; padding-right: 8px; }
.qd-items { margin-bottom: 4px; }
.qd-items th { background: #0b1220; color: #fff; padding: 9px 10px; font-size: 11.5px; text-align: left; font-weight: 600; }
.qd-items td { padding: 11px 10px; border-bottom: 1px solid #e3e8f2; vertical-align: top; }
.qd-c { text-align: center !important; }
.qd-r { text-align: right !important; font-variant-numeric: tabular-nums; }
.qd-sub { font-size: 10.5px; color: #6b7690; margin-top: 4px; line-height: 1.5; }
.qd-totals { margin: 10px 0 0 auto; width: 330px; }
.qd-totals td { padding: 5px 10px; }
.qd-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.qd-grand td { background: #2f6fed; color: #fff; font-weight: 700; font-size: 15px; padding: 9px 10px; }
.qd-words { text-align: right; font-size: 11.5px; color: #384358; margin-top: 6px; }
.qd-vatnote { text-align: right; font-size: 10.5px; color: #6b7690; margin-top: 2px; }
.qd-notes { margin-top: 16px; padding-top: 12px; border-top: 1px solid #e3e8f2; }
.qd-notes h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #2f6fed; }
.qd-notes ol { margin: 0; padding-left: 18px; font-size: 10.8px; color: #384358; line-height: 1.55; }
.qd-notes li { margin-bottom: 2px; }
.qd-sign { display: flex; gap: 40px; margin-top: 34px; }
.qd-sign > div { flex: 1; text-align: center; font-size: 11.5px; color: #384358; }
.qd-sign span { display: block; border-bottom: 1px solid #0b1220; height: 36px; margin-bottom: 6px; }
.qd-sign small { display: block; font-size: 10px; color: #6b7690; margin-top: 4px; }
.qd-foot { position: absolute; left: 44px; right: 44px; bottom: 14px; text-align: center; font-size: 10px; color: #a7b0c2; }

@media (max-width: 980px) {
  .qt-layout { grid-template-columns: 1fr; }
  .qt-preview-col { position: static; }
}
@media (max-width: 680px) {
  .qt-card { padding: 20px; }
}

/* Print / "Save as PDF" fallback: print only the quotation */
@media print {
  body * { visibility: hidden !important; }
  #quotePreview, #quotePreview * { visibility: visible !important; }
  #quotePreview { position: absolute !important; left: 0; top: 0; width: 794px !important; height: 1122px !important; border: none; box-shadow: none; border-radius: 0; overflow: visible; }
  #quotePreview .qd { transform: none !important; }
  @page { size: A4; margin: 0; }
}
