/* ==========================================================================
   Quotation documents — format picker + 3 live document editors
   (Techno Commercial Offer: Simple / Detailed, and Standard Quotation)
   Same "live document" approach as invoice.css/purchase-order.css.
   ========================================================================== */

/* ---------- Format picker (first step when clicking Create Quotation) ---------- */
.qd-format-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }
.qd-format-card {
  border: 1.5px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5);
  cursor: pointer; transition: border-color var(--transition), background var(--transition), transform var(--transition);
  display: flex; flex-direction: column; gap: 8px;
}
.qd-format-card:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }
.qd-format-card-title { font-weight: 700; font-size: 14px; color: var(--text); }
.qd-format-card-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* flex-start (not flex-end): fields in this row can have different natural
   heights (e.g. the lead picker's manual-entry toggle makes it taller than
   a plain label+input field) — aligning by the top edge means one taller
   field never throws off every other field's label/input position, the
   way bottom-alignment would. */
.qd-meta-bar { display: flex; gap: var(--sp-5); flex-wrap: wrap; align-items: flex-start; margin-bottom: var(--sp-5); padding-bottom: var(--sp-4); border-bottom: 1px dashed var(--border-strong); }
.qd-meta-bar .field { margin-bottom: 0; min-width: 180px; }
.qd-tax-mode-row { margin-top: 27px; }
/* Bare checkbox labels (Show Bank Details / Add a second item group) sit
   directly in the meta-bar with no field label above them — nudge them
   down to line up with the other fields' inputs, not their labels. */
.qd-meta-bar > label.flex { margin-top: 27px; }

/* ---------- Printable document base ----------
   Modern corporate-document redesign (shared by Quotations AND the
   Documents module, which builds its 6 templates on this same .qd-doc
   root — see documents.css). One consistent design language: navy for
   structure/headings, a restrained maroon accent for emphasis, light
   gray rules instead of heavy black grids, and a clear typographic
   hierarchy. Per-format identity (.fmt-simple / .fmt-detailed /
   .fmt-standard) is kept as light variation on top of this shared base,
   not a different palette per format. */
