/* Drake, asistente flotante de Jorxel. Vive en #drake-root (fijo). No afecta al resto del sitio.
   Tema claro por defecto; body.light-d es el tema oscuro del sitio. El botón de WhatsApp del sitio
   suele ir abajo a la derecha, así que Drake se coloca un poco por encima de esa esquina. */
#drake-root {
  --dk-accent: #30c7b5;
  --dk-dark: #110227;
  --dk-card: #fff;
  --dk-text: #1b1038;
  --dk-muted: #5a5570;
  --dk-line: rgba(17, 2, 39, .14);
  --dk-me: #30c7b5;
  position: fixed;
  left: 22px; /* lado izquierdo, para no chocar con el botón de WhatsApp (derecha) */
  bottom: 10px; /* 10px arriba del borde inferior, siempre fijo */
  z-index: 9998;
  font-family: 'Poppins', system-ui, sans-serif;
}
body.light-d #drake-root {
  --dk-card: #241a4d;
  --dk-text: #fff;
  --dk-muted: rgba(255, 255, 255, .72);
  --dk-line: rgba(255, 255, 255, .18);
}

/* Burbuja flotante con Drake: late y suelta ondas (gota de agua) para invitar al clic. */
.drake-fab {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid var(--dk-accent);
  border-radius: 50%;
  background: var(--dk-card);
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .45);
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: visible;
  animation: drake-pulse 2.8s ease-in-out infinite;
  transition: transform .2s ease;
}
.drake-fab:hover { transform: scale(1.06); }
.drake-fab img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.drake-fab-dot { position: absolute; top: -2px; right: -2px; width: 15px; height: 15px; border-radius: 50%; background: #e23744; border: 2px solid var(--dk-card); }

/* Ondas de agua: dos círculos que crecen y se desvanecen desde la burbuja */
.drake-fab::before,
.drake-fab::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--dk-accent);
  animation: drake-ripple 2.8s ease-out infinite;
  pointer-events: none;
}
.drake-fab::after { animation-delay: 1.4s; }
@keyframes drake-ripple {
  0% { transform: scale(1); opacity: .55; }
  80% { opacity: 0; }
  100% { transform: scale(2.1); opacity: 0; }
}
@keyframes drake-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
.drake-open .drake-fab { animation: none; }
.drake-open .drake-fab::before,
.drake-open .drake-fab::after { display: none; }

/* Globo "¿Necesitas información?": sale junto a la burbuja, a la derecha (porque Drake va a la izquierda). */
/* Nube de diálogo que "dice" el dragón. Sale a la derecha, a la altura de su boca. */
.drake-tip {
  position: absolute;
  left: 74px;
  bottom: 26px;
  max-width: 200px;
  padding: .6rem .9rem;
  border-radius: 16px;
  background: var(--dk-card);
  color: var(--dk-text);
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .5);
  border: 1px solid var(--dk-line);
  cursor: pointer;
  opacity: 0;
  transform: translateX(-10px) scale(.9);
  transform-origin: left bottom;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s cubic-bezier(.2, 1.3, .4, 1);
  white-space: normal;
}
/* Pico del bocadillo + dos burbujitas hacia el dragón, como nube de cómic */
.drake-tip::before {
  content: '';
  position: absolute;
  left: -7px;
  bottom: 14px;
  width: 14px;
  height: 14px;
  background: var(--dk-card);
  border-left: 1px solid var(--dk-line);
  border-bottom: 1px solid var(--dk-line);
  transform: rotate(45deg);
}
.drake-tip::after {
  content: '';
  position: absolute;
  left: -16px;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dk-card);
  border: 1px solid var(--dk-line);
  box-shadow: -7px -3px 0 -2px var(--dk-card), -7px -3px 0 -1px var(--dk-line);
}
.drake-tip.is-visible { opacity: 1; transform: none; pointer-events: auto; animation: drake-tip-nudge 2.5s ease-in-out .4s infinite; }
@keyframes drake-tip-nudge { 0%, 100% { translate: 0 0; } 50% { translate: 0 -3px; } }

