/* Màn "Báo giá": mọi class có tiền tố qt- để không đụng màn khác. */

.qt-tools[hidden] {
  display: none;
}
.qt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.qt-chip-count {
  color: var(--muted);
  font-size: 12px;
}
.chip.is-active .qt-chip-count,
.chip[aria-pressed='true'] .qt-chip-count {
  color: inherit;
}
.qt-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  width: min(300px, 100%);
}
.qt-search .i {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
.qt-search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    border-color var(--duration-base),
    box-shadow var(--duration-base);
}
.qt-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Bảng báo giá và danh mục */
.qt-tbl td {
  vertical-align: middle;
}
.qt-row {
  cursor: pointer;
}
.qt-code {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.qt-sub {
  display: block;
  font-size: 12px;
}
.qt-gap {
  margin-left: 6px;
}
.qt-soon {
  color: var(--warn);
}
.qt-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.qt-new {
  animation: qt-pop var(--duration-slide) var(--ease-out);
}
@keyframes qt-pop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Modal soạn báo giá */
.layer-panel.modal.qt-panel {
  width: min(980px, 100%);
  max-height: min(94vh, 100%);
}
.qt-tabs {
  margin-bottom: 14px;
}
.qt-status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.qt-lock-note {
  flex-basis: 100%;
}
.qt-items {
  margin: 8px 0 16px;
}
.qt-items h3 {
  margin-bottom: 8px;
}
.qt-picker {
  position: relative;
  margin-bottom: 10px;
}
.qt-input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition:
    border-color var(--duration-base),
    box-shadow var(--duration-base);
}
.qt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.qt-input:disabled {
  background: var(--surface-2);
  color: var(--muted);
}
.qt-picker-input {
  min-height: 42px;
}
.qt-picker-list {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform-origin: top left;
  animation: pop-in var(--duration-base) var(--ease-out);
}
.qt-picker-list[hidden] {
  display: none;
}
.qt-option,
.qt-option-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--duration-fast),
    transform var(--duration-fast);
}
.qt-option[aria-selected='true'] {
  background: var(--accent-soft);
  transform: translateX(3px);
}
.qt-option-empty {
  cursor: default;
}
.qt-lines {
  display: grid;
  gap: 8px;
}
.qt-line {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) 84px 140px 84px 140px 36px;
  align-items: end;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.qt-in {
  animation: qt-line-in var(--duration-slide) var(--ease-out);
}
@keyframes qt-line-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}
.qt-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.qt-cap {
  color: var(--muted);
  font-size: 12px;
}
.qt-line-name strong {
  overflow-wrap: anywhere;
}
.qt-cell-total {
  text-align: right;
}
.qt-line-total {
  font-weight: 600;
}
.qt-del {
  align-self: end;
}
.qt-items-empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  text-align: center;
}
.qt-items-empty[hidden] {
  display: none;
}
.qt-block-error {
  min-height: 0;
  padding-top: 6px;
}
.qt-block-error.has-error {
  color: var(--danger);
  animation: fade-in var(--duration-base) var(--ease-out);
}
.qt-block-error.shake {
  animation: shake 360ms var(--ease-in-out);
}
.qt-totals {
  display: grid;
  gap: 8px;
  margin-left: auto;
  width: min(380px, 100%);
}
.qt-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.qt-tax {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.qt-tax .qt-input {
  width: 72px;
}
.qt-grand {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 17px;
}
.qt-grand .qt-total-val {
  color: var(--accent);
}
.qt-foot {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.qt-foot-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.qt-foot .btn[hidden],
.qt-foot-note[hidden],
.qt-approved[hidden] {
  display: none;
}
.qt-foot-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 13px;
  animation: fade-in var(--duration-base) var(--ease-out);
}
.qt-foot-note.is-warn {
  color: var(--warn);
  font-weight: 500;
}
.qt-status-cell {
  display: inline-block;
}

/* Duyệt giảm giá: huy hiệu chờ duyệt nhịp nhẹ; duyệt xong nền cam mờ dần sang xanh và dấu tích vẽ dần */
.qt-pulse {
  animation: qt-pulse calc(var(--duration-enter) * 3) var(--ease-in-out) infinite;
}
@keyframes qt-pulse {
  50% {
    opacity: 0.6;
    transform: scale(0.96);
  }
}
.qt-approved {
  position: relative;
  isolation: isolate;
}
.qt-approved .i {
  width: 14px;
  height: 14px;
  stroke-width: 2.4;
}
.qt-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.qt-approved.is-new {
  animation: qt-swap var(--duration-slide) var(--ease-out);
}
.qt-approved.is-new::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: var(--warn-soft);
  opacity: 0;
  animation: qt-fade-out var(--duration-enter) var(--ease-out);
}
.qt-approved.is-new .qt-check path {
  animation: qt-draw var(--duration-enter) var(--ease-out) var(--duration-base) backwards;
}
@keyframes qt-swap {
  from {
    transform: scale(0.9);
  }
}
@keyframes qt-fade-out {
  from {
    opacity: 1;
  }
}
@keyframes qt-draw {
  from {
    stroke-dashoffset: 1;
  }
}
.qt-reject-note {
  display: flex;
  flex-basis: 100%;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  overflow-wrap: anywhere;
  animation: rise var(--duration-slide) var(--ease-out);
}
.qt-reject-note .i {
  width: 18px;
  height: 18px;
}
.qt-doc-flag {
  margin-top: 4px;
  font-weight: 600;
}
@media (pointer: coarse) {
  .qt-code {
    min-height: 44px;
  }
}

