/* ==========================================================================
   Asistente de IA — "Pregúntale a Focal Point"
   Solo se carga cuando el chat está activo (Focal Point → Chat IA).
   Usa los tokens de style.css (--paper, --ink, --accent, …).
   ========================================================================== */

/* ---- Botón del header (reemplaza el ícono de búsqueda) ---- */
.header-chat__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 38px;
  padding: 0 0.95rem 0 0.8rem;
  background: var(--accent);
  color: var(--ink);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
}
.header-chat__toggle:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.header-chat__toggle svg { flex: none; }
.header-chat__label--short { display: none; }
@media (max-width: 900px) {
  .header-chat__label--full { display: none; }
  .header-chat__label--short { display: inline; }
}

/* ---- Campo del hero ---- */
.hero-ask { margin-top: 1.75rem; max-width: 34rem; }
.hero-ask__field { display: flex; }
.hero-ask__field input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  background: var(--white);
  border: 1px solid var(--ink);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
}
.hero-ask__field input[type="search"]::placeholder { color: var(--muted); }
.hero-ask__field button {
  padding: 0 1.3rem;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.hero-ask__field button:hover { background: var(--ink-soft); }
.hero-ask__hint { display: block; margin: 1.1rem 0 0.55rem; font-size: var(--step-label); color: var(--muted); }
.hero-ask__chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.hero-ask__chip {
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  line-height: 1.3;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
}
.hero-ask__chip:hover { border-color: var(--ink); color: var(--ink); }
.hero-ask__chips li:nth-child(n+4) { display: none; } /* el hero muestra 3; el panel del chat muestra todas */

/* ---- Panel lateral ---- */
html.fp-chat-lock { overflow: hidden; }

.fp-chat__overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.38);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s 0.2s;
  z-index: 99;
}
.fp-chat__overlay.is-open { opacity: 1; visibility: visible; transition: opacity 0.2s ease; }

.fp-chat {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--ink);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
  z-index: 100;
}
.fp-chat.is-open { transform: none; visibility: visible; transition: transform 0.25s ease; }
@media (max-width: 640px) {
  .fp-chat { width: 100vw; border-left: 0; }
}

.fp-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.fp-chat__eyebrow { margin: 0 0 0.3rem; font-size: var(--step-label); color: var(--muted); }
.fp-chat__eyebrow .mark { color: var(--accent); }
.fp-chat__title { font-size: 1.4rem; }
.fp-chat__head-actions { display: flex; align-items: center; gap: 0.6rem; }
.fp-chat__reset,
.fp-chat__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
}
.fp-chat__reset:hover,
.fp-chat__close:hover { border-color: var(--ink); }
.fp-chat__reset[hidden] { display: none; }

/* ---- Conversación ---- */
.fp-chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.25rem;
}
.fp-chat__log:focus-visible { outline-offset: -3px; }

.fp-chat__empty p { margin: 0 0 0.9rem; color: var(--ink-soft); font-size: 1rem; }
.fp-chat__empty-label { margin: 1.4rem 0 0.6rem !important; font-size: var(--step-label) !important; color: var(--muted) !important; }
.fp-chat__chips { display: flex; flex-direction: column; gap: 0.5rem; }
.fp-chat__chip {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.fp-chat__chip:hover { border-color: var(--ink); }

.fp-msg { font-size: 1rem; line-height: 1.55; }
.fp-msg p { margin: 0; }

.fp-msg--user {
  align-self: flex-end;
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.fp-msg--bot {
  align-self: stretch;
  padding-left: 0.9rem;
  border-left: 3px solid var(--accent);
  color: var(--ink);
}
.fp-msg--error { border-left-color: #b3261e; color: var(--ink-soft); }
.fp-msg__body p { margin: 0 0 0.6rem; }
.fp-msg__body p:last-child { margin-bottom: 0; }
.fp-msg__body ul { list-style: disc; padding-left: 1.2rem; margin: 0 0 0.6rem; }
.fp-msg__body li { margin-bottom: 0.3rem; }
.fp-msg__body strong { font-weight: 600; }

.fp-chat__cite { line-height: 0; margin-left: 2px; }
.fp-chat__cite a {
  display: inline-block;
  min-width: 1.15em;
  padding: 0.12em 0.3em;
  background: var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
}
.fp-chat__cite a:hover { background: var(--ink); color: var(--paper); }

/* ---- Fuentes ---- */
.fp-sources { margin-top: 0.9rem; }
.fp-sources__title { margin: 0 0 0.45rem; font-size: var(--step-label); color: var(--muted); }
.fp-sources__list { display: flex; flex-direction: column; gap: 0.45rem; list-style: none; margin: 0; padding: 0; }
.fp-source {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  background: var(--paper-raised);
  border: 1px solid transparent;
  border-radius: var(--radius);
}
.fp-source:hover { border-color: var(--ink); }
.fp-source__n {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  background: var(--accent);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink);
}
.fp-source__body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.fp-source__title { font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
.fp-source__meta {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.fp-chat__links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.fp-chat__links a { border-bottom: 1px solid var(--accent); font-size: 0.95rem; }
.fp-chat__links a:hover { border-color: var(--ink); }

/* ---- Cargando ---- */
.fp-msg--loading { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 0.95rem; }
.fp-dots { display: inline-flex; gap: 4px; }
.fp-dots i {
  width: 6px;
  height: 6px;
  background: var(--ink);
  border-radius: 50%;
  opacity: 0.25;
  animation: fp-dot 1s infinite ease-in-out;
}
.fp-dots i:nth-child(2) { animation-delay: 0.15s; }
.fp-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes fp-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---- Composer ---- */
.fp-chat__composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.fp-chat__composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 140px;
  padding: 0.65rem 0.8rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px: evita el zoom automático en iOS */
  line-height: 1.4;
  color: var(--ink);
  resize: none;
}
.fp-chat__composer textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; border-color: var(--ink); }
.fp-chat__send {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.fp-chat__send:hover { background: var(--ink-soft); }
.fp-chat__send:disabled { opacity: 0.35; cursor: not-allowed; }

.fp-chat__legal {
  margin: 0;
  padding: 0 1rem 0.9rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--muted);
}
