/* Styles for Thien Phat Quotation & Order Builder Tool */
:root {
  --qb-navy: #0b2f4f;
  --qb-navy-deep: #061f35;
  --qb-navy-soft: #174866;
  --qb-gold: #d19a2f;
  --qb-gold-deep: #a87316;
  --qb-gold-light: #fef7e7;
  --qb-ivory: #f7f2ea;
  --qb-paper: #ffffff;
  --qb-ink: #102d43;
  --qb-muted: #5e707e;
  --qb-line: #dbe4eb;
  --qb-line-dark: #b0c2d0;
  --qb-success: #1b7a54;
  --qb-success-bg: #eaf7f1;
  --qb-excel-green: #107c41;
  --qb-excel-hover: #0b5a2f;
  --qb-zalo-blue: #0068ff;
  --qb-zalo-hover: #0052cc;
  --qb-radius-sm: 6px;
  --qb-radius-md: 10px;
  --qb-radius-lg: 14px;
  --qb-shadow-sm: 0 2px 6px rgba(11, 47, 79, 0.06);
  --qb-shadow-md: 0 8px 24px rgba(11, 47, 79, 0.1);
  --qb-shadow-lg: 0 16px 40px rgba(11, 47, 79, 0.14);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body.qb-body {
  margin: 0;
  background-color: #f2f5f8;
  color: var(--qb-ink);
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.qb-header {
  background: var(--qb-navy-deep);
  color: #ffffff;
  padding: 12px 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.qb-header-inner {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.qb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #ffffff;
}

.qb-brand img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #ffffff;
  padding: 2px;
}

.qb-brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
}

.qb-brand-sub {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--qb-gold);
}

.qb-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qb-btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--qb-radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  text-decoration: none;
  transition: all 0.2s ease;
}

.qb-btn-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.qb-btn-nav.accent {
  background: var(--qb-gold);
  border-color: var(--qb-gold);
  color: var(--qb-navy-deep);
  font-weight: 600;
}

.qb-btn-nav.accent:hover {
  background: #e5ab37;
}

/* Layout container */
.qb-main {
  max-width: 1540px;
  width: 100%;
  margin: 20px auto 100px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .qb-main {
    grid-template-columns: 1fr;
  }
}

/* Panel cards */
.qb-panel {
  background: var(--qb-paper);
  border-radius: var(--qb-radius-md);
  box-shadow: var(--qb-shadow-sm);
  border: 1px solid var(--qb-line);
  overflow: hidden;
}

.qb-panel-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--qb-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.qb-panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--qb-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.qb-panel-body {
  padding: 20px;
}

/* Document Type Toggle */
.qb-mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e8eef3;
  padding: 4px;
  border-radius: var(--qb-radius-sm);
  margin-bottom: 20px;
  gap: 4px;
}

.qb-mode-btn {
  padding: 10px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  background: transparent;
  color: var(--qb-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.qb-mode-btn.active {
  background: var(--qb-navy);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(11, 47, 79, 0.2);
}

/* Form Groups */
.qb-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--qb-line);
}

.qb-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.qb-section-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--qb-navy-soft);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qb-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.qb-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qb-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--qb-ink);
}

.qb-label small {
  color: var(--qb-muted);
  font-weight: 400;
}

.qb-input,
.qb-select,
.qb-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--qb-line-dark);
  border-radius: var(--qb-radius-sm);
  background: #ffffff;
  color: var(--qb-ink);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qb-input:focus,
.qb-select:focus,
.qb-textarea:focus {
  outline: none;
  border-color: var(--qb-navy);
  box-shadow: 0 0 0 3px rgba(11, 47, 79, 0.12);
}

.qb-textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

/* Quick chips / presets */
.qb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.qb-chip {
  background: #eef3f7;
  border: 1px solid #d4e0e9;
  color: var(--qb-navy);
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.qb-chip:hover {
  background: var(--qb-navy);
  color: #ffffff;
  border-color: var(--qb-navy);
}

/* Product Item Cards */
.qb-items-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.qb-item-card {
  background: #fafcfe;
  border: 1px solid var(--qb-line);
  border-left: 4px solid var(--qb-navy);
  border-radius: var(--qb-radius-sm);
  padding: 16px;
  position: relative;
  transition: box-shadow 0.2s ease;
}

.qb-item-card:hover {
  box-shadow: var(--qb-shadow-sm);
  border-color: #b7cbdb;
}

.qb-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.qb-item-badge {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--qb-navy);
  background: #e8f0f6;
  padding: 2px 10px;
  border-radius: 10px;
}

.qb-item-actions {
  display: flex;
  gap: 6px;
}

