/* Haravan CUSNEW Build PC — Báo giá module
   Brand override: set --hq-brand on #hq-quote-root or via data-store-brand */

#hq-quote-root {
  --hq-brand: #d4e000;
  --hq-brand-dark: #c6d200;
  --hq-brand-soft: #222408;
  --hq-brand-border: #5c6408;
  --hq-ink: #0f172a;
  --hq-muted: #64748b;
  --hq-line: #e2e8f0;
  --hq-surface: #f8fafc;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--hq-ink);
}

#hq-quote-root[data-store-brand] {
  --hq-brand: attr(data-store-brand color, #d4e000);
}

/* Toolbar */
.hq-quote-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0 16px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--hq-line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hq-quote-toolbar .hq-btn {
  appearance: none;
  border: 1px solid var(--hq-line);
  background: #fff;
  color: var(--hq-ink);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.hq-quote-toolbar .hq-btn:hover:not(:disabled) {
  border-color: var(--hq-brand);
  color: var(--hq-brand-dark);
  background: var(--hq-brand-soft);
}

.hq-quote-toolbar .hq-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hq-quote-toolbar .hq-btn-primary {
  background: linear-gradient(135deg, var(--hq-brand), var(--hq-brand-dark));
  border-color: transparent;
  color: #1a1a00;
}

.hq-quote-toolbar .hq-btn-primary:hover:not(:disabled) {
  color: #1a1a00;
  filter: brightness(1.05);
  background: linear-gradient(135deg, var(--hq-brand), var(--hq-brand-dark));
}

.hq-quote-toolbar .hq-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--hq-muted);
  min-height: 1.2em;
}

.hq-quote-toolbar .hq-status.is-ok { color: #15803d; }
.hq-quote-toolbar .hq-status.is-err { color: #b91c1c; }

/* Screen preview of quote (optional, shown in demo / restore view) */
.hq-quote-preview {
  background: #fff;
  border: 1px solid var(--hq-line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.hq-quote-preview.is-readonly::before {
  content: "Chế độ xem báo giá (chỉ đọc)";
  display: block;
  margin: -8px 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--hq-brand-soft);
  color: var(--hq-brand-dark);
  font-size: 12px;
  font-weight: 700;
}

/* Print sheet — hidden on screen unless measuring / demo preview clone */
#hq-print-sheet {
  display: none;
  box-sizing: border-box;
  width: 186mm;
  margin: 0;
  padding: 0;
  color: var(--hq-ink);
  background: #fff;
  font: 11px/1.4 Inter, Arial, sans-serif;
}

#hq-print-sheet * { box-sizing: border-box; }

#hq-print-sheet.is-measuring {
  display: block;
  position: absolute;
  top: 0;
  left: -10000px;
}

.hq-print-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--hq-brand);
}

.hq-print-brand { min-width: 0; }

.hq-print-logo {
  display: block;
  width: 190px;
  height: 59px;
  object-fit: contain;
  object-position: left center;
}

.hq-print-wordmark {
  font-size: 18px;
  font-weight: 700;
  color: var(--hq-brand-dark);
}

.hq-print-title { text-align: right; }

.hq-print-title h1 {
  margin: 0 0 4px;
  font: 700 20px/1.3 Inter, Arial, sans-serif;
  color: var(--hq-ink);
}

.hq-print-title p {
  margin: 0;
  font-size: 10px;
  color: #475569;
}

.hq-print-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
  margin: 12px 0;
  font-size: 10px;
}

.hq-print-meta-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.hq-print-meta-item strong { white-space: nowrap; }

.hq-print-line-fill {
  flex: 1;
  border-bottom: 1px dotted #94a3b8;
  height: 1em;
}

.hq-print-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.hq-print-table th {
  padding: 7px 6px;
  border-bottom: 1px solid #94a3b8;
  color: var(--hq-ink);
  background: #f1f5f9;
  font-weight: 700;
  font-size: 10px;
  text-align: left;
}

.hq-print-table td {
  padding: 6px;
  border-bottom: 1px solid var(--hq-line);
  vertical-align: middle;
}

.hq-print-table .cell-center { text-align: center; }
.hq-print-table .cell-price {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hq-print-part-type {
  display: block;
  color: var(--hq-muted);
  font-size: 9px;
}

.hq-print-part-name {
  color: var(--hq-ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.hq-print-total-grand {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 24px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 2px solid var(--hq-brand);
}

.hq-print-total-grand span { font-weight: 700; }

.hq-print-total-grand strong {
  font-size: 20px;
  color: var(--hq-brand-dark);
}

.hq-print-notes {
  margin: 10px 0 0;
  color: #475569;
  font-size: 9px;
}

.hq-print-footer {
  display: block;
  margin-top: 12px;
  padding: 8px 0 0;
  border-top: 1px solid var(--hq-line);
  color: #475569;
  background: #fff;
  font-size: 9px;
  overflow-wrap: anywhere;
}

.hq-print-footer p { margin: 0 0 3px; }

/* Modal — PNG preview / share code */
.hq-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hq-modal.is-open { display: flex; }

.hq-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.hq-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
}

.hq-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--hq-line);
}

.hq-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.hq-modal-header p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--hq-muted);
}

.hq-modal-close {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--hq-muted);
  padding: 4px 8px;
}

.hq-modal-body {
  position: relative;
  padding: 24px;
  background: #f1f5f9;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  text-align: center;
  min-height: 280px;
}

.hq-modal-body canvas {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
  border: 1px solid #cbd5e1;
  background: #fff;
}

.hq-modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--hq-line);
  background: #fff;
}

.hq-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hq-share-box {
  text-align: left;
  background: #fff;
  border: 1px solid var(--hq-line);
  border-radius: 12px;
  padding: 16px;
  margin: 0 auto;
  max-width: 560px;
}

.hq-share-box label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--hq-muted);
  margin-bottom: 6px;
}

.hq-share-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--hq-brand-dark);
  margin: 0 0 12px;
}

.hq-share-url {
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--hq-line);
  background: var(--hq-surface);
  color: var(--hq-ink);
  word-break: break-all;
}

.hq-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100000;
  display: none;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.hq-toast.is-show { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 767.98px) {
  .hq-quote-toolbar .hq-status { width: 100%; margin-left: 0; }
  .hq-modal-footer { flex-direction: column; align-items: stretch; }
  .hq-modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hq-modal-actions .hq-btn-primary { grid-column: 1 / -1; }
}

/* Print */
@page { size: A4 portrait; margin: 10mm 12mm; }

@media print {
  html, body {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body > :not(#hq-print-sheet) { display: none !important; }
  body::before, body::after { display: none !important; }

  #hq-print-sheet {
    display: block !important;
    position: static !important;
    width: 186mm;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #hq-print-sheet a[href]::after { content: none !important; }

  .hq-print-table tr,
  .hq-print-total-grand,
  .hq-print-notes,
  .hq-print-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.hq-quote-customer-form label input { width: 100%; }
.hq-print-meta { grid-template-columns: 1fr 1fr; }
@media print {
  .hq-quote-customer-form { display: none !important; }
}
