/*
-----------------------------------------------------------------------
  Buscador IA global (templates/front_end/_ai_search.html.twig)
  - Campo de búsqueda en la cabecera de todas las páginas
  - Chat del asistente: pantalla completa en móvil, panel a la derecha en escritorio
  - Acceso dentro del menú lateral
  Mobile-first.
-----------------------------------------------------------------------
*/
:root {
  --hs-navy: #0b2350;
  --hs-navy-2: #0b2350;
  --hs-yellow: #ff8f72; /* acento (antes amarillo); el verde queda para destellos */
  --hs-amber: #9fb3d9;
  --hs-violet: #0b2350;
  --hs-cyan: #9fb3d9;
  --hs-orb: radial-gradient(circle at 30% 28%, #dbe4f3 0%, #9fb3d9 34%, #0b2350 72%, #061634 100%);
  --hs-ring: linear-gradient(90deg, var(--hs-violet), var(--hs-yellow), #ff6a45, var(--hs-yellow), var(--hs-violet));
}

@keyframes hs-ring-shift { to { background-position: 300% 50%; } }
@keyframes hs-live { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes hs-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(159, 179, 217, .55); }
  70%  { box-shadow: 0 0 0 12px rgba(159, 179, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(159, 179, 217, 0); }
}
@keyframes hs-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Campo en la cabecera ---------- */
.header-ai-search {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 42px;
  margin: 0 12px 0 0;
  padding: 0 5px 0 14px;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #5b6275;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  text-align: left;
  cursor: text;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
/* Borde de gradiente animado (el "brillo IA") */
.header-ai-search::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: -2px;
  border-radius: inherit;
  background: var(--hs-ring);
  background-size: 300% 100%;
  animation: hs-ring-shift 6s linear infinite;
}
.header-ai-search::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  border-radius: inherit;
  background: #fff;
}
.header-ai-search:hover .header-ai-search-tag { background: var(--marca-marino-hover); }
.header-ai-search:focus-visible { outline: 2px solid var(--hs-yellow); outline-offset: 3px; }
.header-ai-search-icon { flex-shrink: 0; width: 20px; height: 20px; display: block; } /* la lupa de la marca */
.header-ai-search-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-ai-search-tag {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--marca-marino);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  animation: hs-pulse 2.4s ease-out infinite;
}

/* Teléfono: el campo ocupa todo el espacio entre el logo y el menú.
   "Ingresar" y la cuenta pasan al menú lateral.
   Con la barra de chat fija abajo (.con-barra-ia) el campo no se muestra y la cabecera queda normal. */
