/* ==========================================================
   HELI - Agente de Inteligencia Artificial de SIAMTIC
   Design System Tokens & Componentes
   ========================================================== */

:root {
  --heli-navy-950: #061226;
  --heli-navy-900: #0A1D3F;
  --heli-navy-800: #0D224A;
  --heli-navy-700: #0F2A5C;
  --heli-orange-500: #FF6B1A;
  --heli-orange-400: #FF7F38;
  --heli-orange-300: #FF8A4C;
  --heli-orange-100: rgba(255, 107, 26, 0.14);
  --heli-green: #10B981;
  --heli-text: #FFFFFF;
  --heli-text-soft: #DCE4F3;
  --heli-muted: #9AA8C4;
  --heli-line: rgba(255, 255, 255, 0.12);
  --heli-line-strong: rgba(255, 107, 26, 0.35);
  --heli-shadow: 0 20px 50px rgba(3, 11, 24, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --heli-radius: 18px;
  --heli-font: "Barlow", system-ui, -apple-system, sans-serif;
  --heli-font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
}

/* ---------- Botón Flotante (Launcher) ---------- */
.heli-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  outline: none;
  font-family: var(--heli-font);
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.heli-launcher:hover {
  transform: translateY(-3px) scale(1.02);
}

.heli-launcher:active {
  transform: translateY(0) scale(0.98);
}

.heli-avatar-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--heli-navy-900), var(--heli-navy-700));
  border: 2.5px solid var(--heli-orange-500);
  box-shadow: 0 8px 24px rgba(255, 107, 26, 0.35), 0 4px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.heli-avatar-btn:hover {
  box-shadow: 0 10px 30px rgba(255, 107, 26, 0.55), 0 0 0 4px rgba(255, 107, 26, 0.2);
  border-color: var(--heli-orange-300);
}

.heli-avatar-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Indicador de Estado En Línea */
.heli-status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  background: var(--heli-green);
  border: 2.5px solid var(--heli-navy-950);
  border-radius: 50%;
}

.heli-status-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--heli-green);
  opacity: 0.7;
  animation: heli-pulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes heli-pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  70% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Badge de Notificación no leída */
.heli-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: var(--heli-orange-500);
  color: var(--heli-navy-950);
  font-size: 0.75rem;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--heli-navy-950);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.heli-badge.is-visible {
  display: flex;
  animation: heli-bounce 0.4s ease;
}

@keyframes heli-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Tooltip Proactivo de Bienvenida */
.heli-tooltip {
  position: absolute;
  right: 76px;
  bottom: 8px;
  background: var(--heli-navy-900);
  color: var(--heli-text);
  border: 1px solid var(--heli-line-strong);
  box-shadow: 0 12px 32px rgba(3, 11, 24, 0.6);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(10px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.heli-tooltip.is-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.heli-tooltip-text {
  max-width: 240px;
  white-space: normal;
}

.heli-tooltip-text strong {
  color: var(--heli-orange-300);
  display: block;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.heli-tooltip-close {
  background: transparent;
  border: none;
  color: var(--heli-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  font-size: 1rem;
}

.heli-tooltip-close:hover {
  color: var(--heli-text);
}

/* ---------- Ventana de Chat ---------- */
.heli-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--heli-navy-950);
  border: 1px solid var(--heli-line-strong);
  border-radius: var(--heli-radius);
  box-shadow: var(--heli-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  font-family: var(--heli-font);
  opacity: 0;
  transform: translateY(20px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.heli-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Cabecera del Chat */
.heli-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--heli-navy-900), var(--heli-navy-800));
  border-bottom: 1px solid var(--heli-line);
}

.heli-header-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.heli-header-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--heli-orange-500);
  overflow: hidden;
  background: var(--heli-navy-700);
}

.heli-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.heli-header-info h3 {
  margin: 0;
  font-family: var(--heli-font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--heli-text);
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.heli-header-pill {
  font-family: var(--heli-font);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--heli-orange-300);
  background: var(--heli-orange-100);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 107, 26, 0.3);
}

.heli-header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--heli-muted);
  margin-top: 2px;
}

.heli-header-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--heli-green);
  display: inline-block;
}

.heli-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.heli-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--heli-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.heli-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--heli-text);
  border-color: var(--heli-line);
}

.heli-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Área de Mensajes */
.heli-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background-color: var(--heli-navy-950);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
}

.heli-chat-body::-webkit-scrollbar {
  width: 6px;
}

.heli-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.heli-chat-body::-webkit-scrollbar-thumb {
  background: var(--heli-navy-700);
  border-radius: 3px;
}

.heli-chat-body::-webkit-scrollbar-thumb:hover {
  background: var(--heli-orange-500);
}

/* Mensaje Fila */
.heli-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: heli-fadeIn 0.25s ease;
}

.heli-msg-row.heli-msg-user {
  flex-direction: row-reverse;
}

@keyframes heli-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.heli-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid var(--heli-orange-500);
  overflow: hidden;
  background: var(--heli-navy-700);
}

.heli-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.heli-msg-bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--heli-text);
  word-break: break-word;
}

