/* ── Creador de Cotizaciones — Bretica ─────────────────────────── */

/* Layout principal */
.cot-toolbar {
  position: sticky;
  top: 0;
  z-index: 80;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cot-toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 20px;
  flex-wrap: wrap;
}
.cot-toolbar-left  { display: flex; align-items: center; gap: 12px; }
.cot-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.cot-title-block  { display: flex; flex-direction: column; }
.cot-title        { font-size: .9rem; font-weight: 700; color: #1e293b; line-height: 1.2; }
.cot-subtitle     { font-size: .72rem; color: #94a3b8; }

.cot-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 120px);
  align-items: start;
}

/* Editor */
.cot-editor {
  padding: 20px;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
}

.cot-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 14px;
}

.cot-section-title {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.cot-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cot-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.cot-field { display: flex; flex-direction: column; gap: 4px; }
.cot-field label { font-size: .75rem; font-weight: 600; color: #475569; }

.tax-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tax-row .input { flex: 1; }

.cot-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
}
.cot-toggle input[type="checkbox"] { margin: 0; }

/* Logo upload */
.logo-upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.logo-upload-area:hover,
.logo-upload-area.drag-over {
  border-color: var(--bretica-blue, #1e3a5f);
  background: #f8fafc;
}
.logo-placeholder { display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.logo-placeholder span { font-size: .82rem; color: #64748b; }
.logo-hint { font-size: .7rem; color: #94a3b8; }

/* Items table */
.items-table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.items-table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}
.items-table th {
  padding: 8px 6px;
  font-size: .7rem;
  font-weight: 600;
  color: #64748b;
  text-align: left;
  white-space: nowrap;
}
.items-table th.col-qty,
.items-table th.col-price,
.items-table th.col-disc,
.items-table th.col-total { text-align: right; }
.items-table th.col-del { width: 32px; }
.items-table th.col-qty  { min-width: 60px; }
.items-table th.col-price { min-width: 100px; }
.items-table th.col-disc  { min-width: 70px; }
.items-table th.col-total { min-width: 90px; }
.items-table th.col-desc  { min-width: 160px; }

.items-table tbody tr { border-bottom: 1px solid #f1f5f9; }
.items-table tbody td { padding: 4px 4px; vertical-align: middle; }
.items-table .num { text-align: right; font-size: .8rem; color: #334155; white-space: nowrap; }
.items-table td:last-child { text-align: center; }

.items-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 12px;
}
.totals-block { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.total-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: .82rem;
  color: #64748b;
  padding: 2px 0;
}
.total-row.total-grand {
  font-size: .9rem;
  font-weight: 700;
  color: #1e293b;
  border-top: 2px solid #e2e8f0;
  margin-top: 4px;
  padding-top: 6px;
}
.total-row.hidden { display: none; }

/* Color swatches */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  padding: 0;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor; }

/* Font picker dropdown */
.font-picker { position: relative; margin-top: 4px; }

.font-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-size: .9rem;
  color: #1e293b;
  transition: border-color .15s;
  gap: 8px;
}
.font-picker-trigger:hover,
.font-picker-trigger:focus { border-color: #94a3b8; outline: none; }
.font-picker-trigger svg { flex-shrink: 0; color: #94a3b8; transition: transform .15s; }
.font-picker.open .font-picker-trigger { border-color: #1e3a5f; }
.font-picker.open .font-picker-trigger svg { transform: rotate(180deg); }

.font-picker-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 120;
  list-style: none;
  margin: 0; padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}
.font-picker-list.hidden { display: none; }

.font-picker-group {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 8px 12px 4px;
  cursor: default;
  user-select: none;
}
.font-picker-opt {
  padding: 8px 14px;
  font-size: 1rem;
  color: #1e293b;
  cursor: pointer;
  transition: background .1s;
  display: block;
  width: 100%;
}
.font-picker-opt:hover    { background: #f8fafc; }
.font-picker-opt.selected { background: #eff6ff; color: #1e3a5f; font-weight: 600; }

/* Preview panel */
.cot-preview-wrap {
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
}
.cot-preview-header {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 10px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.cot-preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
}

/* Quote document */
#quotePreview { max-width: 700px; margin: 0 auto; }
.qd-paper {
  background: #fff;
  box-shadow: 0 2px 24px rgba(0,0,0,.1);
}

/* Modal */
.cot-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cot-modal.hidden { display: none; }
.cot-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.cot-modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.cot-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 8px;
}
.cot-modal-desc {
  font-size: .85rem;
  color: #64748b;
  margin: 0 0 18px;
  line-height: 1.5;
}
.cot-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.cot-modal-msg {
  font-size: .82rem;
  border-radius: 6px;
  padding: 8px 12px;
  margin-top: 10px;
}
.cot-modal-msg.hidden { display: none; }
.cot-modal-msg--success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.cot-modal-msg--error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Ocultar botón flotante de WhatsApp en esta app */
.wa-float { display: none !important; }

/* ── Print / PDF ──────────────────────────────────────────────── */
@media print {
  @page { margin: 12mm 15mm; size: A4; }

  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  /* Hide UI chrome */
  nav, footer,
  .cot-toolbar,
  .cot-editor,
  .cot-preview-header,
  .cot-modal,
  #btnPDF, #btnEmail, #btnReset {
    display: none !important;
  }

  /* Flatten layout */
  .cot-wrap { display: block !important; }
  .cot-preview-wrap {
    position: static !important;
    height: auto !important;
    overflow: visible !important;
    background: transparent !important;
  }
  .cot-preview-scroll {
    overflow: visible !important;
    padding: 0 !important;
    background: transparent !important;
  }
  #quotePreview { max-width: none !important; }
  .qd-paper {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cot-wrap { grid-template-columns: 1fr; }
  .cot-editor { border-right: none; border-bottom: 1px solid #e2e8f0; }
  .cot-preview-wrap {
    position: static;
    height: auto;
  }
  .cot-preview-scroll { padding: 16px; }
}
@media (max-width: 600px) {
  .cot-grid-2, .cot-grid-3 { grid-template-columns: 1fr; }
  .cot-toolbar-inner { padding: 8px 12px; }
  .cot-title-block { display: none; }
  .cot-editor { padding: 12px; }
  .cot-card { padding: 14px; }
}
