/*
 * ============================================================
 *  Fundación Aprender sin Temer — extras.css
 *  Estilos de los elementos flotantes creados por extras.js:
 *  barra de progreso, WhatsApp, compartir y chat.
 *  Usa las variables de styles.css (con valores de respaldo).
 * ============================================================
 */

/* ── Enlaces legales del footer ── */
.footer-legal {
  display: flex;
  gap: 16px;
  font-size: 12px;
}
.footer-legal a {
  color: inherit;
  opacity: 0.75;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.footer-legal a:hover { opacity: 1; color: var(--azul, #29B8E0); }

/* ── Barra de progreso de lectura ── */
.ast-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 1002;
  background: linear-gradient(90deg,
    var(--azul, #29B8E0), var(--verde, #8DC63F), var(--amarillo, #F9E22B), var(--naranja, #F7941D));
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* ── Columna de botones flotantes ── */
.ast-dock {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 996;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ast-fab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 6px 20px rgba(27, 46, 122, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.ast-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 26px rgba(27, 46, 122, 0.28); }
.ast-fab:active { transform: scale(0.96); }
.ast-fab:focus-visible { outline: 3px solid var(--amarillo, #F9E22B); outline-offset: 3px; }

.ast-fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ast-fab--share {
  width: 44px;
  height: 44px;
  background: #fff;
  color: var(--azul-oscuro, #1B2E7A);
  border: 2px solid rgba(41, 184, 224, 0.35);
}
.ast-fab--share svg { width: 20px; height: 20px; }

.ast-fab--wa { background: #25D366; }

/* Con el chat abierto solo queda el botón del chat, para no tapar el panel */
.ast-dock.chat-open .ast-fab:not(.ast-fab--chat) {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
}
.ast-dock .ast-fab { transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, visibility 0.2s; }
.ast-fab--wa svg { width: 28px; height: 28px; stroke: none; }

.ast-fab--chat {
  width: 58px;
  height: 58px;
  background: var(--azul-oscuro, #1B2E7A);
}
.ast-fab--chat svg { width: 28px; height: 28px; }
.ast-fab--chat.is-open { background: var(--azul, #29B8E0); }

.ast-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--naranja, #F7941D);
  border: 2px solid #fff;
  animation: ast-pulse 2s ease-in-out infinite;
}
@keyframes ast-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* Tooltip "¡Enlace copiado!" */
.ast-tip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translate(6px, -50%);
  white-space: nowrap;
  background: var(--azul-oscuro, #1B2E7A);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ast-tip.show { opacity: 1; transform: translate(0, -50%); }
.ast-tip:empty { display: none; }

/* ── Panel del chat ── */
.ast-chat {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 997;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(13, 26, 74, 0.28);
  overflow: hidden;
  font-family: var(--font-body, 'Nunito', sans-serif);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ast-chat.open { opacity: 1; transform: none; }
.ast-chat[hidden] { display: none; }

.ast-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--azul-oscuro, #1B2E7A), var(--footer-bg, #0d1a4a));
  color: #fff;
}
.ast-chat-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 3px;
}
.ast-chat-meta { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.ast-chat-meta strong { font-family: var(--font-display, 'Fredoka One', sans-serif); font-weight: 400; font-size: 17px; }
.ast-chat-meta span { font-size: 12px; opacity: 0.8; display: flex; align-items: center; gap: 6px; }
.ast-online { width: 8px; height: 8px; border-radius: 50%; background: var(--verde, #8DC63F); display: inline-block; }

.ast-chat-close {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ast-chat-close:hover { background: rgba(255, 255, 255, 0.22); }
.ast-chat-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.ast-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--gris-suave, #F7F9FC);
  overscroll-behavior: contain;
}

.ast-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  animation: ast-in 0.22s ease both;
}
.ast-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--texto, #1a1a2e);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(27, 46, 122, 0.06);
}
.ast-msg--user {
  align-self: flex-end;
  background: var(--azul, #29B8E0);
  color: #fff;
  border-bottom-right-radius: 4px;
  font-weight: 600;
}
@keyframes ast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ast-typing { display: flex; gap: 4px; padding: 14px; }
.ast-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b5bdd3;
  animation: ast-blink 1s infinite ease-in-out;
}
.ast-typing span:nth-child(2) { animation-delay: 0.15s; }
.ast-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ast-blink {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

.ast-chips, .ast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  animation: ast-in 0.22s ease both;
}
.ast-chip, .ast-more {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 50px;
  cursor: pointer;
  background: #fff;
  color: var(--azul-oscuro, #1B2E7A);
  border: 2px solid rgba(41, 184, 224, 0.4);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ast-chip:hover, .ast-more:hover { background: var(--azul-claro, #E8F7FD); border-color: var(--azul, #29B8E0); }

.ast-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 16px;
  border-radius: 50px;
  background: var(--naranja, #F7941D);
  color: #fff;
  text-decoration: none;
}
.ast-action:hover { filter: brightness(1.05); }
.ast-action svg { width: 16px; height: 16px; }
.ast-action[href^="https://wa.me"] { background: #25D366; }

.ast-chip:focus-visible, .ast-more:focus-visible, .ast-action:focus-visible,
.ast-chat-close:focus-visible, .ast-chat-form button:focus-visible {
  outline: 3px solid var(--amarillo, #F9E22B);
  outline-offset: 2px;
}

.ast-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e6ebf3;
  background: #fff;
}
.ast-chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* 16px evita el zoom automático en iOS */
  padding: 10px 14px;
  border-radius: 50px;
  border: 2px solid #e1e7f0;
  outline: none;
}
.ast-chat-form input:focus { border-color: var(--azul, #29B8E0); }
.ast-chat-form button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--azul-oscuro, #1B2E7A);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ast-chat-form button svg { width: 20px; height: 20px; fill: currentColor; }

/* ── Móviles ── */
@media (max-width: 600px) {
  .ast-dock { right: 16px; bottom: 16px; gap: 10px; }
  .ast-fab { width: 46px; height: 46px; }
  .ast-fab--share { width: 40px; height: 40px; }
  .ast-fab--chat { width: 54px; height: 54px; }
  .ast-chat {
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    bottom: 82px;
    height: 70vh;
    height: 70dvh;
    max-height: none;
  }
}

/* ── Menos movimiento ── */
@media (prefers-reduced-motion: reduce) {
  .ast-dot, .ast-typing span { animation: none; }
  .ast-msg, .ast-chips, .ast-actions { animation: none; }
  .ast-chat, .ast-fab, .ast-tip { transition: none; }
}

/* Enlaces dentro del texto del hero de las páginas de donación (fondo oscuro) */
.donar-hero-desc a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
}

/* ── Aviso de cookies (páginas sin el aviso completo de la portada) ── */
.ast-consent {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 1001;
  max-width: 420px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--blanco, #fff);
  color: var(--azul-oscuro, #1B2E7A);
  box-shadow: 0 12px 40px rgba(27, 46, 122, 0.22);
  font-family: var(--font-body, 'Nunito', sans-serif);
  font-size: 14px;
  line-height: 1.5;
}
.ast-consent[hidden] { display: none; }
.ast-consent a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.ast-consent-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.ast-consent button {
  font: inherit;
  font-weight: 800;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  border: 2px solid var(--azul-oscuro, #1B2E7A);
}
.ast-consent-no { background: transparent; color: var(--azul-oscuro, #1B2E7A); }
.ast-consent-yes { background: var(--azul-oscuro, #1B2E7A); color: #fff; }
.ast-consent button:focus-visible { outline: 3px solid var(--azul, #29B8E0); outline-offset: 2px; }
@media (max-width: 600px) {
  .ast-consent { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media print {
  .ast-progress, .ast-dock, .ast-chat, .ast-consent { display: none !important; }
}
