/* =========================================================
   COTIZACIÓN PÚBLICA  ·  prefijo cotp-
   Usa las variables del sitio (claro / oscuro).
   ========================================================= */

.cotp {
  --cotp-ok: #16a34a;
  --cotp-warn: #d97706;
  --cotp-bad: #dc2626;

  width: 100%; min-height: 70vh; padding: 36px 0 80px;
  background: var(--bg-soft, var(--bg)); color: var(--text);
}
.cotp *, .cotp *::before, .cotp *::after { box-sizing: border-box; }

.cotp__wrap {
  width: min(960px, calc(100% - 32px)); margin: 0 auto; display: grid; gap: 18px;
  animation: cotpIn .35s ease both;
}
@keyframes cotpIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.cotp-loading { text-align: center; color: var(--text-soft); padding: 60px 0; }
.cotp-spin {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px;
  border: 2px solid currentColor; border-right-color: transparent; animation: cotpSpin .7s linear infinite;
}
@keyframes cotpSpin { to { transform: rotate(360deg); } }

/* ---------- Cabecera ---------- */
.cotp-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 22px; background: var(--surface); border: 1px solid var(--border);
  border-radius: calc(var(--radius, 12px) + 4px);
}
.cotp-head > div { display: grid; gap: 4px; min-width: 0; }
.cotp-eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--primary); }
.cotp-head h1 { margin: 0; font-size: clamp(1.6rem, 4.5vw, 2.3rem); letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.cotp-head p { margin: 0; color: var(--text-soft); overflow-wrap: anywhere; }
.cotp-head p strong { color: var(--text); }
.cotp-vig { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }

.cotp-chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: .78rem; font-weight: 800;
  background: color-mix(in srgb, var(--cotp-ok) 15%, var(--surface)); color: var(--cotp-ok);
}
.cotp-chip.is-warn { background: color-mix(in srgb, var(--cotp-warn) 16%, var(--surface)); color: var(--cotp-warn); }
.cotp-chip.is-bad { background: color-mix(in srgb, var(--cotp-bad) 14%, var(--surface)); color: var(--cotp-bad); }

/* ---------- Botones ---------- */
.cotp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px;
  border-radius: var(--radius, 10px); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .15s, opacity .15s;
}
.cotp-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.cotp-btn:disabled { opacity: .6; cursor: wait; }
.cotp-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.cotp-btn i, .cotp-btn svg { width: 18px; height: 18px; }
.cotp-btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text, #fff); }
.cotp-btn--danger { background: var(--cotp-bad); border-color: var(--cotp-bad); color: #fff; }

/* ---------- Avisos de estado ---------- */
.cotp-banner {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: calc(var(--radius, 12px) + 2px);
  border: 1px solid var(--border); background: var(--surface);
}
.cotp-banner strong { display: block; font-size: 1.05rem; }
.cotp-banner p { margin: 4px 0 0; color: var(--text-soft); overflow-wrap: anywhere; }
.cotp-banner p.cotp-banner__quote { font-style: italic; }
.cotp-banner__icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.cotp-banner__icon i, .cotp-banner__icon svg { width: 22px; height: 22px; }
.cotp-banner.is-ok { border-color: color-mix(in srgb, var(--cotp-ok) 45%, var(--border)); background: color-mix(in srgb, var(--cotp-ok) 8%, var(--surface)); }
.cotp-banner.is-ok .cotp-banner__icon { background: color-mix(in srgb, var(--cotp-ok) 18%, var(--surface)); color: var(--cotp-ok); }
.cotp-banner.is-bad { border-color: color-mix(in srgb, var(--cotp-bad) 45%, var(--border)); background: color-mix(in srgb, var(--cotp-bad) 7%, var(--surface)); }
.cotp-banner.is-bad .cotp-banner__icon { background: color-mix(in srgb, var(--cotp-bad) 16%, var(--surface)); color: var(--cotp-bad); }
.cotp-banner.is-warn { border-color: color-mix(in srgb, var(--cotp-warn) 45%, var(--border)); background: color-mix(in srgb, var(--cotp-warn) 8%, var(--surface)); }
.cotp-banner.is-warn .cotp-banner__icon { background: color-mix(in srgb, var(--cotp-warn) 18%, var(--surface)); color: var(--cotp-warn); }

/* ---------- Tarjetas y tabla ---------- */
.cotp-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius, 12px) + 4px);
  overflow: hidden;
}
.cotp-table { width: 100%; border-collapse: collapse; }
.cotp-table th {
  padding: 12px 16px; text-align: left; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-soft); background: var(--bg-soft, var(--bg)); border-bottom: 1px solid var(--border);
}
.cotp-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cotp-table tbody tr:last-child td { border-bottom: 0; }
.cotp-table td strong { display: block; overflow-wrap: anywhere; }
.cotp-table td small { display: block; margin-top: 2px; color: var(--text-soft); }
.cotp-table .is-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cotp-table s { color: var(--text-soft); margin-right: 4px; }