.qd-doc {
  --qd-ink: #1e2230;
  --qd-navy: #173a63;
  --qd-maroon: #9c1d2e;
  --qd-muted: #667085;
  --qd-line: #d7dbe3;
  --qd-line-strong: #aeb4c4;
  --qd-band: #f4f6fb;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 12px; line-height: 1.5; color: var(--qd-ink); background: #fff;
  padding: 22px; border: 1px solid var(--qd-line-strong); border-radius: 6px; box-shadow: 0 1px 3px rgba(23, 58, 99, 0.08);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

/* ---------- Header band: logo (reasonably sized) + company identity ---------- */
.qd-doc-header { display: flex; flex-direction: column; align-items: center; text-align: center; border-bottom: 2.5px solid var(--qd-navy); padding-bottom: 12px; margin-bottom: 14px; }
.qd-doc-header .doc-brand-logo { max-height: 46px; margin: 0 auto 6px; }
.qd-doc-company-name { font-size: 17px; font-weight: 800; color: var(--qd-navy); font-style: normal; letter-spacing: 0.01em; }
.qd-doc-header-line { color: var(--qd-muted); font-weight: 500; font-size: 10.5px; margin-top: 1px; }
.qd-doc-tagline { color: var(--qd-maroon); font-style: normal; font-weight: 700; font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; margin-top: 2px; }

.qd-doc.fmt-standard .qd-doc-header { border-bottom-color: var(--qd-navy); }

/* ---------- Document title ---------- */
.qd-doc-title-bar {
  text-align: center; font-size: 19px; font-weight: 800; letter-spacing: 0.06em; color: var(--qd-navy);
  padding: 4px 0 10px; margin-bottom: 14px; text-decoration: none; background: transparent; text-transform: uppercase;
  position: relative;
}
.qd-doc-title-bar::after { content: ""; display: block; width: 52px; height: 3px; background: var(--qd-maroon); margin: 8px auto 0; border-radius: 2px; }
.qd-doc.fmt-standard .qd-doc-title-bar { background: transparent; }

.qd-doc-refdate { display: flex; justify-content: space-between; font-weight: 700; color: var(--qd-navy); font-size: 11.5px; margin-bottom: 12px; padding: 6px 10px; background: var(--qd-band); border-radius: 4px; }

.qd-doc-recipient { margin-bottom: 10px; }
.qd-doc-recipient .fw-700 { font-weight: 700; }
.qd-doc-subject { font-weight: 700; margin-bottom: 10px; }
.qd-doc-subject .qd-label { text-decoration: none; color: var(--qd-navy); }

.qd-doc-intro { margin-bottom: 10px; }

.qd-doc-section-title { font-weight: 700; text-decoration: none; text-transform: uppercase; letter-spacing: 0.05em; font-size: 10.5px; color: var(--qd-navy); margin: 14px 0 7px; padding-bottom: 4px; border-bottom: 1.5px solid var(--qd-line); }

.qd-bullet-list { margin: 0 0 10px; padding: 0; list-style: none; }
.qd-bullet-list li { display: flex; gap: 6px; margin-bottom: 4px; }
.qd-bullet-list li::before { content: "•"; flex-shrink: 0; color: var(--qd-maroon); font-weight: 700; }
.qd-bullet-list.numbered { counter-reset: qd-counter; }
.qd-bullet-list.numbered li::before { counter-increment: qd-counter; content: counter(qd-counter) "."; font-weight: 700; color: var(--qd-maroon); }

/* ---------- Items table ---------- */
.qd-doc-items-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.qd-doc-items-table th, .qd-doc-items-table td { border: 1px solid var(--qd-line); padding: 7px 9px; }
.qd-doc-items-table th { background: var(--qd-navy); color: #fff; font-weight: 700; text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; border-color: var(--qd-navy); }
.qd-doc-items-table td.num, .qd-doc-items-table th.num { text-align: right; white-space: nowrap; }
.qd-doc-items-table td.desc { max-width: 320px; }
.qd-doc-items-table tbody tr:nth-child(even) td { background: var(--qd-band); }
.qd-doc-items-table tr.total-row td { font-weight: 800; text-align: right; background: var(--qd-navy); color: #fff; border-color: var(--qd-navy); }
.qd-doc-items-table tr.total-row td:first-child { text-align: left; }

.qd-doc-group-title { font-weight: 800; text-align: center; background: var(--qd-band); color: var(--qd-navy); border: 1px solid var(--qd-line); border-bottom: none; padding: 6px; text-transform: uppercase; letter-spacing: 0.03em; font-size: 11px; }

.qd-doc-words { border: 1px solid var(--qd-line); border-left: 3px solid var(--qd-maroon); padding: 8px 10px; margin-bottom: 10px; color: var(--qd-ink); font-weight: 800; text-align: center; border-radius: 0 4px 4px 0; background: var(--qd-band); }

.qd-doc-terms-value { color: var(--qd-ink); font-weight: 500; }
.qd-doc.fmt-detailed .qd-doc-section-title + .qd-bullet-list.numbered { color: var(--qd-ink); font-weight: 500; }
.qd-doc.fmt-detailed .qd-doc-section-title + .qd-bullet-list.numbered li::before { color: var(--qd-maroon); }

.qd-doc-bank-table { width: 62%; border-collapse: collapse; margin: 6px 0 10px; }
.qd-doc-bank-table td { border: 1px solid var(--qd-line); padding: 5px 9px; font-size: 11px; }
.qd-doc-bank-table td:first-child { font-weight: 700; width: 40%; background: var(--qd-band); color: var(--qd-navy); }
.qd-doc-bank-table td:last-child { color: var(--qd-ink); font-weight: 600; }

.qd-doc-sign { margin-top: 24px; break-inside: avoid; }
.qd-doc-sign-line { height: 44px; border-bottom: 1px solid var(--qd-line-strong); max-width: 220px; }

/* ---------- Editable fields inside the live document editor ---------- */
.qd-doc input, .qd-doc textarea, .qd-doc select {
  border: 1px solid var(--border-strong, #cbd5e1);
  background: #ffffff;
  font: inherit;
  color: var(--text, #1e293b);
  width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.qd-doc input::placeholder, .qd-doc textarea::placeholder {
  color: #94a3b8;
  font-style: italic;
  opacity: 1;
}
.qd-doc input:hover, .qd-doc textarea:hover, .qd-doc select:hover {
  border-color: #64748b;
  background: #fff;
}
.qd-doc input:focus, .qd-doc textarea:focus, .qd-doc select:focus {
  outline: none;
  border-color: var(--primary, #9c1d2e);
  box-shadow: 0 0 0 2.5px rgba(156, 29, 46, 0.15);
  background: #fff;
}
.qd-doc input[type="number"], .qd-doc td.num input {
  text-align: right;
}
.qd-doc-company-name {
  padding: 4px 8px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
}
.qd-doc-items-table input {
  padding: 6px 8px;
  border: 1px solid var(--border-strong, #cbd5e1);
  background: #ffffff;
  border-radius: 4px;
}
.qd-doc-items-table input:focus {
  border-color: var(--primary, #9c1d2e);
  box-shadow: 0 0 0 2px rgba(156, 29, 46, 0.15);
}
.qd-doc-recipient input {
  display: block;
  margin-top: 4px;
  margin-bottom: 4px;
  max-width: 360px;
}
.qd-doc-refdate input {
  display: inline-block;
  padding: 3px 6px;
  background: #fff;
}
.qd-doc-subject input {
  display: inline-block;
  padding: 4px 8px;
  background: #fff;
}
.qd-doc-header-line input {
  display: inline-block;
  padding: 2px 6px;
  background: #fff;
}
.qd-doc-sign input {
  display: block;
  margin-top: 4px;
  margin-bottom: 4px;
  max-width: 320px;
}
.qd-doc-error { color: #b91c1c; font-size: 12px; font-weight: 600; margin: -4px 0 8px; }

.qd-bullet-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.qd-bullet-row textarea { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 8px 10px; font-size: 13px; color: var(--text); }
.qd-bullet-row textarea:focus { outline: none; border-color: var(--primary); }
.qd-bullet-row .remove-row-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 6px; flex-shrink: 0; }
.qd-bullet-row .remove-row-btn:hover { color: var(--danger); }

.qd-doc .remove-row-btn { background: none; border: none; color: #444; opacity: 0.55; cursor: pointer; padding: 4px; }
.qd-doc .remove-row-btn:hover { opacity: 1; color: #b91c1c; }

/* ---------- Print / PDF output ----------
   No outer card border/shadow on the printed page (it doesn't paginate
   well across multiple sheets); @page controls the sheet margins instead.
   Table headers repeat on every printed page and key blocks never split
   across a page break. The generic "hide everything except the open
   modal" isolation lives once in components.css, shared by every
   document type — see the comment there for why. */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  #quotePreviewBody { padding: 0; }
  .qd-doc { border: none; box-shadow: none; border-radius: 0; padding: 0; }
  .qd-doc input, .qd-doc textarea, .qd-doc select {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .qd-doc-items-table thead { display: table-header-group; }
  .qd-doc-items-table tr { break-inside: avoid; }
  .qd-doc-sign, .qd-doc-words, .qd-doc-bank-table, .qd-doc-header { break-inside: avoid; }
}