@media (max-width: 575.98px) {
  .header-area.con-barra-ia .header-ai-search { display: none; }
  .header-area.con-buscador:not(.con-barra-ia) .header-align-end { flex: 1; min-width: 0; margin-left: 10px; }
  .header-area.con-buscador:not(.con-barra-ia) .header-action-area { display: flex; width: 100%; height: 70px; }
  .header-ai-search { flex: 1; margin-right: 4px; }
  .header-area.con-buscador:not(.con-barra-ia) .header-action-area .user-options,
  .header-area.con-buscador:not(.con-barra-ia) .header-action-area .btn-ingresar { display: none !important; }
  .header-area.con-buscador:not(.con-barra-ia) .header-logo-area img { max-width: 132px; }
  .header-area.con-buscador:not(.con-barra-ia) .header-align-end { margin-left: 8px; }
  .header-area.con-buscador:not(.con-barra-ia) .btn-menu { margin-left: 4px; flex-shrink: 0; }
}
/* Teléfonos estrechos: logo más compacto para que se lea "Buscar empresas" completo */
@media (max-width: 359.98px) {
  .header-area.con-buscador:not(.con-barra-ia) .header-logo-area img { max-width: 112px; }
}
@media (max-width: 413.98px) {
  .header-ai-search { gap: 7px; padding-left: 12px; font-size: 13.5px; }
  /* La lupa de la marca ya dice "buscador con IA": la etiqueta cede su espacio al texto */
  .header-ai-search-tag { display: none; }
  .header-ai-search { padding-right: 12px; }
  .header-ai-search-icon { width: 18px; height: 18px; }
}
@media (min-width: 576px) and (max-width: 991.98px) {
  .header-area.con-buscador .header-align-end { flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
  .header-area.con-buscador .header-action-area { flex: 1; justify-content: flex-end; min-width: 0; }
  .header-ai-search { flex: 1; max-width: 360px; }
}
/* Móvil: "Buscar empresas". Escritorio: campo ancho que va alternando ejemplos de cómo preguntar */
.header-ai-search-hint { display: none; }
.header-ai-search-ej { color: var(--hs-navy); font-weight: 600; transition: opacity .25s ease; }
.header-ai-search-ej.is-out { opacity: 0; }
@media (min-width: 992px) {
  .header-area.con-buscador .header-align-end { flex: 1; min-width: 0; display: flex; margin-left: 24px; }
  .header-area.con-buscador .header-action-area { flex: 1; min-width: 0; justify-content: flex-end; }
  .header-area.con-buscador .header-navigation-area { margin-left: 28px; }
  .header-ai-search { flex: 1; max-width: 420px; height: 44px; margin-right: 14px; padding-left: 16px; gap: 10px; font-size: 14.5px; }
  .header-ai-search-lbl { display: none; }
  .header-ai-search-hint { display: inline; }
}
/* Laptops: con cuatro opciones en el menú el ejemplo largo no entra; se muestra "Buscar empresas" y se ajustan los márgenes */
@media (min-width: 992px) and (max-width: 1399.98px) {
  .header-area.con-buscador .header-align-end { margin-left: 12px; }
  .header-area.con-buscador .header-navigation-area { margin-left: 12px; }
  .header-area.con-buscador .header-ai-search { margin-right: 10px; }
  .header-area.con-buscador .header-ai-search-lbl { display: inline; }
  .header-area.con-buscador .header-ai-search-hint { display: none; }
  /* Como en el teléfono: la lupa de la marca ya dice "IA", la etiqueta cede su espacio al texto */
  .header-area.con-buscador .header-ai-search-tag { display: none; }
  .header-area.con-buscador .header-ai-search { gap: 8px; padding-left: 14px; padding-right: 14px; }
}
/* Pantallas de 992 a 1199px: botón compacto (lupa + IA) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .header-area.con-buscador .header-ai-search { flex: none; padding-right: 5px; }
  .header-area.con-buscador .header-ai-search-text { display: none; }
  .header-area.con-buscador .header-ai-search-tag { display: inline-flex; }
}

/* ---------- Chat del asistente (todas las páginas menos /directorio) ----------
   El contenido usa las mismas piezas que el chat de /directorio (ver más abajo). Móvil: hoja
   que sube desde abajo, igual que la de /directorio. Escritorio: panel a la derecha con el
   aspecto de la tarjeta lateral del directorio. */
body.ai-hs-open { overflow: hidden; }
.ai-hs {
  position: fixed;
  inset: 0;
  z-index: 1070;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear .4s;
}
.ai-hs.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.ai-hs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 35, 80, .55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .3s ease;
}
.ai-hs.is-open .ai-hs-backdrop { opacity: 1; }
.ai-hs-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--kb, 0px); /* la caja de escribir queda sobre el teclado del teléfono */
  height: 82vh;
  height: min(82dvh, calc(100dvh - var(--kb, 0px) - 12px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f6f7fb;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(11, 35, 80, .3);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform .42s cubic-bezier(.22, 1, .36, 1);
}
.ai-hs.is-open .ai-hs-panel { transform: none; }
.kb-abierto .ai-hs-panel { padding-bottom: 0; border-radius: 16px 16px 0 0; }
/* Franja de gradiente IA en el borde superior */
.ai-hs-panel::before {
  content: '';
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ai-yellow), var(--ai-amber), var(--ai-violet), var(--ai-cyan), var(--ai-yellow));
  background-size: 200% 100%;
  animation: ai-shimmer 3s linear infinite;
}
.ai-hs-top {
  flex-shrink: 0;
  padding: 8px 14px 10px;
  touch-action: none; /* deslizar hacia abajo cierra la hoja */
  background: #fff;
  border-bottom: 1px solid #eceef4;
}
.ai-hs-handle {
  display: block;
  width: 40px;
  height: 4px;
  margin: 2px auto 10px;
  border-radius: 4px;
  background: #d4d8e3;
}
.ai-hs-top .ai-panel-header { padding: 0; margin: 0; border: 0; }
.ai-hs-top .ai-panel-title { font-size: 16px; }
.ai-hs-top .ai-panel-status { font-size: 11.5px; }
.ai-hs-top .ai-panel-icon-btn { width: 36px; height: 36px; background: #f0f1f6; color: #495066; font-size: 15px; }
.ai-hs-top .ai-panel-icon-btn:hover { background: #e3e5ee; }
.ai-hs-top .ai-panel-icon-btn[hidden] { display: none; }

.ai-hs-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 14px 10px;
}
.ai-hs-body .ai-chat-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin-bottom: 8px;
  padding: 14px 2px 8px;
  overscroll-behavior: contain;
}
.ai-hs-body .ai-chat-text { max-width: 86%; font-size: 14px; }
.ai-hs-body .ai-chat-avatar { width: 28px; height: 28px; font-size: 12px; }
/* Sugerencias en una sola fila deslizable: ahorra altura */
.ai-hs-body .ai-chat-suggestions {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 -14px 10px;
  padding: 0 14px 2px;
  scrollbar-width: none;
}
.ai-hs-body .ai-chat-suggestions[hidden] { display: none; }
.ai-hs-body .ai-chat-suggestions::-webkit-scrollbar { display: none; }
.ai-hs-body .ai-chat-suggestions-title { display: none; }
.ai-hs-body .ai-chat-suggestion {
  flex: 0 0 200px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
  padding: 9px 12px;
}
.ai-hs-body .ai-chat-suggestion-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-hs-form { margin: 0; }
/* 16px evita el zoom automático de iOS al enfocar el campo */
.ai-hs-body .ai-chat-input { font-size: 16px; min-width: 0; }
.ai-hs-body .ai-chat-input::-webkit-search-cancel-button { display: none; }
.ai-hs-body .ai-chat-send { width: 40px; height: 40px; font-size: 15px; }