/* Panel de chat */
.drake-panel {
  position: absolute;
  left: 0;
  bottom: 76px;
  transform-origin: left bottom;
  width: min(360px, calc(100vw - 32px));
  /* El panel arranca ~76px del borde (sobre la burbuja) y sube casi hasta el tope: 20px de aire arriba. */
  max-height: calc(100vh - 76px - 20px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--dk-line);
  border-radius: 20px;
  background: var(--dk-card);
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .55);
  overflow: hidden;
  animation: drake-in .22s ease;
}
@keyframes drake-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.drake-head { display: flex; align-items: center; gap: .7rem; padding: .85rem 1rem; background: linear-gradient(120deg, var(--dk-accent), #6b5bd6); color: #fff; }
.drake-head img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); background: #fff; }
.drake-head strong { display: block; font-size: 1rem; line-height: 1.1; }
.drake-head span { font-size: .76rem; opacity: .9; }
.drake-head > div { flex: 1; }
.drake-x { background: none; border: 0; color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 .2rem; opacity: .9; }
.drake-x:hover { opacity: 1; }

.drake-body { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; background: var(--dk-card); scroll-behavior: smooth; }

.drake-msg { display: flex; align-items: flex-end; gap: .5rem; max-width: 100%; }
.drake-msg img { width: 28px; height: 28px; border-radius: 50%; flex: none; background: #fff; border: 1px solid var(--dk-line); }
.drake-bubble { padding: .7rem .85rem; border-radius: 14px; font-size: .9rem; line-height: 1.5; }
.drake-bot { align-self: flex-start; }
.drake-bot .drake-bubble { background: rgba(48, 199, 181, .12); color: var(--dk-text); border-bottom-left-radius: 4px; }
.drake-bot .drake-bubble a { color: var(--dk-accent); font-weight: 600; }
.drake-list { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .25rem; }
.drake-list li { font-size: .85rem; line-height: 1.4; }
.drake-list li::marker { color: var(--dk-accent); }
.drake-me { align-self: flex-end; }
.drake-me .drake-bubble { background: var(--dk-me); color: #04231f; border-bottom-right-radius: 4px; font-weight: 600; }

.drake-choices { display: flex; flex-direction: column; gap: .45rem; margin-top: .1rem; }
.drake-choice { text-align: left; padding: .6rem .85rem; border: 1px solid var(--dk-accent); border-radius: 12px; background: transparent; color: var(--dk-text); font: 600 .86rem/1.3 'Poppins', sans-serif; cursor: pointer; transition: background .2s, color .2s, transform .1s; }
.drake-choice:hover { background: rgba(48, 199, 181, .14); }
.drake-choice:active { transform: scale(.98); }
.drake-choice.is-primary { background: var(--dk-accent); color: #04231f; border-color: var(--dk-accent); }
.drake-choice.is-primary:hover { background: #26a596; }

.drake-form { display: grid; gap: .6rem; padding: .3rem 0; }
.drake-form label { display: grid; gap: .25rem; font: 600 .78rem/1.2 'Poppins', sans-serif; color: var(--dk-muted); }
.drake-form input { padding: .6rem .7rem; border: 1px solid var(--dk-line); border-radius: 10px; background: var(--dk-card); color: var(--dk-text); font-size: .9rem; }
.drake-form input:focus { outline: 2px solid var(--dk-accent); outline-offset: 1px; }
.drake-form-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.drake-form-row .drake-choice { flex: 1; text-align: center; }
.drake-skip { background: none; border: 0; color: var(--dk-muted); font: 600 .82rem 'Poppins', sans-serif; text-decoration: underline; cursor: pointer; }
.drake-skip:hover { color: var(--dk-text); }

@media (max-width: 600px) {
  #drake-root { left: 14px; bottom: 10px; }
  .drake-fab { width: 56px; height: 56px; }
  .drake-fab img { width: 42px; height: 42px; }
  .drake-tip { max-width: 160px; }
  /* En móvil el panel se fija a la pantalla, con 20px de aire arriba. */
  .drake-panel {
    position: fixed;
    top: 20px;
    right: 14px;
    bottom: 76px;
    width: auto;
    left: 14px;
    max-height: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .drake-fab { animation: none; }
  .drake-fab::before, .drake-fab::after { animation: none; display: none; }
  .drake-panel { animation: none; }
  .drake-tip { transition: opacity .2s ease; }
  .drake-tip.is-visible { animation: none; }
  .drake-body { scroll-behavior: auto; }
}

/* Campo de texto */
.drake-ask { display: flex; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--dk-line); background: var(--dk-card); }
.drake-ask input { flex: 1; min-width: 0; padding: .6rem .8rem; border: 1px solid var(--dk-line); border-radius: 999px; background: var(--dk-card); color: var(--dk-text); font-size: .9rem; }
.drake-ask input:focus { outline: 2px solid var(--dk-accent); outline-offset: 1px; }
.drake-ask button { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--dk-accent); color: #fff; cursor: pointer; font-size: 1rem; }

#drake-root .drake-ask input[type=text] { border-radius: 999px; height: 40px; padding: 0 .9rem; }
