/* ==========================================================================
   UP CARE — widget de chat (captación)
   Hereda los tokens de upcare.css (índigo #24216A ≤25% del área, turquesa
   #73D8BD ≤10%, superficies planas, bordes de 1px). Nada de degradados de
   marca: la jerarquía se hace con espaciado, bordes y tipografía.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Lanzador (burbuja flotante)
   -------------------------------------------------------------------------- */
.upc-launcher {
  position: fixed;
  right: 18px;
  bottom: calc(18px + 44px + 26px); /* sobre el botón de WhatsApp (52px + aire) */
  z-index: 70;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid color-mix(in oklch, var(--indigo) 30%, transparent);
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 8px 24px rgba(22, 22, 78, 0.22);
  transition: transform 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.upc-launcher:hover { transform: translateY(-2px); background: color-mix(in oklch, var(--indigo) 88%, black); }
.upc-launcher:active { transform: translateY(0); }
.upc-launcher svg { width: 25px; height: 25px; }
.upc-launcher .upc-launcher-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--indigo);
}
.upc-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; }

/* --------------------------------------------------------------------------
   2. Panel
   -------------------------------------------------------------------------- */
.upc-panel {
  position: fixed;
  z-index: 76;
  right: 12px;
  bottom: 12px;
  width: min(392px, calc(100vw - 24px));
  height: min(618px, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: 0 24px 64px rgba(22, 22, 78, 0.28), 0 2px 8px rgba(22, 22, 78, 0.12);
  overflow: hidden;
  animation: upc-in 0.22s var(--ease) both;
}
.upc-panel[hidden] { display: none !important; }
@keyframes upc-in {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* hoja inferior en móvil */
@media (max-width: 520px) {
  .upc-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: auto; /* estira entre left/right: 0 exacto, sin depender de % */
    height: 88dvh;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  body.upc-open { overflow: hidden; }
}

/* --- cabecera -------------------------------------------------------------- */
.upc-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* filete de marca: 2px de turquesa, área mínima */
  box-shadow: inset 0 2px 0 var(--accent);
}
.upc-plate {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--indigo);
  color: #fff;
  border-radius: var(--r-sm);
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.03em;
}
.upc-head-txt { flex: 1 1 auto; min-width: 0; }
.upc-title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
}
.upc-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.upc-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--turq-deep-fb);
  background: var(--turq-deep);
  flex: 0 0 auto;
}
.upc-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.upc-close:hover { color: var(--indigo); border-color: var(--border-strong); }
.upc-close svg { width: 15px; height: 15px; }

/* --- conversación --------------------------------------------------------- */
.upc-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { .upc-log { scroll-behavior: auto; } }

.upc-msg {
  max-width: 86%;
  padding: 10px 13px;
  font-size: 14.5px;
  line-height: 1.5;
  border-radius: 12px;
  overflow-wrap: anywhere;
  animation: upc-msg-in 0.2s var(--ease) both;
}
@keyframes upc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.upc-msg--bot {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  border-left: 2px solid var(--accent); /* glifo turquesa, no relleno */
  max-width: calc(86% + 2px);
}
.upc-msg--user {
  align-self: flex-end;
  background: var(--indigo);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.upc-msg--sys {
  align-self: center;
  max-width: 100%;
  text-align: center;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 2px 0;
}
.upc-msg--error {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid color-mix(in oklch, var(--error) 45%, transparent);
  border-left: 3px solid var(--error);
  color: var(--ink);
  font-size: 13.5px;
}
.upc-msg--error b { display: block; font-family: var(--f-display); font-size: 13.5px; margin-bottom: 2px; }

/* "escribiendo…" */
.upc-typing { display: inline-flex; align-items: center; gap: 4px; padding: 13px; }
.upc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--azora);
  animation: upc-dot 1.1s infinite ease-in-out;
}
.upc-typing span:nth-child(2) { animation-delay: 0.16s; }
.upc-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes upc-dot {
  0%, 62%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* --- opciones rápidas ----------------------------------------------------- */
.upc-choices {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 14px 2px;
  background: var(--bg);
}
.upc-choices:empty { display: none; }
.upc-choice {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--indigo);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}
.upc-choice:hover { border-color: var(--turq-deep-fb); border-color: var(--turq-deep); background: var(--surface); }
.upc-choice:disabled { opacity: 0.5; }

/* --- consentimiento ------------------------------------------------------- */
.upc-consent {
  margin-top: 4px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  display: grid;
  gap: 10px;
}
.upc-consent p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.upc-consent label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: start;
  cursor: pointer;
  font-size: 12.8px;
  line-height: 1.45;
  color: var(--ink);
}
.upc-consent input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  accent-color: var(--turq-deep-fb);
  flex: 0 0 auto;
}
.upc-consent .upc-consent-link { font-size: 12.2px; }
.upc-consent .upc-consent-link a { color: var(--turq-ink-fb); color: var(--turq-ink); text-decoration: underline; text-underline-offset: 2px; }
.upc-consent .upc-cta { width: 100%; }

/* --- pie: entrada --------------------------------------------------------- */
.upc-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px 8px;
}
.upc-form { display: flex; align-items: flex-end; gap: 8px; }
.upc-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 96px;
  padding: 11px 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  resize: none;
}
.upc-input::placeholder { color: color-mix(in oklch, var(--ink-soft) 72%, transparent); }
.upc-input:focus { outline: 2px solid var(--turq-deep-fb); outline: 2px solid var(--turq-deep); outline-offset: 1px; border-color: var(--turq-deep); }
.upc-input:disabled { background: var(--bg); }
.upc-send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--indigo);
  border: 1.5px solid color-mix(in oklch, var(--indigo) 22%, transparent);
  border-radius: var(--r-md);
  transition: background 0.15s var(--ease), opacity 0.15s var(--ease);
}
.upc-send:hover { background: color-mix(in oklch, var(--accent) 84%, var(--indigo)); }
.upc-send:disabled { opacity: 0.45; }
.upc-send svg { width: 19px; height: 19px; }
.upc-legal {
  margin: 7px 0 0;
  font-family: var(--f-mono);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-align: center;
}
.upc-legal a { text-decoration: underline; text-underline-offset: 2px; }
.upc-legal a:hover { color: var(--turq-deep-fb); }

/* --- enlaces y botones utilitarios dentro del log ------------------------- */
.upc-retry {
  margin-top: 7px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--indigo);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 12.5px;
}
.upc-retry:hover { border-color: var(--turq-deep-fb); border-color: var(--turq-deep); }
.upc-linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--turq-ink-fb);
  color: var(--turq-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.upc-confirm {
  display: grid;
  gap: 8px;
  justify-items: start;
}
.upc-confirm .upc-check {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in oklch, var(--accent) 26%, var(--surface));
  color: var(--turq-ink-fb);
  color: var(--turq-ink);
}
.upc-confirm .upc-check svg { width: 19px; height: 19px; }
.upc-confirm strong { font-family: var(--f-display); font-size: 15px; }

/* --------------------------------------------------------------------------
   3. Accesibilidad / preferencias del sistema
   -------------------------------------------------------------------------- */
.upc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
@media (prefers-reduced-motion: reduce) {
  .upc-panel,
  .upc-msg { animation: none; }
  .upc-typing span { animation: none; opacity: 0.7; }
}
