/* Chat de preventa: panel lateral (escritorio) / pantalla completa (móvil). Funciona en landings (p4-base) y en páginas con tokens.
   Cada variable lleva su valor por defecto porque las landings no definen --brand, --surface-2, --text-2... */
html:has(dialog.c-chat[open]) {
  overflow: hidden;
}
.u-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.c-chat,
.c-chatc {
  --cl: color-mix(in srgb, var(--text, #0B1B30) 12%, transparent);
  border: 0;
  padding: 0;
  color: var(--text, #0B1B30);
  background: var(--bg, #F4F6F1);
  font: 15px/1.5 var(--f, 'Archivo', system-ui, sans-serif);
}
.c-chat::backdrop,
.c-chatc::backdrop {
  background: rgba(6, 20, 42, 0.5);
}
.c-chat h2,
.c-chatc h2 {
  margin: 0;
  font: 700 17px/1.2 var(--f, 'Archivo', system-ui, sans-serif);
  color: var(--text, #0B1B30);
  letter-spacing: 0;
}
.c-chat a,
.c-chatc a {
  color: var(--link, #0B4FA8);
  text-decoration: underline;
  cursor: pointer;
}
.c-chat textarea,
.c-chatc textarea,
.c-chat input,
.c-chatc input {
  font: 16px var(--f, 'Archivo', system-ui, sans-serif);
}
.c-chat {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(440px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  box-shadow: -18px 0 40px -24px rgba(0, 0, 0, 0.5);
}
.c-chat[open] {
  display: flex;
  flex-direction: column;
}
.c-chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--cl);
  flex: none;
}
.c-chat__head .c-btn--icon {
  flex: none;
}
.c-chat__ico {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--brand, #0B2545);
}
.c-chat__tit {
  flex: 1;
  min-width: 0;
}
.c-chat__tit small {
  display: block;
  font-size: 12px;
  color: var(--text-2, #5A6B80);
}
.c-chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.c-chat__m {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.c-chat__m p {
  margin: 0 0 8px;
}
.c-chat__m p:last-child {
  margin: 0;
}
.c-chat__m ul {
  margin: 0 0 8px;
  padding-left: 20px;
  list-style: disc;
}
.c-chat__m ul:last-child {
  margin: 0;
}
.c-chat__m--u {
  align-self: flex-end;
  background: var(--brand, #0B2545);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.c-chat__m--a {
  align-self: flex-start;
  background: var(--surface-2, #EEF1EA);
  border-bottom-left-radius: 4px;
  animation: chat-in 0.18s ease-out;
}
.c-chat__m--a .c-chat__hablar {
  display: flex;
  margin-top: 10px;
}
.c-chat__err {
  align-self: stretch;
  max-width: none;
  background: transparent;
  border: 1px solid var(--cl);
  border-radius: 12px;
  font-size: 14px;
}
.c-chat__err .c-chat__reintentar {
  margin: 2px 0 8px;
}
.c-chat__typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}
.c-chat__typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-2, #5A6B80);
  animation: chat-dot 1s infinite ease-in-out;
}
.c-chat__typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.c-chat__typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}
@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.c-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 10px;
  flex: none;
  max-height: 34vh;
  overflow-y: auto;
}
.c-chat__sug {
  font: 14px/1.3 var(--f, 'Archivo', system-ui, sans-serif);
  text-align: left;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--cl);
  background: var(--surface, #fff);
  color: var(--text, #0B1B30);
  cursor: pointer;
}
.c-chat__sug:hover {
  background: var(--surface-2, #EEF1EA);
}
.c-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--cl);
  flex: none;
}
.c-chat__form textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 140px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--cl);
  background: var(--surface, #fff);
  color: var(--text, #0B1B30);
  line-height: 1.3;
}
.c-chat__form .c-chat__enviar {
  background: var(--ball, var(--accent, #D7F24B));
  color: var(--on-accent, #06142A) !important;
  flex: none;
}
.c-chat__pie {
  margin: 0;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2, #5A6B80);
  flex: none;
}
/* Modal de contacto: encima del panel */
.c-chatc {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}
.c-chatc .c-chat__head {
  justify-content: space-between;
}
.c-chatc .c-chat__cform,
.c-chatc .c-chat__gracias {
  display: block;
  padding: 14px 16px 18px;
}
.c-chatc [hidden] {
  display: none;
}
.c-chat__ayuda {
  margin: 0 0 12px;
  color: var(--text-2, #5A6B80);
  font-size: 14px;
}
.c-chat__campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.c-chat__campo label {
  font: 700 13px var(--f, 'Archivo', system-ui, sans-serif);
}
.c-chat__campo label i {
  font-weight: 400;
}
.c-chat__campo input,
.c-chat__campo textarea {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--cl);
  background: var(--surface, #fff);
  color: var(--text, #0B1B30);
  width: 100%;
  box-sizing: border-box;
}
.c-chat__campo textarea {
  resize: vertical;
}
.c-chat__chk {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 14px;
  cursor: pointer;
}
.c-chat__chk input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  flex: none;
}
.c-chat__cerr {
  margin: 0 0 8px;
  min-height: 0;
  color: var(--ko, #D3413F);
  font-size: 14px;
}
.c-chat__acts {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
@media (max-width: 720px) {
  .c-chat {
    inset: 0;
    width: 100vw;
  }
  .c-chat__m {
    max-width: 94%;
  }
  .c-chat__form {
    padding-bottom: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .c-chat__m--a,
  .c-chat__typing i {
    animation: none;
  }
}
