/* Botones flotantes y chat de los temas Noche y Papel.
   El mismo diseño en los dos: WhatsApp a la izquierda, asistente a la derecha.
   No depende de utilidades de Tailwind, que en estos temas a veces no entran al CSS compilado. */

body.noche .flotante-wa,
body.papel .flotante-wa,
body.noche .flotante-ia,
body.papel .flotante-ia {
  position: fixed;
  z-index: 60;
  bottom: 20px;
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-decoration: none;
  box-shadow: 0 12px 28px -10px rgba(8, 12, 16, .55), 0 0 0 1px rgba(255, 255, 255, .08);
  transition: transform .2s ease;
}
body.noche .flotante-wa:hover,
body.papel .flotante-wa:hover,
body.noche .flotante-ia__btn:hover,
body.papel .flotante-ia__btn:hover {
  transform: translateY(-2px);
}
body.noche .flotante-wa,
body.papel .flotante-wa {
  left: 20px;
  right: auto;
  background: #25d366;
  color: #fff;
}
body.noche .flotante-ia,
body.papel .flotante-ia {
  right: 20px;
  left: auto;
  width: auto;
  height: auto;
  background: transparent;
  box-shadow: none;
}
body.noche .flotante-ia__btn,
body.papel .flotante-ia__btn {
  position: relative;
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #11181d !important;
  color: #f4f7f8 !important;
  box-shadow: 0 12px 28px -10px rgba(8, 12, 16, .55), 0 0 0 1px rgba(255, 255, 255, .12);
  cursor: pointer;
}
body.noche .flotante-wa svg,
body.papel .flotante-wa svg,
body.noche .flotante-ia__btn svg,
body.papel .flotante-ia__btn svg {
  width: 28px;
  height: 28px;
  display: block;
  color: inherit !important;
}
body.noche .flotante-etiq,
body.papel .flotante-etiq {
  position: absolute;
  top: 50%;
  padding: 7px 12px;
  border-radius: 999px;
  background: #11181d;
  color: #f4f7f8;
  font: 600 13px/1.2 "Schibsted Grotesk", "Geist", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .2s ease;
}
body.noche .flotante-wa .flotante-etiq,
body.papel .flotante-wa .flotante-etiq { left: calc(100% + 10px); }
body.noche .flotante-ia .flotante-etiq,
body.papel .flotante-ia .flotante-etiq { right: calc(100% + 10px); }
body.noche .flotante-wa:hover .flotante-etiq,
body.papel .flotante-wa:hover .flotante-etiq,
body.noche .flotante-ia__btn:hover .flotante-etiq,
body.papel .flotante-ia__btn:hover .flotante-etiq,
body.noche .flotante-wa:focus-visible .flotante-etiq,
body.papel .flotante-wa:focus-visible .flotante-etiq,
body.noche .flotante-ia__btn:focus-visible .flotante-etiq,
body.papel .flotante-ia__btn:focus-visible .flotante-etiq { opacity: 1; }

body.noche #ai-chat-window.is-abierto,
body.papel #ai-chat-window.is-abierto {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  z-index: 280;
  inset: 0;
  width: auto;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #10161b;
  color: #e7eef1;
  box-shadow: none;
  overflow: hidden;
}
body.noche #ai-chat-container,
body.papel #ai-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
body.noche #ai-chat-header,
body.papel #ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  margin: 0;
  padding: 14px 14px 14px 16px;
  background: #172127 !important;
  color: #f4f7f8;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
body.noche #ai-chat-header h2,
body.papel #ai-chat-header h2 {
  margin: 0;
  color: #f4f7f8;
  font: 700 15px/1.2 "Schibsted Grotesk", "Geist", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
}
body.noche #ai-chat-header p,
body.papel #ai-chat-header p {
  margin: 2px 0 0;
  color: rgba(244, 247, 248, .62);
  font: 400 12px/1.3 "Schibsted Grotesk", "Geist", "Helvetica Neue", Arial, sans-serif;
}
body.noche #ai-chat-header > div,
body.papel #ai-chat-header > div { display: flex; align-items: center; min-width: 0; }
body.noche .ia-marca,
body.papel .ia-marca {
  width: 36px;
  height: 36px;
  margin-right: 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: #25d366 !important;
  color: #06210f !important;
}
body.noche .ia-marca svg,
body.papel .ia-marca svg { width: 18px; height: 18px; }
body.noche #ai-chat-header > button,
body.papel #ai-chat-header > button {
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #f4f7f8;
  cursor: pointer;
}
body.noche #ai-chat-header > button:hover,
body.papel #ai-chat-header > button:hover { background: rgba(255, 255, 255, .08); }
body.noche #ai-chat-header > button svg,
body.papel #ai-chat-header > button svg { width: 18px; height: 18px; }

