/* ==========================================================
   Assistente virtual (chatbot Gemini)
   ========================================================== */
.chat-fab {
  position: fixed; right: var(--gutter); bottom: clamp(1rem, 3vw, 1.75rem); z-index: 40;
  display: inline-flex; align-items: center; gap: .6rem;
  min-height: 52px; padding: 0 1.1rem 0 .95rem;
  border: 1px solid rgb(255 179 207 / .35); border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: .9rem;
  box-shadow: 0 16px 40px -14px rgb(7 7 26 / .7);
  cursor: pointer;
  transition: transform .3s var(--ease-out), background-color .25s, opacity .3s;
}
.chat-fab svg { width: 22px; height: 22px; color: var(--glow); }
.chat-fab:hover { background: var(--accent); transform: translateY(-2px); }
.chat-fab.is-hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
.chat-fab[aria-expanded="true"] { background: var(--accent); }
.chat-fab:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 3px; }

@media (max-width: 599.98px) {
  .chat-fab { width: 52px; padding: 0; justify-content: center; }
  .chat-fab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.chat-window {
  position: fixed; z-index: 45;
  right: var(--gutter); bottom: calc(clamp(1rem, 3vw, 1.75rem) + 64px);
  display: flex; flex-direction: column;
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  height: min(520px, calc(100svh - 140px));
  overflow: hidden;
  border: 1px solid var(--line-dark); border-radius: 10px;
  background: var(--ink); color: var(--paper);
  box-shadow: 0 30px 80px -20px rgb(7 7 26 / .75);
}
.chat-window[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .chat-window:not([hidden]) { animation: chat-in .35s var(--ease-out); }
}
@keyframes chat-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem .75rem .75rem 1.1rem;
  border-bottom: 1px solid var(--line-dark);
  font-weight: 700;
}
.chat-header span { color: var(--glow); }
.chat-close {
  width: 44px; height: 44px;
  background: none; border: 0; border-radius: 50%;
  color: var(--paper); font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.chat-close:hover { background: rgb(245 244 240 / .08); }
.chat-close:focus-visible { outline: 2px solid var(--glow); outline-offset: -2px; }

.chat-messages { flex: 1; display: flex; flex-direction: column; gap: .6rem; padding: 1rem; overflow-y: auto; }
.message { max-width: 85%; padding: .65rem .9rem; border-radius: 12px; font-size: .92rem; line-height: 1.5; white-space: pre-wrap; }
.message.bot { align-self: flex-start; background: rgb(245 244 240 / .07); border-bottom-left-radius: 3px; }
.message.user { align-self: flex-end; background: var(--accent); border-bottom-right-radius: 3px; }
.message.loading { display: inline-flex; gap: 4px; }
.message.loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--glow); animation: typing 1s infinite ease-in-out; }
.message.loading span:nth-child(2) { animation-delay: .15s; }
.message.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 40% { transform: translateY(-4px); opacity: .5; } }

.chat-input-area { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--line-dark); }
.chat-input-area input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 .9rem;
  border: 1px solid var(--line-dark); border-radius: 999px;
  background: rgb(245 244 240 / .05); color: var(--paper);
  font: inherit; font-size: 16px;
}
.chat-input-area input::placeholder { color: var(--muted-dark); }
.chat-input-area input:focus-visible { outline: 2px solid var(--glow); outline-offset: 1px; }
.chat-input-area button {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: background-color .2s;
}
.chat-input-area button:hover { background: var(--accent-hi); }
.chat-input-area button:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
.chat-input-area button svg { width: 18px; height: 18px; }
