/* =========================================================
   Chat con Zua · botón flotante y ventana
   Usa las variables de styles.css (colores, radio, sombra)
   ========================================================= */

.zua-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 0;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(43, 43, 46, .18);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.zua-fab:hover { background: var(--primary-hover); }
.zua-fab:focus-visible { outline: 2px solid var(--foreground); outline-offset: 2px; }
.zua-fab svg { width: 1.25rem; height: 1.25rem; flex: none; }
.zua-fab[aria-expanded="true"] { display: none; }

.zua-panel {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  background: var(--background);
  color: var(--foreground);
}
.zua-panel[hidden] { display: none; }

.zua-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.zua-avatar {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 9999px;
  font-weight: 700;
}
.zua-head-text { flex: 1; min-width: 0; }
.zua-title { font-size: 1rem; font-weight: 600; line-height: 1.25; }
.zua-sub { font-size: 0.8125rem; color: var(--muted-foreground); }
.zua-close {
  width: 2.25rem;
  height: 2.25rem;
  background: none;
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted-foreground);
}
.zua-close:hover { color: var(--foreground); background: var(--surface-alt); }

.zua-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1rem;
}
.zua-msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.zua-msg--bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}
.zua-msg--user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 0.25rem;
}
.zua-msg a { color: var(--primary); font-weight: 600; text-decoration: underline; }

.zua-typing { display: inline-flex; gap: 0.25rem; padding: 0.25rem 0; }
.zua-typing span {
  width: 0.4rem;
  height: 0.4rem;
  background: var(--muted-foreground);
  border-radius: 9999px;
  animation: zua-blink 1.2s infinite ease-in-out;
}
.zua-typing span:nth-child(2) { animation-delay: .2s; }
.zua-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes zua-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.zua-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.zua-suggestions[hidden] { display: none; }
.zua-suggestions button {
  padding: 0.5rem 0.875rem;
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 9999px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.zua-suggestions button:hover { background: var(--primary); color: var(--primary-foreground); }

.zua-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--border);
}
.zua-form input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: 1rem; /* 16px: evita el zoom automático en iPhone */
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 9999px;
}
.zua-form input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.zua-send {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
}
.zua-send:hover { background: var(--primary-hover); }
.zua-send:disabled { opacity: .6; cursor: wait; }
.zua-send svg { width: 1.125rem; height: 1.125rem; }

/* En pantallas grandes: ventana flotante sobre la esquina */
@media (min-width: 640px) {
  .zua-fab { right: 1.5rem; bottom: 1.5rem; }
  .zua-panel {
    inset: auto 1.5rem 1.5rem auto;
    width: 23rem;
    height: min(34rem, calc(100dvh - 3rem));
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(43, 43, 46, .18);
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zua-typing span { animation: none; opacity: .6; }
}