.heli-msg-bot .heli-msg-bubble {
  background: var(--heli-navy-900);
  border: 1px solid var(--heli-line);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.heli-msg-user .heli-msg-bubble {
  background: linear-gradient(135deg, var(--heli-orange-500), var(--heli-orange-400));
  color: var(--heli-navy-950);
  font-weight: 500;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(255, 107, 26, 0.3);
}

/* Elementos enriquecidos dentro de los mensajes */
.heli-msg-bubble p {
  margin: 0 0 8px 0;
}

.heli-msg-bubble p:last-child {
  margin-bottom: 0;
}

.heli-msg-bubble strong {
  color: var(--heli-orange-300);
}

.heli-msg-user .heli-msg-bubble strong {
  color: var(--heli-navy-950);
  font-weight: 700;
}

.heli-msg-bubble ul {
  margin: 6px 0 8px 0;
  padding-left: 18px;
  list-style: none;
}

.heli-msg-bubble li {
  position: relative;
  margin-bottom: 4px;
}

.heli-msg-bubble li::before {
  content: "•";
  color: var(--heli-orange-500);
  font-weight: bold;
  position: absolute;
  left: -14px;
}

.heli-msg-time {
  display: block;
  font-size: 0.6875rem;
  color: var(--heli-muted);
  margin-top: 4px;
  text-align: right;
}

.heli-msg-user .heli-msg-time {
  color: rgba(6, 18, 38, 0.7);
}

/* Tarjeta Destacada de Producto dentro del chat */
.heli-card {
  background: var(--heli-navy-950);
  border: 1px solid var(--heli-line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0 4px 0;
}

.heli-card-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--heli-orange-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.heli-card-title {
  font-family: var(--heli-font-display);
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  margin: 0 0 4px 0;
}

.heli-card-desc {
  font-size: 0.8125rem;
  color: var(--heli-text-soft);
  margin: 0;
  line-height: 1.35;
}

/* Botones de acción directa en el mensaje */
.heli-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.heli-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--heli-navy-700);
  color: var(--heli-text);
  border: 1px solid var(--heli-line-strong);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.heli-cta-btn:hover {
  background: var(--heli-orange-500);
  color: var(--heli-navy-950);
  border-color: var(--heli-orange-500);
  transform: translateY(-1px);
}

.heli-cta-btn.heli-cta-primary {
  background: var(--heli-orange-500);
  color: var(--heli-navy-950);
  border-color: var(--heli-orange-500);
}

.heli-cta-btn.heli-cta-primary:hover {
  background: var(--heli-orange-300);
}

.heli-cta-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Indicador de Escritura */
.heli-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--heli-navy-900);
  border: 1px solid var(--heli-line);
  border-radius: 14px;
  border-top-left-radius: 4px;
  width: fit-content;
}

.heli-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--heli-orange-300);
  border-radius: 50%;
  opacity: 0.4;
  animation: heli-typing-bounce 1.3s infinite ease-in-out;
}

.heli-typing-dot:nth-child(1) { animation-delay: 0s; }
.heli-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.heli-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes heli-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* Sugerencias Rápidas (Chips / Pills) */
.heli-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px 16px;
  background: var(--heli-navy-950);
}

.heli-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--heli-line);
  color: var(--heli-text-soft);
  padding: 6px 11px;
  border-radius: 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.heli-chip:hover {
  background: var(--heli-orange-100);
  color: var(--heli-orange-300);
  border-color: var(--heli-line-strong);
  transform: translateY(-1px);
}

/* Barra de Entrada de Texto */
.heli-chat-footer {
  padding: 12px 16px;
  background: var(--heli-navy-900);
  border-top: 1px solid var(--heli-line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.heli-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.heli-input {
  width: 100%;
  min-height: 44px;
  background: var(--heli-navy-950);
  border: 1px solid var(--heli-line-strong);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--heli-text);
  font-size: 0.9375rem;
  font-family: var(--heli-font);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.heli-input:focus {
  border-color: var(--heli-orange-500);
  box-shadow: 0 0 0 3px rgba(255, 107, 26, 0.2);
}

.heli-input::placeholder {
  color: var(--heli-muted);
  font-size: 0.875rem;
}

.heli-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--heli-orange-500);
  color: var(--heli-navy-950);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.heli-send-btn:hover {
  background: var(--heli-orange-300);
  transform: scale(1.06);
}

.heli-send-btn:active {
  transform: scale(0.96);
}

.heli-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Pie informativo / branding */
.heli-footer-brand {
  font-size: 0.6875rem;
  color: var(--heli-muted);
  text-align: center;
  padding-bottom: 6px;
  background: var(--heli-navy-900);
}

.heli-footer-brand a {
  color: var(--heli-orange-300);
  text-decoration: none;
}

/* ---------- Responsividad Móvil ---------- */
@media (max-width: 480px) {
  .heli-launcher {
    bottom: 16px;
    right: 16px;
  }

  .heli-avatar-btn {
    width: 58px;
    height: 58px;
  }

  .heli-avatar-img {
    width: 46px;
    height: 46px;
  }

  .heli-tooltip {
    display: none; /* Evitar ocupar toda la pantalla en móvil */
  }

  .heli-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .heli-chat-header {
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .heli-chat-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}
