/* Chat de la web — estilos adaptados a la web nueva de legiohispana.es (noviembre de 2026).
   Solo cambia el aspecto. chat-widget.js no se toca: mismas clases y mismo comportamiento.
   Los colores se fijan aquí (tinta y lona de la web), no con data-color. */
.it-chat { font: 16px/1.5 "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif; color: #0B1230; position: relative; z-index: 10000; color-scheme: light; }
.it-chat * { box-sizing: border-box; }
.it-chat [hidden] { display: none !important; }
.it-chat button, .it-chat textarea, .it-chat a { font: inherit; }
.it-chat button { cursor: pointer; }
.it-chat :is(button, a, textarea):focus-visible { outline: 3px solid #1A3FC4; outline-offset: 3px; }

.it-launcher {
  position: fixed; right: 24px; bottom: 24px;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 12px 20px;
  background: #0B1230; color: #fff;
  border: 2px solid #fff; border-radius: 6px;
  font-weight: 700 !important;
}
.it-launcher:hover { background: #1A3FC4; }
.it-chat-icon { font-size: 26px; line-height: 1; }

.it-panel {
  position: fixed; right: 24px; bottom: 24px;
  width: 380px; height: min(580px, calc(100dvh - 48px));
  display: flex; flex-direction: column;
  background: #fff; border: 2px solid #0B1230; border-radius: 10px; overflow: hidden;
  text-align: left;
}
.it-header { display: block; position: relative; background: #0B1230; color: #fff; padding: 16px 16px 10px; }
.it-heading { padding-right: 40px; }
.it-heading strong { display: block; font-stretch: 62%; font-weight: 900; text-transform: uppercase; font-size: 26px; line-height: 1; }
.it-heading small { display: block; font-size: 14px; color: #C3CAE0; margin-top: 4px; }
.it-actions { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; margin-top: 6px; }
.it-actions a, .it-actions button { font-size: 14px; font-weight: 600; background: none; color: #fff; border: 0; padding: 0; min-height: 44px; display: inline-flex; align-items: center; text-decoration: underline; text-underline-offset: .18em; }
.it-actions .it-close { position: absolute; top: 6px; right: 6px; min-width: 44px; min-height: 44px; justify-content: center; font-size: 30px; line-height: 1; text-decoration: none; }
.it-chat .it-header :is(button, a):focus-visible { outline-color: #FFB000; }

.it-messages { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.it-message { max-width: 92%; padding: 11px 14px; border-radius: 10px 10px 10px 2px; background: #E9EDF0; overflow-wrap: anywhere; flex-shrink: 0; }
.it-message p { margin: 0; white-space: pre-wrap; }
.it-message a { color: inherit; text-decoration: underline; }
.it-user { align-self: flex-end; background: #0B1230; color: #fff; border-radius: 10px 10px 2px 10px; }
.it-fallback { display: inline-block; margin-top: 8px; font-weight: 700; }

.it-privacy { margin: 0; padding: 8px 16px; font-size: 14px; line-height: 1.4; color: #3A4263; border-top: 1px solid #D9E0E6; }
.it-privacy a { color: #1A3FC4; font-weight: 600; text-decoration: underline; }
.it-suggestions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.it-suggestions button { border: 2px solid #0B1230; border-radius: 4px; background: #fff; color: #0B1230; font-size: 14px; font-weight: 600; padding: 6px 10px; min-height: 40px; text-align: left; }
.it-suggestions button:hover { background: #0B1230; color: #fff; }

.it-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); border-top: 2px solid #0B1230; position: relative; background: #E9EDF0; }
.it-form textarea { resize: none; min-width: 0; max-height: 100px; border: 2px solid #0B1230; border-radius: 4px; padding: 10px; color: #0B1230; background: #fff; font-size: 16px; }
.it-send { border: 2px solid #0B1230; border-radius: 4px; background: #0B1230; color: #fff; padding: 10px 14px; font-weight: 700 !important; min-height: 48px; }
.it-send:disabled { opacity: .5; cursor: default; }
.it-count { position: absolute; bottom: 0; left: 20px; font-size: 14px; color: #3A4263; }
.it-typing { font-size: 14px; color: #3A4263; margin: 0; }
.it-typing span { display: inline-block; animation: it-pulse 1s infinite alternate; }
.it-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes it-pulse { to { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .it-typing span { animation: none; } }

@media (max-width: 799px) {
  /* En móvil el botón del chat es un cuadrado de 52 px que cabe en el hueco de la barra de plaza. */
  .it-launcher { right: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); width: 52px; min-height: 52px; height: 52px; padding: 0; justify-content: center; }
  .it-launcher-text { display: none; }
}
@media (max-width: 599px) {
  .it-panel { top: 0; left: 0; right: 0; bottom: auto; width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  /* Con el teclado abierto quedan unos 330–450 px de alto. Todo lo que no es conversación
     se compacta para que los mensajes conserven sitio. */
  .it-header { padding: max(10px, env(safe-area-inset-top)) 12px 2px; }
  .it-heading strong { font-size: 22px; }
  .it-heading small { margin-top: 2px; }
  .it-actions { margin-top: 0; }
  .it-actions a, .it-actions button { min-height: 34px; }
  .it-actions .it-close { top: max(2px, env(safe-area-inset-top)); min-height: 44px; }
  /* Mientras se escribe (teclado abierto): cabecera de dos líneas sin la fila de enlaces
     y, cuando ya se ha enviado el primer mensaje, sin el aviso de privacidad.
     Al tocar la conversación o cerrar el teclado tocando fuera, vuelven a verse. */
  .it-heading small { margin-top: 0; line-height: 1.3; }
  .it-panel:has(textarea:focus) .it-actions > :not(.it-close) { display: none; }
  .it-panel:has(textarea:focus) .it-header { padding-bottom: 8px; }
  .it-panel:has(textarea:focus):has(.it-user) .it-privacy { display: none; }
  .it-chat .it-form textarea:focus-visible { outline-width: 2px; outline-offset: 0; }
  .it-messages { padding: 10px 12px; gap: 8px; }
  .it-message { padding: 9px 12px; }
  .it-privacy { padding: 6px 12px; line-height: 1.3; }
  .it-suggestions { flex-wrap: nowrap; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
  .it-suggestions::-webkit-scrollbar { display: none; }
  .it-suggestions button { flex: none; white-space: nowrap; }
  .it-form { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  .it-form textarea { height: 48px; padding: 10px; }
}