/* Tài liệu báo giá (xem trước và in): luôn là "tờ giấy" sáng, không theo nền tối */
.qt-doc {
  --qt-paper: white;
  --qt-ink: black;
  --qt-rule: gray;
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--qt-paper);
  color: var(--qt-ink);
  box-shadow: var(--shadow-sm);
}
.qt-doc-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}
.qt-doc-brand {
  font-size: 22px;
  font-weight: 700;
}
.qt-doc-meta {
  text-align: right;
}
.qt-doc-meta h2 {
  font-size: 20px;
  letter-spacing: 0.06em;
}
.qt-doc .qt-cap {
  color: inherit;
  opacity: 0.7;
}
.qt-doc-table {
  width: 100%;
  border-collapse: collapse;
}
.qt-doc-table th,
.qt-doc-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--qt-rule);
  text-align: left;
}
.qt-doc-table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.qt-doc-table .num,
.qt-doc-table tfoot th {
  text-align: right;
}
.qt-doc-table tfoot tr:last-child {
  font-weight: 700;
}
.qt-doc-note {
  font-size: 13px;
}

/* Thu hẹp: bảng thành danh sách thẻ, dòng sản phẩm xếp hai hàng */
@media (max-width: 720px) {
  .qt-search {
    margin-left: 0;
    width: 100%;
  }
  .qt-tbl,
  .qt-tbl tbody,
  .qt-tbl tr,
  .qt-tbl td {
    display: block;
  }
  .qt-tbl thead {
    display: none;
  }
  .qt-tbl tbody tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
  }
  .qt-tbl td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    white-space: normal;
    text-align: right;
  }
  .qt-tbl td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-align: left;
  }
  .qt-line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .qt-line-name {
    grid-column: 1 / -1;
  }
  .qt-cell-total {
    text-align: left;
  }
  .qt-del {
    justify-self: end;
  }
  .qt-doc {
    padding: 16px;
    overflow-x: auto;
  }
  .qt-doc-meta {
    text-align: left;
  }
}

/* In: chỉ in phần tài liệu; class print-quote được gắn lên body ngay trước khi gọi window.print() */
@media print {
  body.print-quote {
    overflow: visible !important;
  }
  body.print-quote > *:not(.layer) {
    display: none !important;
  }
  body.print-quote .layer {
    position: static;
    display: block;
    padding: 0;
  }
  body.print-quote .layer-backdrop,
  body.print-quote .layer-head,
  body.print-quote .layer-foot,
  body.print-quote .qt-tabs,
  body.print-quote .qt-compose {
    display: none !important;
  }
  body.print-quote .layer-panel {
    position: static;
    width: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    transform: none;
    animation: none;
    transition: none;
  }
  body.print-quote .layer-body {
    padding: 0;
    overflow: visible;
  }
  body.print-quote .qt-preview {
    display: block;
    opacity: 1;
    transform: none;
  }
  body.print-quote .qt-doc {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
