/* Formulario público de cotización. CSS propio y liviano, sin dependencias. */

:root {
  --cq-bg: #f4f6fa;
  --cq-surface: #ffffff;
  --cq-text: #1b2433;
  --cq-muted: #5d6b82;
  --cq-line: #dbe1ec;
  --cq-primary: #0b57d0;
  --cq-primary-dark: #0842a0;
  --cq-primary-soft: #e8f0fe;
  --cq-danger: #b3261e;
  --cq-danger-soft: #fdecea;
  --cq-ok: #1e7a3c;
  --cq-ok-soft: #e6f4ea;
  --cq-radius: 12px;
  --cq-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--cq-bg);
  color: var(--cq-text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.cq-container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

.cq-top { background: var(--cq-surface); border-bottom: 1px solid var(--cq-line); }
.cq-top .cq-container { display: flex; align-items: center; min-height: 56px; }
.cq-brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--cq-primary); }

main.cq-container { padding-top: 32px; padding-bottom: 64px; }
.cq-title { margin: 0 0 8px; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; }
.cq-lead { margin: 0 0 24px; color: var(--cq-muted); }

/* Tarjetas */
.cq-card {
  background: var(--cq-surface);
  border: 1px solid var(--cq-line);
  border-radius: var(--cq-radius);
  box-shadow: var(--cq-shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.cq-card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 18px; }
.cq-step {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--cq-primary); color: #fff; font-size: 14px; font-weight: 700;
}
.cq-optional { color: var(--cq-muted); font-weight: 400; font-size: 14px; }

/* Campos */
.cq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.cq-grid-full { grid-column: 1 / -1; }
.cq-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cq-field + .cq-field { margin-top: 14px; }
.cq-grid .cq-field + .cq-field { margin-top: 0; }
.cq-label { font-size: 14px; font-weight: 600; }
.cq-label abbr { color: var(--cq-danger); text-decoration: none; }