body.noche #ai-chat-messages,
body.papel #ai-chat-messages {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  background: #10161b;
  color: #e7eef1;
}
body.noche .ia-msg,
body.papel .ia-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
body.noche .ia-msg--yo,
body.papel .ia-msg--yo { justify-content: flex-end; }
body.noche .ia-burbuja,
body.papel .ia-burbuja {
  max-width: min(80%, 280px);
  margin: 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: #1c2830 !important;
  color: #e7eef1 !important;
  font: 400 14px/1.45 "Schibsted Grotesk", "Geist", "Helvetica Neue", Arial, sans-serif;
}
body.noche .ia-msg--yo .ia-burbuja,
body.papel .ia-msg--yo .ia-burbuja {
  background: #e7f6ef !important;
  color: #102018 !important;
  border-bottom-right-radius: 4px;
}
body.noche .ia-msg--bot .ia-burbuja,
body.papel .ia-msg--bot .ia-burbuja { border-bottom-left-radius: 4px; }
body.noche .ia-msg--error .ia-burbuja,
body.papel .ia-msg--error .ia-burbuja {
  background: #3a1d22;
  color: #ffd5d8;
}
body.noche .ia-burbuja p,
body.papel .ia-burbuja p { margin: 0; color: inherit; }
body.noche .ia-burbuja a,
body.papel .ia-burbuja a {
  color: #0e7490;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
body.noche .ia-msg--bot .ia-burbuja a,
body.papel .ia-msg--bot .ia-burbuja a { color: #7ee7f5; }
body.noche .ia-avatar,
body.papel .ia-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: #25d366 !important;
  color: #06210f !important;
}
body.noche .ia-avatar svg,
body.papel .ia-avatar svg { width: 15px; height: 15px; }
body.noche .ia-puntos,
body.papel .ia-puntos { display: flex; gap: 4px; padding: 4px 2px; }
body.noche .ia-puntos i,
body.papel .ia-puntos i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(231, 238, 241, .55);
  animation: ia-punto 1s ease-in-out infinite;
}
body.noche .ia-puntos i:nth-child(2),
body.papel .ia-puntos i:nth-child(2) { animation-delay: .15s; }
body.noche .ia-puntos i:nth-child(3),
body.papel .ia-puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes ia-punto { 50% { opacity: .25; transform: translateY(-2px); } }

body.noche #ai-chat-input-container,
body.papel #ai-chat-input-container {
  flex: none;
  margin: 0;
  padding: 12px;
  background: #10161b;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
body.noche #ai-chat-form,
body.papel #ai-chat-form { display: flex; gap: 8px; align-items: center; }
body.noche #ai-chat-input,
body.papel #ai-chat-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  background: #172127;
  color: #f4f7f8;
  font: 400 14px/1 "Schibsted Grotesk", "Geist", "Helvetica Neue", Arial, sans-serif;
  box-shadow: none;
}
body.noche #ai-chat-input::placeholder,
body.papel #ai-chat-input::placeholder { color: rgba(244, 247, 248, .45); }
body.noche #ai-chat-submit,
body.papel #ai-chat-submit {
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  background: #25d366 !important;
  color: #06210f !important;
  cursor: pointer;
}
body.noche #ai-chat-submit:disabled,
body.papel #ai-chat-submit:disabled { opacity: .45; cursor: default; }
body.noche #ai-chat-submit svg,
body.papel #ai-chat-submit svg { width: 18px; height: 18px; }

/* Papel es claro: el panel no puede usar los colores de Noche. */
body.papel #ai-chat-window.is-abierto {
  background: #f3f2ee;
  color: #1b1d1f;
  border-color: rgba(27, 29, 31, .14);
}
body.papel #ai-chat-header {
  background: #1d2023 !important;
  border-bottom-color: transparent;
}
body.papel #ai-chat-header h2,
body.papel #ai-chat-header > button { color: #f4f1ea; }
body.papel #ai-chat-header p { color: rgba(244, 241, 234, .62); }
body.papel .ia-marca,
body.papel .ia-avatar { background: #ff5a2c !important; color: #fff !important; }
body.papel #ai-chat-messages { background: #f3f2ee; color: #1b1d1f; }
body.papel .ia-burbuja {
  background: #fff !important;
  color: #1b1d1f !important;
  box-shadow: 0 1px 2px rgba(27, 29, 31, .08);
}
body.papel .ia-msg--yo .ia-burbuja { background: #ff5a2c !important; color: #fff !important; }
body.papel .ia-msg--error .ia-burbuja { background: #ffe8e3 !important; color: #8d2412 !important; }
body.papel .ia-msg--bot .ia-burbuja a { color: #e8481c; }
body.papel .ia-msg--yo .ia-burbuja a { color: #fff; }
body.papel .ia-puntos i { background: rgba(27, 29, 31, .4); }
body.papel #ai-chat-input-container { background: #f3f2ee; border-top-color: rgba(27, 29, 31, .12); }
body.papel #ai-chat-input { background: #fff; color: #1b1d1f; border-color: rgba(27, 29, 31, .16); }
body.papel #ai-chat-input::placeholder { color: #8b8f92; }
body.papel #ai-chat-submit { background: #ff5a2c !important; color: #fff !important; }
body.papel .flotante-ia__btn { background: #1d2023 !important; }

@media (min-width: 768px) {
  body.noche #ai-chat-window.is-abierto,
  body.papel #ai-chat-window.is-abierto {
    inset: auto;
    top: calc(var(--barra) + 12px);
    right: 20px;
    bottom: 88px;
    width: 380px;
    height: auto;
    max-height: calc(100dvh - var(--barra) - 108px);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 20px;
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .65);
  }
  body.noche #ai-chat-header,
  body.papel #ai-chat-header { border-radius: 20px 20px 0 0; }
}
@media (max-width: 767px) {
  body.noche .flotante-etiq,
  body.papel .flotante-etiq { display: none; }
  /* El alto lo fija el teclado (visualViewport), no el alto de la página. */
  body.noche #ai-chat-window.is-abierto,
  body.papel #ai-chat-window.is-abierto {
    top: var(--ia-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--ia-alto, 100dvh);
    max-height: none;
    border-radius: 0;
  }
  body.noche #ai-chat-input,
  body.papel #ai-chat-input { font-size: 16px; }
  body.noche #ai-chat-input-container,
  body.papel #ai-chat-input-container { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
