/* ===================================================================
   quotation-editor.css — หน้าฟอร์มแก้ไขใบเสนอราคาแบบ WYSIWYG เต็มหน้าจอ
   พิมพ์/แก้ตรงไหนเห็นผลตรงนั้นบนกระดาษ A4 จริง (794px = 210mm @ 96dpi)
   =================================================================== */

#qt-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1900;
  background: #EAEDEF;
  display: flex;
  flex-direction: column;
}

#qt-editor-overlay ~ .modal-overlay,
#qt-editor-overlay .modal-overlay {
  z-index: 2100;
}

.qt-editor-toolbar {
  flex-shrink: 0;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.qt-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.qt-editor-canvas-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 32px 20px;
}

.qt-editor-sidepanel {
  width: 300px;
  flex-shrink: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px;
}

/* ---------- A4 page canvas ---------- */
.qt-a4-page {
  width: 794px;
  min-height: 1123px;
  background: #fff;
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  padding: 48px 56px;
  font-family: var(--font-sans);
  color: #1a1a1a;
  font-size: 13px;
  line-height: 1.5;
}

.qt-editable {
  outline: none;
  min-height: 1.4em;
  border-radius: 3px;
  transition: background 0.12s;
  cursor: text;
}
.qt-editable:hover {
  background: rgba(20,108,104,0.05);
}
.qt-editable:focus {
  background: rgba(20,108,104,0.08);
  box-shadow: 0 0 0 1px var(--accent);
}
.qt-editable:empty::before {
  content: attr(data-placeholder);
  color: #B0B8BC;
  font-weight: 400;
}
.qt-editable.qt-inline {
  display: inline-block;
  min-width: 60px;
}