.cotp-split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.cotp-side { display: grid; gap: 18px; min-width: 0; }
.cotp-note { padding: 18px 20px; }
.cotp-note h2, .cotp-respond h2 { margin: 0 0 8px; font-size: 1.05rem; }
.cotp-note p { margin: 0; line-height: 1.55; color: var(--text-soft); overflow-wrap: anywhere; }

.cotp-cond { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cotp-cond li { display: grid; gap: 2px; padding-left: 14px; border-left: 3px solid var(--primary); }
.cotp-cond strong { font-size: .92rem; }
.cotp-cond span { color: var(--text-soft); line-height: 1.5; overflow-wrap: anywhere; font-size: .92rem; }

.cotp-totals {
  display: grid; gap: 10px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: calc(var(--radius, 12px) + 4px);
}
.cotp-totals > div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.cotp-totals .is-discount { color: var(--cotp-ok); }
.cotp-totals__total { padding-top: 12px; border-top: 1px solid var(--border); font-size: 1.15rem; font-weight: 800; }
.cotp-totals__total strong { font-size: 1.5rem; letter-spacing: -.02em; }
.cotp-totals small { color: var(--text-soft); line-height: 1.4; }

/* ---------- Responder ---------- */
.cotp-respond { padding: 22px; display: grid; gap: 12px; scroll-margin-top: 20px; }
.cotp-respond p { margin: 0; color: var(--text-soft); }
.cotp-respond__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cotp-form { display: grid; gap: 14px; }
.cotp-form[hidden], .cotp-respond__actions[hidden], .cotp-field[hidden], .cotp-alert[hidden] { display: none; }
.cotp-form__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cotp-field { display: grid; gap: 6px; }
.cotp-field label { font-weight: 700; font-size: .9rem; }
.cotp-field em { font-weight: 500; font-style: normal; color: var(--text-soft); }
.cotp-field select, .cotp-field textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius, 10px);
  background: var(--bg); color: var(--text); font: inherit; line-height: 1.5;
}
.cotp-field textarea { resize: vertical; min-height: 84px; }
.cotp-field select:focus, .cotp-field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: none; outline: 2px solid var(--primary); outline-offset: 1px;
}
.cotp-alert {
  padding: 11px 14px; border-radius: var(--radius, 10px); font-weight: 600; font-size: .92rem;
  background: color-mix(in srgb, var(--cotp-bad) 12%, var(--surface)); color: var(--cotp-bad);
  border: 1px solid color-mix(in srgb, var(--cotp-bad) 35%, var(--surface));
}

.cotp-foot { margin: 0; text-align: center; color: var(--text-soft); font-size: .9rem; }
.cotp-foot a { color: var(--primary); font-weight: 700; }

/* ---------- No encontrada ---------- */
.cotp-empty {
  display: grid; justify-items: center; gap: 12px; text-align: center; padding: 48px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius, 12px) + 6px);
}
.cotp-empty h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 1.9rem); }
.cotp-empty p { margin: 0; color: var(--text-soft); max-width: 44ch; }
.cotp-empty__icon {
  display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%;
  background: color-mix(in srgb, var(--cotp-warn) 16%, var(--surface)); color: var(--cotp-warn);
}
.cotp-empty__icon i, .cotp-empty__icon svg { width: 32px; height: 32px; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .cotp { padding: 20px 0 56px; }
  .cotp-head { padding: 18px; }
  .cotp-head .cotp-btn { width: 100%; }
  .cotp-split { grid-template-columns: 1fr; }

  .cotp-table thead { display: none; }
  .cotp-table, .cotp-table tbody, .cotp-table tr, .cotp-table td { display: block; width: 100%; }
  .cotp-table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .cotp-table tbody tr:last-child { border-bottom: 0; }
  .cotp-table td { padding: 3px 0; border: 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .cotp-table td::before {
    content: attr(data-label); flex: none; color: var(--text-soft); font-size: .74rem; font-weight: 800;
    letter-spacing: .05em; text-transform: uppercase; padding-top: 2px;
  }
  .cotp-table td:first-child { display: block; text-align: left; padding-bottom: 6px; }
  .cotp-table td:first-child::before { display: none; }
  .cotp-respond { padding: 18px; }
  .cotp-respond__actions .cotp-btn, .cotp-form__actions .cotp-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cotp *, .cotp *::before, .cotp *::after { animation: none !important; transition: none !important; }
}
