/* Asistente virtual de Gonzalo Assessors: botón y ventana de chat.
   Usa las variables de color y tipografía de la web (v5.css). Sin animaciones de movimiento: solo fundidos suaves. */

.gac-launcher {
  position: fixed; z-index: 45;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 20px 0 16px; border: 0; border-radius: 26px;
  background: var(--brand, #231a5d); color: #fff;
  font: 600 16px/1 var(--body, "Roboto Condensed", Arial, sans-serif); letter-spacing: .02em;
  box-shadow: 0 8px 22px rgba(22, 15, 64, .28); cursor: pointer;
  transition: background-color .2s, opacity .2s;
}
.gac-launcher:hover { background: var(--brand-mid, #3b2f86); }
.gac-launcher svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gac-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; }
@media (max-width: 560px) {
  .gac-launcher { width: 54px; height: 54px; padding: 0; justify-content: center; border-radius: 50%; }
  .gac-launcher .gac-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* El botón de volver arriba sube para no quedar debajo del chat */
.to-top { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }

.gac-panel {
  position: fixed; z-index: 46;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 380px; height: min(600px, calc(100vh - 120px)); height: min(600px, calc(100dvh - 120px));
  display: flex; flex-direction: column;
  background: var(--card, #fffdf9); color: var(--ink, #2a2622);
  border: 1px solid var(--line, #e4ddd0); border-radius: 12px; overflow: hidden;
  box-shadow: 0 18px 48px rgba(22, 15, 64, .22);
  font-family: var(--body, "Roboto Condensed", Arial, sans-serif); font-size: 16px; line-height: 1.5;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s linear .2s;
}
.gac-panel.gac-open { opacity: 1; visibility: visible; transition: opacity .2s; }
@media (max-width: 560px) {
  .gac-panel {
    left: 0; right: 0; bottom: 0; width: auto;
    height: 86vh; height: 86dvh; border-radius: 14px 14px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.gac-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px; background: var(--brand, #231a5d); color: #fff; }
.gac-head-text { flex: 1; min-width: 0; }
.gac-title { margin: 0; font: 700 18px/1.2 var(--head, "Inria Sans", Arial, sans-serif); color: #fff; }
.gac-sub { margin: 2px 0 0; font-size: 13px; opacity: .85; }
.gac-icon-btn {
  flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer;
}
.gac-icon-btn:hover { background: rgba(255, 255, 255, .14); }
.gac-icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.gac-notice {
  margin: 0; padding: 9px 18px; font-size: 13px; line-height: 1.45;
  color: var(--muted, #6b6259); background: var(--brand-soft, #efe7d8); border-bottom: 1px solid var(--line, #e4ddd0);
}
.gac-notice a { color: var(--brand, #231a5d); font-weight: 600; }

.gac-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.gac-msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.gac-bot { align-self: flex-start; background: #fff; border: 1px solid var(--line, #e4ddd0); border-bottom-left-radius: 4px; }
.gac-user { align-self: flex-end; background: var(--brand, #231a5d); color: #fff; border-bottom-right-radius: 4px; }
.gac-error { align-self: stretch; max-width: none; background: #fff6d6; border: 1px solid #ecd9a0; color: #5c4a12; font-size: 14px; }

.gac-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 13px 14px; background: #fff; border: 1px solid var(--line, #e4ddd0); border-radius: 14px; border-bottom-left-radius: 4px; }
.gac-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted, #6b6259); opacity: .35; animation: gac-fade 1.4s infinite ease-in-out; }
.gac-typing span:nth-child(2) { animation-delay: .2s; }
.gac-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes gac-fade { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .gac-typing span { animation: none; opacity: .5; } }

.gac-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px; }
.gac-chip {
  border: 1px solid var(--brand, #231a5d); background: transparent; color: var(--brand, #231a5d);
  border-radius: 18px; padding: 6px 12px; font: 500 14px/1.3 var(--body, "Roboto Condensed", Arial, sans-serif); cursor: pointer; text-align: left;
}
.gac-chip:hover { background: var(--brand, #231a5d); color: #fff; }

.gac-card { align-self: stretch; border: 1px solid #c9d8c2; background: #f3f8f0; border-radius: 10px; padding: 11px 13px; font-size: 14px; }
.gac-card-title { margin: 0 0 6px; font-weight: 700; color: #2f5a22; }
.gac-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.gac-card dt { color: var(--muted, #6b6259); }
.gac-card dd { margin: 0; overflow-wrap: anywhere; }
.gac-card-note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted, #6b6259); }

.gac-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--line, #e4ddd0); background: var(--card, #fffdf9); }
.gac-input {
  flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: 10px 12px;
  border: 1px solid var(--line, #e4ddd0); border-radius: 10px; background: #fff; color: var(--ink, #2a2622);
  font: 16px/1.4 var(--body, "Roboto Condensed", Arial, sans-serif);
}
.gac-input:focus { outline: 2px solid #8f86d6; outline-offset: 0; border-color: transparent; }
.gac-send {
  flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: var(--brand, #231a5d); color: #fff; cursor: pointer;
}
.gac-send:hover { background: var(--brand-mid, #3b2f86); }
.gac-send:disabled { opacity: .45; cursor: default; }
.gac-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.gac-foot { display: flex; justify-content: space-between; gap: 10px; padding: 2px 14px 10px; font-size: 12.5px; color: var(--muted, #6b6259); }
.gac-foot a { color: inherit; }
.gac-restart { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; }

.gac-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sin la clave de la IA puesta en el servidor, el asistente no se muestra */
.gac-launcher[hidden], .gac-panel[hidden] { display: none !important; }

/* Los mensajes se apilan desde abajo, junto a la caja de texto */
.gac-log > :first-child { margin-top: auto; }

/* Móvil escribiendo (teclado abierto): la ventana ocupa la parte visible y se compacta.
   La altura y la posición las pone chat.js. El aviso de IA se ha visto al abrir el chat
   y el subtítulo «Respuestas automáticas con IA» se queda en la cabecera. */
@media (max-width: 560px) {
  .gac-panel.gac-kb { border-radius: 0; border-top: 0; padding-bottom: 0; }
  .gac-panel.gac-kb .gac-notice, .gac-panel.gac-kb .gac-foot { display: none; }
  .gac-panel.gac-kb .gac-head { padding-top: 8px; padding-bottom: 8px; }
  .gac-panel.gac-kb .gac-title { font-size: 16px; }
  .gac-panel.gac-kb .gac-log { padding-top: 10px; }
  .gac-panel.gac-kb .gac-form { padding-bottom: 8px; }
}