/* Escritorio: panel a la derecha con el aspecto de la tarjeta lateral de /directorio */
@media (min-width: 768px) {
  .ai-hs-panel {
    left: auto;
    top: 0;
    bottom: 0;
    height: auto;
    width: 420px;
    padding: 18px 18px 16px;
    border-radius: 0;
    box-shadow: -20px 0 60px rgba(0, 0, 0, .3);
    opacity: 0;
    transform: translateX(32px);
    transition: opacity .25s ease, transform .3s cubic-bezier(.22, 1, .36, 1);
  }
  .ai-hs.is-open .ai-hs-panel { opacity: 1; }
  .ai-hs-handle { display: none; }
  .ai-hs-top { padding: 0; background: transparent; border: 0; touch-action: auto; }
  .ai-hs-top .ai-panel-header { padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid #e7e9f0; }
  .ai-hs-top .ai-panel-title { font-size: 17px; }
  .ai-hs-top .ai-panel-status { font-size: 12px; }
  .ai-hs-top .ai-panel-icon-btn { width: 34px; height: 34px; background: transparent; color: #9aa0b4; font-size: 14px; }
  .ai-hs-top .ai-panel-icon-btn:hover { background: #eceef4; color: #495066; }
  .ai-hs-body { padding: 0; }
  .ai-hs-body .ai-chat-messages { padding: 12px 4px 0 0; margin-bottom: 14px; }
  .ai-hs-body .ai-chat-text { max-width: 82%; font-size: 13px; }
  .ai-hs-body .ai-chat-avatar { width: 26px; height: 26px; font-size: 11px; }
  .ai-hs-body .ai-chat-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    overflow: visible;
    margin: 0 0 12px;
    padding: 0;
  }
  .ai-hs-body .ai-chat-suggestions-title { display: block; }
  .ai-hs-body .ai-chat-suggestion { flex-direction: column; align-items: flex-start; gap: 8px; margin: 0; padding: 10px 11px; }
  .ai-hs-body .ai-chat-suggestion-text small { white-space: normal; }
  .ai-hs-body .ai-chat-input { font-size: 14px; }
  .ai-hs-body .ai-chat-send { width: 34px; height: 34px; font-size: 13px; }
}

/* ---------- Piezas del chat compartidas con /directorio ----------
   Antes vivían en directorio.css; aquí las usan los dos chats para verse iguales. */
/* --- Chat --- */
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
}
.ai-chat-bubble {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.ai-chat-bubble-user { flex-direction: row-reverse; }

.ai-chat-avatar {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef2f8;
  color: #9fb3d9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.ai-chat-bubble-user .ai-chat-avatar {
  background: #0b2350;
  color: #fff;
}

.ai-chat-text {
  background: #fff;
  border: 1px solid #e7e9f0;
  color: #1a1a2e;
  font-size: 13px;
  line-height: 1.45;
  padding: 9px 13px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  max-width: 82%;
}
.ai-chat-bubble-user .ai-chat-text {
  background: #0b2350;
  color: #fff;
  border-color: #0b2350;
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}

/* --- Formato dentro de la respuesta del bot (negritas, listas) --- */
.ai-chat-text p { margin: 0 0 6px; }
.ai-chat-text p:last-child { margin-bottom: 0; }
.ai-chat-text ul.ai-chat-list {
  margin: 2px 0 6px;
  padding-left: 18px;
}
.ai-chat-text ul.ai-chat-list li { margin-bottom: 3px; }
.ai-chat-text ul.ai-chat-list:last-child { margin-bottom: 0; }
.ai-chat-text strong { color: #0b2350; }
.ai-chat-bubble-user .ai-chat-text strong { color: #fff; }
/* Nombre de empresa en la respuesta: lleva a su ficha (se ve tocable, sin parecer un párrafo de enlaces) */
.ai-chat-text a.ai-chat-empresa {
	color: #0b2350;
	text-decoration: underline;
	text-decoration-color: #ff6a45;
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
}
.ai-chat-text a.ai-chat-empresa:hover,
.ai-chat-text a.ai-chat-empresa:focus-visible { color: #ff6a45; }

/* --- El asistente pide permiso de ubicación (búsqueda por cercanía, directorio.html.twig) --- */
.ai-chat-ubicacion .ai-chat-text,
.ai-chat-sugerencia .ai-chat-text { border-color: #ffd3c6; background: #fff8f5; }
.ai-ubicacion-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.ai-ubicacion-acciones button,
.ai-ubicacion-acciones a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ai-ubicacion-si {
  flex: 1 1 auto;
  border: none;
  background: #ff6a45;
  color: #fff;
}
.ai-ubicacion-si:hover:not(:disabled) { background: #f0552e; color: #fff; }
a.ai-ubicacion-si { text-decoration: none; }
.ai-ubicacion-no {
  border: 1px solid #d5d9e4;
  background: #fff;
  color: #495066;
}
.ai-ubicacion-no:hover:not(:disabled) { border-color: #0b2350; color: #0b2350; }
.ai-ubicacion-acciones button:disabled { opacity: .7; cursor: default; }
.ai-ubicacion-acciones a:focus-visible,
.ai-ubicacion-acciones button:focus-visible { outline: 2px solid #0b2350; outline-offset: 2px; }

/* Mientras el navegador muestra su aviso de ubicación (chat que se abre desde otras páginas) */
.ai-ubicacion-espera {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  color: #c8441f;
}
.ai-ubicacion-espera i { animation: ai-ubicacion-pulso 1.2s ease-in-out infinite; }
@keyframes ai-ubicacion-pulso { 50% { opacity: .35; } }

/* --- Registro desde el chat (al agotar las búsquedas gratis): mismos botones que el permiso de ubicación --- */
.ai-chat-registro .ai-chat-text { border-color: #ffd3c6; background: #fff8f5; }

/* --- Búsquedas recientes del usuario con sesión iniciada: se repiten con un toque --- */
.ai-chat-recientes { margin: 4px 0 12px 44px; }
.ai-chat-recientes-titulo { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: #6b7189; }
.ai-chat-recientes-lista { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chat-reciente {
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid #d5d9e4;
  border-radius: 999px;
  background: #fff;
  color: #0b2350;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ai-chat-reciente:hover { border-color: #ff6a45; color: #c8441f; }
.ai-chat-reciente:focus-visible { outline: 2px solid #0b2350; outline-offset: 2px; }
.ai-chat-reciente[hidden] { display: none; }
.ai-chat-reciente-mas { border-style: dashed; color: #6b7189; }
@media (max-width: 575.98px) { .ai-chat-recientes { margin-left: 0; } }

/* --- Cursor parpadeante durante el efecto de escritura --- */
.ai-typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #0b2350;
  margin-left: 2px;
  vertical-align: -2px;
  animation: ai-cursor-blink 0.8s steps(1) infinite;
}
@keyframes ai-cursor-blink { 50% { opacity: 0; } }

/* --- Ideas para empezar (tarjetas) --- */
.ai-chat-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.ai-chat-suggestions[hidden] { display: none; }
.ai-chat-suggestions-title {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9aa0b4;
}
.ai-chat-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  background: #fff;
  border: 1px solid #e7e9f0;
  color: #495066;
  text-align: left;
  padding: 10px 11px;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.ai-chat-suggestion:hover {
  border-color: #b8c6e3;
  box-shadow: 0 6px 16px -10px rgba(11, 35, 80, .6);
  transform: translateY(-1px);
}
.ai-chat-suggestion-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #0b2350;
  background: #eef2f8;
}
.ai-chat-suggestion:nth-of-type(2) .ai-chat-suggestion-icon { color: #1e3a70; background: #eef2f8; }
.ai-chat-suggestion:nth-of-type(3) .ai-chat-suggestion-icon { color: #0e9fb8; background: #e0f8fc; }
.ai-chat-suggestion:nth-of-type(4) .ai-chat-suggestion-icon { color: #0b2350; background: #fff0eb; }
.ai-chat-suggestion-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ai-chat-suggestion-text strong {
  font-size: 12.5px;
  color: #0b2350;
}
.ai-chat-suggestion-text small {
  font-size: 11.5px;
  line-height: 1.35;
  color: #6b7186;
}

.ai-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  /* Resaltada de forma sutil: es donde empieza todo */
  border: 1.5px solid #ffc4b3;
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  box-shadow: 0 0 0 4px rgba(255, 106, 69, .08), 0 6px 18px -10px rgba(11, 35, 80, .35);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.ai-chat-input-row:focus-within {
  border-color: var(--marca-coral);
  box-shadow: 0 0 0 4px rgba(255, 106, 69, .18), 0 6px 18px -10px rgba(11, 35, 80, .35);
}
.ai-chat-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--marca-marino);
  background: transparent;
}
/* Los ejemplos que se escriben solos se leen, pero claramente como ejemplo */
.ai-chat-input::placeholder { color: #7d849b; opacity: 1; }
.ai-chat-send {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--marca-coral);
  color: var(--marca-tinta);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s ease, transform .1s ease;
}
.ai-chat-send:hover { background: var(--marca-coral-hover); }
.ai-chat-send:active { transform: scale(0.94); }

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid #e7e9f0;
}
.ai-panel-heading { flex: 1; min-width: 0; }
.ai-panel-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  color: #0b2350;
}
.ai-panel-status {
  display: block;
  font-size: 12px;
  color: #6b7186;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-panel-status .ai-live-dot { width: 6px; height: 6px; margin-right: 2px; }
.ai-panel-icon-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #9aa0b4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ai-panel-icon-btn:hover { background: #eceef4; color: #495066; }

/* =====================================================================
   Identidad visual de la IA (escritorio y móvil)
   ===================================================================== */
:root {
  --ai-navy: #0b2350;
  --ai-yellow: #ff8f72;
  --ai-amber: #9fb3d9;
  --ai-violet: #0b2350;
  --ai-cyan: #9fb3d9;
}

@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(159, 179, 217, .55); }
  70%  { box-shadow: 0 0 0 12px rgba(159, 179, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(159, 179, 217, 0); }
}
@keyframes ai-sparkle {
  0%, 100% { transform: rotate(0) scale(1); }
  50%      { transform: rotate(-14deg) scale(1.15); }
}
@keyframes ai-live {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
@keyframes ai-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ai-shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -150% 0; }
}

/* Orbe de la IA: gradiente con pulso */
.ai-orb {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  background: var(--marca-marino);
  animation: ai-pulse 2.4s ease-out infinite;
}
.ai-orb i { animation: ai-sparkle 2.4s ease-in-out infinite; }
.ai-orb-sm { width: 36px; height: 36px; font-size: 14px; }

.ai-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff6a45;
  box-shadow: 0 0 6px #ff6a45;
  vertical-align: middle;
  animation: ai-live 1.6s ease-in-out infinite;
}

/* Avatar del bot: la lupa del logo sobre marino, como el resto de íconos del asistente */
.ai-chat-bubble-bot .ai-chat-avatar {
  background: var(--marca-marino);
  color: #fff;
}
.ai-chat-bubble-bot .ai-chat-text { animation: ai-fade-in .3s ease both; }

/* --- IA pensando --- */
.ai-chat-avatar-thinking { position: relative; }
.ai-chat-avatar-thinking::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--ai-violet);
  border-right-color: var(--ai-cyan);
  animation: ai-spin .9s linear infinite;
}
.ai-chat-text.ai-thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  border-color: #dde5f2;
  background: linear-gradient(100deg, #fff 20%, #eef2f8 45%, #fff8d6 55%, #fff 80%);
  background-size: 250% 100%;
  animation: ai-shimmer 1.8s linear infinite;
}
.ai-thinking-dots { display: inline-flex; gap: 4px; }
.ai-thinking-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-violet);
  animation: ai-bounce 1.1s ease-in-out infinite;
}
.ai-thinking-dots i:nth-child(2) { background: var(--ai-amber); animation-delay: .15s; }
.ai-thinking-dots i:nth-child(3) { background: var(--ai-cyan); animation-delay: .3s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40%           { transform: translateY(-5px); opacity: 1; }
}
.ai-thinking-label { font-size: 12.5px; color: #495066; }
.ai-fade { animation: ai-fade-in .35s ease; }

/* ---------- Acceso dentro del menú lateral ---------- */
.aside-ai-search {
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 32px);
  margin: 16px 16px 14px;
  padding: 12px 14px;
  border: 1px solid rgba(11, 35, 80, .45);
  border-radius: 16px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(11, 35, 80, .2), transparent 60%),
    var(--hs-navy);
  color: #fff;
  text-align: left;
}
.aside-ai-search-orb {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--marca-marino);
  border: 1px solid rgba(255, 255, 255, .18); /* el menú lateral también es marino */
  color: #fff;
  font-size: 15px;
}
.aside-ai-search-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aside-ai-search-body strong { font-size: 15px; color: #fff; }
.aside-ai-search-body small { font-size: 12.5px; color: #c9cfdc; }
.aside-ai-search > i { color: var(--hs-yellow); }

.aside-account { display: flex; gap: 8px; margin: 0 16px 16px; }
.aside-account-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 1px solid var(--hs-navy);
  border-radius: 999px;
  color: var(--hs-navy);
  font-weight: 600;
}
.aside-account-btn.is-primary { border-color: var(--marca-violeta); background: var(--marca-violeta); color: #fff; }
.aside-account-btn:hover { color: inherit; filter: brightness(1.08); }

@media (prefers-reduced-motion: reduce) {
  .header-ai-search::before,
  .header-ai-search-tag,
  .ai-hs-panel::before,
  .ai-orb,
  .ai-orb i,
  .ai-live-dot,
  .ai-chat-avatar-thinking::after,
  .ai-chat-text.ai-thinking,
  .ai-thinking-dots i,
  .ai-chat-bubble-bot .ai-chat-text { animation: none !important; }
  .ai-hs-panel, .ai-hs-backdrop { transition: none; }
}



/* Seis enlaces en el menú: entre 992 y 1399px se compacta el espaciado para que quepan en una fila */
@media (min-width: 992px) {
  .header-area .header-navigation-area .main-menu.nav { flex-wrap: nowrap; }
  .header-area .header-action-area { flex-wrap: nowrap; }
  .header-area .header-action-area .user-options { margin-right: 12px; }
}
/* Botón principal de la cabecera: coral (la chispa de la marca); el marino se perdería sobre el fondo */
.header-area .header-action-area .btn-theme:not(.btn-white) { background-color: var(--marca-coral); border-color: var(--marca-coral); color: var(--marca-tinta); }
.header-area .header-action-area .btn-theme:not(.btn-white):hover { background-color: var(--marca-coral-hover); border-color: var(--marca-coral-hover); color: var(--marca-tinta); }
/* Móvil: el logo horizontal es ancho; se limita para que no choque con "Ingresar" */
@media (max-width: 575.98px) {
  .header-area .header-logo-area img { max-width: 150px; }
}
@media (max-width: 359.98px) {
  .header-area .header-logo-area img { max-width: 126px; }
}
@media (min-width: 1400px) {
  .header-area .header-navigation-area .main-menu.nav > li > a { margin: 0 8px; padding: 0 8px; white-space: nowrap; }
  .header-area .header-navigation-area .main-menu.nav > li:first-child > a { margin-left: 0; padding-left: 0; }
  .header-area .header-action-area .btn-theme { width: auto; padding-left: 22px; padding-right: 22px; white-space: nowrap; }
}
@media (min-width: 992px) and (max-width: 1399.98px) {
  .header-area .header-navigation-area .main-menu.nav > li > a { margin: 0 5px; padding: 0 5px; white-space: nowrap; }
  .header-area .header-navigation-area .main-menu.nav > li:first-child > a { margin-left: 0; padding-left: 0; }
  .header-area .header-action-area .btn-theme { white-space: nowrap; }
}
@media (min-width: 992px) and (max-width: 1199.98px) {
  .header-area .header-navigation-area .main-menu.nav > li > a { margin: 0 3px; padding: 0 3px; font-size: 14px; }
  /* Con sesión iniciada: solo el avatar, el nombre está en el menú desplegable */
  .header-area .user-options .avatar span:nth-child(2) { display: none; }
  .header-area .user-options { margin-right: 8px; }
}

/* Barra superior "Busco empresas / Soy empresa" (escritorio).
   Mide 30px y el menú principal baja de 88px a 58px (78 → 48 bajo 1200px),
   así la cabecera conserva su altura y no se mueve el contenido de las páginas. */
.header-topbar { display: none; }
@media (min-width: 992px) {
  .header-topbar { display: block; background: rgba(0, 0, 0, 0.28); border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
  .header-topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 29px; }
  .header-topbar-links li { display: flex; }
  .header-segmentos, .header-topbar-links { display: flex; align-items: stretch; height: 100%; margin: 0; padding: 0; list-style: none; }
  .header-segmentos { gap: 22px; }
  .header-topbar-links { gap: 20px; }
  .header-segmentos a, .header-topbar-links a {
    display: flex; align-items: center; position: relative;
    font-size: 13px; line-height: 1; color: rgba(255, 255, 255, 0.72); white-space: nowrap;
  }
  .header-segmentos a:hover, .header-topbar-links a:hover { color: #fff; }
  .header-segmentos a.is-active { color: #fff; font-weight: 600; }
  .header-segmentos a.is-active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    border-radius: 3px 3px 0 0; background: #ff6a45;
  }
  .header-area .header-navigation-area .main-menu.nav > li > a { height: 58px; line-height: 58px; }
  .header-area .header-logo-area img { max-width: 220px; } /* logo horizontal: ~30px de alto */
}
@media (min-width: 992px) and (max-width: 1199px) {
  .header-area .header-navigation-area .main-menu.nav > li > a { height: 48px; line-height: 48px; }
  .header-area .header-logo-area img { max-width: 190px; }
}

/* Menú lateral (móvil): mismo selector como control segmentado */
.aside-segmentos { display: flex; gap: 4px; margin: 8px 16px 14px; padding: 4px; border-radius: 12px; background: rgba(11, 35, 80, 0.08); }
.aside-segmentos a {
  flex: 1; padding: 10px 8px; border-radius: 9px; text-align: center;
  font-size: 15px; font-weight: 500; line-height: 1.2; color: #0b2350; white-space: nowrap;
}
.aside-segmentos a.is-active { background: #0b2350; color: #fff; font-weight: 600; box-shadow: 0 2px 6px rgba(11, 35, 80, 0.18); }

/* ---------- Barra flotante del chat (móvil) ----------
   Fija abajo desde que carga la página; tocarla abre el chat. /directorio tiene la suya (.ai-mbar). */
.ai-flot { display: none; }
@media (max-width: 575.98px) {
  .ai-flot {
    display: block;
    position: fixed;
    z-index: 1030;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e3e6ee;
    box-shadow: 0 -6px 20px -12px rgba(11, 35, 80, .3);
    transform: translateY(110%);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
  }
  .ai-flot.is-visible { transform: none; }
  body.ai-hs-open .ai-flot { visibility: hidden; }
  .ai-flot-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 4px 4px 4px 6px;
    border: 1.5px solid transparent;
    border-radius: 999px;
    background: linear-gradient(#fff, #fff) padding-box, var(--hs-ring) border-box;
    background-size: 100% 100%, 300% 100%;
    color: #6b7286;
    font-size: 15px;
    text-align: left;
    animation: hs-ring-shift 6s linear infinite;
  }
  .ai-flot-orb {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--marca-marino);
    color: #fff;
    font-size: 14px;
  }
  .ai-flot-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; color: var(--hs-navy); font-weight: 600; white-space: nowrap; overflow: hidden; }
  .ai-flot-ej { color: #6b7286; font-size: 12.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; transition: opacity .25s ease; }
  .ai-flot-ej:empty { display: none; }
  .ai-flot-ej.is-out { opacity: 0; }

  /* Primera aparición: la barra sube con un pequeño rebote y su borde brilla dos veces */
  .ai-flot.is-nueva.is-visible { animation: ai-flot-entra .6s cubic-bezier(.34, 1.56, .64, 1) both; }
  .ai-flot.is-nueva .ai-flot-btn { animation: hs-ring-shift 6s linear infinite, ai-flot-brillo 1.4s ease-out .5s 2; }
  .ai-flot.is-nueva .ai-flot-orb { animation: ai-flot-orb 1.4s ease-out .5s 2; }
  @keyframes ai-flot-entra { from { transform: translateY(110%); } to { transform: none; } }
  @keyframes ai-flot-brillo {
    0%   { box-shadow: 0 0 0 0 rgba(11, 35, 80, .45); }
    70%  { box-shadow: 0 0 0 10px rgba(11, 35, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(11, 35, 80, 0); }
  }
  @keyframes ai-flot-orb { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.15) rotate(-8deg); } }

  /* Aviso sobre la barra: aparece una vez, se va solo a los 5 s o al tocarlo */
  .ai-flot-aviso {
    position: absolute;
    left: 16px;
    bottom: calc(100% + 10px);
    max-width: calc(100% - 32px);
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--hs-navy);
    color: #fff;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: 0 10px 30px -10px rgba(11, 35, 80, .5);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
  }
  .ai-flot-aviso strong { color: var(--hs-yellow); }
  .ai-flot-aviso::after { /* piquito hacia la barra */
    content: '';
    position: absolute;
    left: 24px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: var(--hs-navy);
    transform: rotate(45deg);
  }
  .ai-flot-aviso.is-visible { opacity: 1; transform: none; pointer-events: auto; transition-delay: .5s; }
  .ai-flot-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--marca-violeta);
    color: #fff;
    font-size: 15px;
  }
  /* Con la barra visible, el botón flotante de subir se coloca encima */
  body.ai-flot-on .scroll-to-top.show { bottom: 84px; }
  body.ai-flot-on { padding-bottom: 72px; } /* el final de la página no queda bajo la barra */
}
@media (prefers-reduced-motion: reduce) {
  .ai-flot, .ai-flot-btn, .ai-flot-orb, .ai-flot-aviso,
  .ai-flot.is-nueva.is-visible, .ai-flot.is-nueva .ai-flot-btn, .ai-flot.is-nueva .ai-flot-orb { transition: none; animation: none; }
}

/* ---------- Campana de notificaciones (cabecera, con sesión iniciada) ----------
   Se ve también en el teléfono: ahí la cuenta pasa al menú lateral, pero los avisos no deben esconderse */
.notif { position: relative; flex-shrink: 0; margin-right: 10px; }
.notif-boton {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border: 1px solid rgba(255,255,255,.28); border-radius: 50%;
  background: transparent; color: #fff; font-size: 17px; cursor: pointer; transition: background-color .15s, border-color .15s;
}
.notif-boton:hover, .notif-boton[aria-expanded="true"] { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5); }
.notif-boton:focus-visible { outline: 2px solid var(--marca-coral); outline-offset: 2px; }
.notif-contador {
  position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px;
  border: 2px solid #0b2350; border-radius: 999px; background: var(--marca-coral); color: #0b2350;
  font-size: 11px; font-weight: 800; line-height: 15px; text-align: center;
}
.notif-menu {
  width: 360px; max-width: calc(100vw - 32px); padding: 0; border: 1px solid #e3e6ef; border-radius: 14px;
  box-shadow: 0 14px 40px rgba(11,35,80,.18); overflow: hidden;
}
.notif-cabecera { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid #eef0f5; }
.notif-titulo { color: #0b2350; font-size: 15px; font-weight: 800; }
.notif-leidas { padding: 0; border: 0; background: none; color: #c8441f; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.notif-leidas:hover { text-decoration: underline; }
.notif-vacio { margin: 0; padding: 22px 16px; color: #6b7186; font-size: 14px; text-align: center; }
.notif-lista { max-height: min(420px, 70vh); margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.notif-lista li + li { border-top: 1px solid #f1f3f8; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; color: #2b3148; text-decoration: none; }
.notif-item:hover, .notif-item:focus-visible { background: #f6f8fc; color: #2b3148; }
.notif-item.is-nueva { background: #fff6f2; }
.notif-item.is-nueva:hover { background: #ffeee6; }
.notif-icono { flex-shrink: 0; margin-top: 2px; color: #0b2350; font-size: 18px; }
.notif-item.is-nueva .notif-icono { color: #e2552f; }
.notif-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; line-height: 1.45; }
.notif-texto strong { color: #0b2350; font-size: 14px; }
.notif-texto time { color: #8a90a6; font-size: 12px; }
@media (max-width: 575.98px) {
  .notif { margin-right: 6px; }
  .notif-boton { width: 38px; height: 38px; font-size: 16px; }
  /* En el teléfono el menú se ancla al borde derecho de la pantalla */
  .notif-menu { position: fixed !important; inset: 64px 16px auto 16px !important; width: auto; max-width: none; transform: none !important; }
}