.cq-input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid #b9c3d6; border-radius: 8px; background: #fff; color: inherit;
  font: inherit; -webkit-appearance: none; appearance: none;
}
textarea.cq-input { resize: vertical; min-height: 88px; }
.cq-input::placeholder { color: #8b97ab; }
.cq-input:hover { border-color: #8d9ab3; }
.cq-input:focus-visible, .cq-btn:focus-visible, .cq-file-clear:focus-visible, .cq-item-btn:focus-visible {
  outline: 3px solid rgba(11, 87, 208, .35); outline-offset: 1px; border-color: var(--cq-primary);
}
.cq-input[aria-invalid="true"] { border-color: var(--cq-danger); background: #fffafa; }
.cq-field-error { margin: 0; color: var(--cq-danger); font-size: 13px; }
.cq-hint { margin: 4px 0 0; color: var(--cq-muted); font-size: 13px; }

/* Búsqueda */
.cq-search-box { position: relative; }
.cq-search-icon { position: absolute; left: 12px; top: 13px; color: var(--cq-muted); pointer-events: none; }
.cq-search-input { padding-left: 40px; }
.cq-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; max-height: 340px; overflow-y: auto;
  background: #fff; border: 1px solid var(--cq-line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
}
.cq-result { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.cq-result[aria-selected="true"], .cq-result:hover { background: var(--cq-primary-soft); }
.cq-result-name { font-size: 15px; line-height: 1.3; }
.cq-result-meta { display: block; color: var(--cq-muted); font-size: 12px; }
.cq-result-added { color: var(--cq-ok); font-size: 12px; font-weight: 600; white-space: nowrap; }
.cq-results-msg { padding: 12px; color: var(--cq-muted); font-size: 14px; }

.cq-thumb { width: 40px; height: 40px; border-radius: 6px; background: #eef1f6 center / contain no-repeat; border: 1px solid var(--cq-line); object-fit: contain; }

/* Lista de productos */
.cq-empty { margin-top: 12px; padding: 20px; text-align: center; color: var(--cq-muted); background: #f8fafd; border: 1px dashed #c3cee0; border-radius: 10px; }
.cq-list { margin-top: 16px; }
.cq-list-head { display: grid; grid-template-columns: 1fr 132px 40px; gap: 12px; padding: 0 4px 6px; color: var(--cq-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
#cq-items { margin: 0; padding: 0; list-style: none; }
.cq-item { display: grid; grid-template-columns: 40px 1fr 132px 40px; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--cq-line); }
.cq-item-name { font-size: 15px; line-height: 1.3; }
.cq-item-meta { display: block; color: var(--cq-muted); font-size: 12px; }
.cq-qty { display: inline-flex; align-items: center; border: 1px solid #b9c3d6; border-radius: 8px; overflow: hidden; background: #fff; }
.cq-qty input { width: 56px; min-height: 40px; border: 0; text-align: center; font: inherit; background: transparent; -moz-appearance: textfield; appearance: textfield; }
.cq-qty input::-webkit-outer-spin-button, .cq-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cq-qty input:focus-visible { outline: 3px solid rgba(11, 87, 208, .35); outline-offset: -3px; }
.cq-qty button { width: 38px; min-height: 40px; border: 0; background: #f1f4f9; font-size: 18px; line-height: 1; cursor: pointer; color: var(--cq-text); }
.cq-qty button:hover { background: #e3e8f1; }
.cq-item-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--cq-muted); cursor: pointer; display: grid; place-items: center; }
.cq-item-btn:hover { background: var(--cq-danger-soft); color: var(--cq-danger); }
.cq-total-line { margin: 8px 4px 0; color: var(--cq-muted); font-size: 14px; text-align: right; }

/* Adjunto */
.cq-file-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.cq-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.cq-file-input:focus-visible + .cq-file-name, .cq-file:focus-within .cq-btn--ghost { outline: 3px solid rgba(11, 87, 208, .25); }
.cq-file-name { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--cq-primary-soft); font-size: 14px; }
.cq-file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.cq-file-clear { width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(11, 87, 208, .15); color: var(--cq-primary-dark); font-size: 16px; line-height: 1; cursor: pointer; }

/* Botones */
.cq-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px; border: 1px solid transparent; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.cq-btn--primary { width: 100%; background: var(--cq-primary); color: #fff; font-size: 17px; min-height: 52px; }
.cq-btn--primary:hover { background: var(--cq-primary-dark); }
.cq-btn--primary[disabled] { opacity: .7; cursor: progress; }
.cq-btn--ghost { background: #fff; border-color: #b9c3d6; color: var(--cq-text); }
.cq-btn--ghost:hover { background: #f1f4f9; }
.cq-btn--small { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.cq-actions { margin-top: 8px; }
.cq-actions .cq-hint { text-align: center; margin-top: 10px; }

/* Avisos */
.cq-alert { border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.cq-alert--error { background: var(--cq-danger-soft); color: #7a1912; border: 1px solid #f3c2bd; }
.cq-alert ul { margin: 8px 0 0; padding-left: 20px; }

/* Éxito */
.cq-success { text-align: center; background: var(--cq-surface); border: 1px solid var(--cq-line); border-radius: var(--cq-radius); box-shadow: var(--cq-shadow); padding: 40px 24px; }
.cq-success:focus { outline: none; }
.cq-success h2 { margin: 12px 0 8px; font-size: 24px; }
.cq-success p { margin: 0 auto 24px; max-width: 460px; color: var(--cq-muted); }
.cq-success-icon { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--cq-ok-soft); color: var(--cq-ok); }

/* Trampa antispam */
.cq-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.cq-spinner { width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: cq-spin .7s linear infinite; }
@keyframes cq-spin { to { transform: rotate(360deg); } }

/* Móvil */
@media (max-width: 600px) {
  main.cq-container { padding-top: 20px; }
  .cq-title { font-size: 24px; }
  .cq-card { padding: 16px; }
  .cq-grid { grid-template-columns: 1fr; }
  .cq-list-head { display: none; }
  .cq-item { grid-template-columns: 40px 1fr 40px; grid-template-areas: "thumb name del" ". qty qty"; row-gap: 8px; }
  .cq-item .cq-thumb { grid-area: thumb; }
  .cq-item .cq-item-main { grid-area: name; }
  .cq-item .cq-qty { grid-area: qty; justify-self: start; }
  .cq-item .cq-item-btn { grid-area: del; }
}

@media (prefers-reduced-motion: reduce) {
  .cq-spinner { animation-duration: 2s; }
}