.qb-btn-icon {
  background: #ffffff;
  border: 1px solid var(--qb-line-dark);
  color: var(--qb-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--qb-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 0.9rem;
}

.qb-btn-icon:hover {
  background: #f1f5f9;
  color: var(--qb-navy);
}

.qb-btn-icon.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

.qb-calc-preview {
  margin-top: 10px;
  padding: 10px 14px;
  background: #edf5fc;
  border-radius: var(--qb-radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.qb-calc-subtotal {
  font-size: 1.1rem;
  color: var(--qb-navy-deep);
  font-weight: 800;
}

.qb-btn-add {
  width: 100%;
  padding: 12px;
  background: #ffffff;
  border: 2px dashed var(--qb-navy-soft);
  color: var(--qb-navy);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--qb-radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.qb-btn-add:hover {
  background: #f0f6fa;
  border-color: var(--qb-navy);
}

/* Summary Box */
.qb-summary-box {
  background: linear-gradient(135deg, var(--qb-navy-deep) 0%, var(--qb-navy) 100%);
  color: #ffffff;
  border-radius: var(--qb-radius-sm);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--qb-shadow-sm);
}

.qb-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.qb-summary-label {
  font-size: 1.05rem;
  font-weight: 600;
}

.qb-summary-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--qb-gold);
}

.qb-summary-words {
  font-size: 0.9rem;
  font-style: italic;
  color: #e2e8f0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  line-height: 1.4;
}

/* Live Preview Sheet (Excel-like simulation) */
.qb-preview-wrapper {
  background: #cbd5e1;
  padding: 24px;
  overflow-x: auto;
  border-radius: 0 0 var(--qb-radius-md) var(--qb-radius-md);
}

.qb-excel-sheet {
  background: #ffffff;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 36px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  font-family: "Times New Roman", Times, serif;
  color: #000000;
  font-size: 14px;
  line-height: 1.35;
}

.qb-excel-header {
  margin-bottom: 18px;
  font-size: 13px;
}

.qb-excel-header h3 {
  margin: 0 0 2px 0;
  font-size: 14px;
  font-weight: 400;
  text-transform: uppercase;
}

.qb-excel-header p {
  margin: 1px 0;
}

.qb-excel-title {
  text-align: center;
  margin: 16px 0 6px 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.qb-excel-date {
  text-align: center;
  font-size: 13px;
  margin-bottom: 14px;
}

.qb-excel-recipient {
  margin-bottom: 6px;
  font-size: 14px;
}

.qb-excel-greeting {
  margin-bottom: 14px;
  font-size: 13.5px;
}

/* Excel Preview Table */
.qb-excel-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  font-size: 13px;
}

.qb-excel-table th,
.qb-excel-table td {
  border: 1px solid #000000;
  padding: 6px 8px;
  vertical-align: middle;
}

.qb-excel-table th {
  font-weight: 700;
  text-align: center;
  background: #ffffff;
}

.qb-excel-table td.col-center {
  text-align: center;
}

.qb-excel-table td.col-right {
  text-align: right;
  white-space: nowrap;
}

.qb-excel-table td.col-desc {
  white-space: pre-line;
  line-height: 1.3;
}

.qb-excel-table tr.total-row td {
  font-weight: 700;
  font-size: 14.5px;
}

.qb-excel-words {
  font-style: italic;
  font-size: 13.5px;
  margin: 8px 0 16px 0;
}

.qb-excel-notes {
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.45;
}

.qb-excel-notes strong {
  display: block;
  margin-bottom: 4px;
}

.qb-excel-notes-content {
  white-space: pre-line;
}

/* Sticky Action Bar */
.qb-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 2px solid var(--qb-line);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  padding: 12px 24px;
  z-index: 99;
}

.qb-action-bar-inner {
  max-width: 1540px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.qb-action-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.qb-action-label {
  font-size: 0.9rem;
  color: var(--qb-muted);
}

.qb-action-total {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--qb-navy-deep);
}

.qb-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qb-btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--qb-radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.qb-btn-excel {
  background: var(--qb-excel-green);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 124, 65, 0.25);
}

.qb-btn-excel:hover {
  background: var(--qb-excel-hover);
  transform: translateY(-1px);
}

.qb-btn-mail {
  background: var(--qb-navy);
  color: #ffffff;
}

.qb-btn-mail:hover {
  background: var(--qb-navy-deep);
  transform: translateY(-1px);
}

.qb-btn-zalo {
  background: var(--qb-zalo-blue);
  color: #ffffff;
}

.qb-btn-zalo:hover {
  background: var(--qb-zalo-hover);
  transform: translateY(-1px);
}

.qb-btn-print {
  background: #f1f5f9;
  border: 1px solid var(--qb-line-dark);
  color: var(--qb-ink);
}

.qb-btn-print:hover {
  background: #e2e8f0;
}

/* Modals */
.qb-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 31, 53, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.qb-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.qb-modal {
  background: #ffffff;
  border-radius: var(--qb-radius-md);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--qb-shadow-lg);
  display: flex;
  flex-direction: column;
}

.qb-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--qb-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.qb-modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--qb-navy);
}

.qb-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--qb-muted);
  cursor: pointer;
  line-height: 1;
}

.qb-modal-body {
  padding: 20px;
}

.qb-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--qb-line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

/* Toast Notification */
.qb-toast {
  position: fixed;
  bottom: 84px;
  right: 24px;
  background: var(--qb-navy-deep);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--qb-radius-sm);
  box-shadow: var(--qb-shadow-lg);
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.qb-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.qb-toast.success {
  background: #064e3b;
  border-left: 5px solid #10b981;
}

/* Print CSS */
@media print {
  body.qb-body {
    background: #ffffff !important;
  }
  .qb-header,
  .qb-action-bar,
  .qb-panel:first-child,
  .qb-panel-header,
  .qb-toast,
  .qb-modal-backdrop {
    display: none !important;
  }
  .qb-main {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  .qb-panel {
    border: none !important;
    box-shadow: none !important;
  }
  .qb-preview-wrapper {
    background: #ffffff !important;
    padding: 0 !important;
  }
  .qb-excel-sheet {
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
}