/* header */
.qt-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--accent);
}
.qt-doc-company { flex: 1; min-width: 0; }
.qt-logo-box {
  width: 88px;
  height: 88px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  margin-bottom: 10px;
  background: #fafbfb;
  gap: 4px;
}
.qt-logo-box img { width: 100%; height: 100%; object-fit: contain; }
.qt-logo-box i { font-size: 20px; color: #B0B8BC; }
.qt-logo-box span { font-size: 10px; color: #B0B8BC; }

.qt-company-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.qt-company-addr { color: #555; font-size: 12px; margin-bottom: 4px; white-space: pre-wrap; }
.qt-doc-meta-line { display: flex; gap: 16px; font-size: 11.5px; color: #666; flex-wrap: wrap; }

.qt-doc-title-block { text-align: right; flex-shrink: 0; min-width: 220px; }
.qt-doc-title { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.qt-doc-number {
  font-size: 14px; font-weight: 700; text-align: right;
  display: inline-block; min-width: 140px;
}
.qt-project { font-size: 12px; color: #555; margin-top: 4px; text-align: right; display: block; }
.qt-doc-dates {
  margin-top: 10px; font-size: 11.5px; color: #555;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.qt-date-input {
  border: none; background: transparent; font-family: var(--font-sans);
  font-size: 11.5px; color: #1a1a1a; font-weight: 600; cursor: pointer;
  padding: 1px 4px; border-radius: 3px;
}
.qt-date-input:hover { background: rgba(20,108,104,0.08); }

/* party box */
.qt-doc-party {
  background: #f8f9fa;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.qt-party-label { font-size: 10.5px; font-weight: 700; color: #888; letter-spacing: 0.06em; margin-bottom: 6px; }
.qt-cust-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }

/* items table */
.qt-items-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.qt-items-table th {
  background: var(--accent); color: #fff; padding: 8px 8px;
  font-size: 11.5px; font-weight: 600; text-align: left;
}
.qt-items-table th:first-child { border-radius: 6px 0 0 0; }
.qt-items-table th:last-child { border-radius: 0 6px 0 0; }
.qt-items-table td { border-bottom: 1px solid #eee; padding: 2px 6px; vertical-align: middle; }
.qt-cell-edit { padding: 4px 2px; font-size: 12.5px; }
.qt-cell-center { text-align: center; }
.qt-cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.qt-item-total { font-weight: 600; font-size: 12.5px; }
.qt-remove-item-btn {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: transparent; color: #C4452F; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.qt-remove-item-btn:hover { background: rgba(196,69,47,0.1); }

/* summary */
.qt-doc-summary-wrap {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 20px; margin: 16px 0 20px;
}
.qt-doc-installments { flex: 1; min-width: 0; }
.qt-inst-title { font-size: 11px; font-weight: 700; color: #888; letter-spacing: 0.05em; margin-bottom: 6px; }
.qt-inst-line { display: flex; justify-content: space-between; font-size: 12px; color: #555; padding: 2px 0; max-width: 280px; }

.qt-summary-table { width: 260px; flex-shrink: 0; border-collapse: collapse; }
.qt-summary-table td { padding: 4px 8px; font-size: 12.5px; }
.qt-summary-table td:first-child { color: #666; }
.qt-summary-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.qt-row-discount td { color: #C4452F; }
.qt-row-total td {
  font-weight: 700; font-size: 16px; padding-top: 10px;
  border-top: 2px solid var(--accent);
}
.qt-row-total td:last-child { color: var(--accent); }

/* notes */
.qt-doc-notes {
  background: #fffbea; border-left: 3px solid #f0c040;
  border-radius: 4px; padding: 10px 14px; margin-bottom: 28px; font-size: 12px;
}
.qt-doc-notes .qt-editable { color: #555; white-space: pre-wrap; }

/* footer signatures */
.qt-doc-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.qt-sign-block { text-align: center; }
.qt-sign-line { border-top: 1px solid #ccc; padding-top: 6px; margin-top: 56px; font-size: 11.5px; color: #666; }

/* ---------- Side panel sections ---------- */
.qt-side-section {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
.qt-side-title {
  font-size: 11.5px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.05em; margin-bottom: 10px;
}
.qt-btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.qt-inst-row {
  margin-bottom: 8px;
}
.qt-inst-row-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}
.qt-inst-row-top .qt-inst-amount-input { flex: 1; }
.qt-inst-label-input, .qt-inst-amount-input {
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 12px;
  font-family: var(--font-sans);
  width: 100%;
  box-sizing: border-box;
}
.qt-inst-amount-input { text-align: right; }
.qt-remove-inst-btn {
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: transparent; color: #C4452F; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  flex-shrink: 0;
}
.qt-remove-inst-btn:hover { background: rgba(196,69,47,0.1); }

/* ---------- responsive: smaller screens scale the page down ---------- */
@media (max-width: 1180px) {
  .qt-editor-sidepanel { width: 260px; }
}
@media (max-width: 900px) {
  .qt-editor-body { flex-direction: column; overflow-y: auto; }
  .qt-editor-canvas-wrap { padding: 16px 8px; overflow: visible; }
  .qt-a4-page { width: 100%; min-height: auto; padding: 24px 20px; transform: none; }
  .qt-editor-sidepanel { width: 100%; border-left: none; border-top: 1px solid var(--line); }
}

/* ---------- Notes header row + pick button (inside A4 page) ---------- */
.qt-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.qt-notes-pick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
}
.qt-notes-pick-btn:hover { background: rgba(20,108,104,0.18); }
.qt-notes-pick-btn i { font-size: 13px; }

/* ---------- Note template picker modal ---------- */
.qt-note-pick-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}
.qt-note-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.qt-note-pick-row:hover { background: var(--panel-hover); }
.qt-note-pick-row-selected {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.qt-note-pick-text { font-size: 13px; flex: 1; }
.qt-note-pick-icon { font-size: 16px; color: var(--accent); flex-shrink: 0; }

/* ---------- Notes management page ---------- */
.qtn-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qtn-row.dragging { opacity: 0.4; }
.qtc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 10px);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.qtc-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.qtn-drag-handle {
  cursor: grab;
  color: var(--text-faint);
  font-size: 16px;
  flex-shrink: 0;
}
.qtn-drag-handle:active { cursor: grabbing; }
.qtn-row-text {
  flex: 1;
  font-size: 13.5px;
  cursor: pointer;
  white-space: pre-wrap;
}
.qtn-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------- Customer list chips (single-row, wraps neatly) ---------- */
.qtc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-hover, rgba(127,127,127,0.1));
  color: var(--text-dim);
  font-size: 11.5px;
  line-height: 1.5;
  max-width: 100%;
}
.qtc-chip i {
  font-size: 12.5px;
  color: var(--accent);
  flex-shrink: 0;
}
.qtc-chip-text {
  display: inline-block;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.qtc-chip-name {
  background: none;
  padding: 3px 0;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
.qtc-chip-name i { color: var(--text-faint); }
.qtc-chip-name .qtc-chip-text { max-width: 260px; }
