/* ═══════════════════════════════════════════════
   CompaFish 🐠 — asistente de precalificación
   + Compa robot caminando en el fondo
   ═══════════════════════════════════════════════ */

/* ── Botón flotante CompaFish ── */
#compaFishBtn {
  position: fixed; left: 22px; bottom: 22px; z-index: 999;
  width: 68px; height: 68px; border-radius: 50%; border: 0; cursor: pointer;
  padding: 0; background: linear-gradient(145deg, var(--navy), var(--blue));
  box-shadow: 0 10px 30px rgba(11,30,61,0.45);
  display: flex; align-items: center; justify-content: center;
  animation: cf-bob 3s ease-in-out infinite;
  transition: transform 0.25s;
}
#compaFishBtn:hover { transform: scale(1.08); }
#compaFishBtn img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; border: 2px solid rgba(11,30,61,0.55); }
#compaFishBtn .cf-ping {
  position: absolute; top: 2px; right: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #25D366; border: 2px solid #fff;
  animation: cf-ping 1.6s ease-out infinite;
}
@keyframes cf-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cf-ping {
  0% { box-shadow: 0 0 0 0 rgba(37,211,102,0.5); }
  100% { box-shadow: 0 0 0 12px rgba(37,211,102,0); }
}

/* ── Panel del chat ── */
#compaFishPanel {
  position: fixed; left: 22px; bottom: 22px; z-index: 998;
  width: min(360px, calc(100vw - 32px)); height: min(520px, calc(100vh - 44px));
  background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 90px rgba(11,30,61,0.35);
  border: 1px solid rgba(0,180,255,0.25);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(24px) scale(0.96); pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#compaFishPanel.cf-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.cf-head {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--navy-deep), var(--navy));
  color: #fff; padding: 14px 16px;
}
.cf-head img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; border: 2px solid rgba(11,30,61,0.55); }
.cf-head-title { font-weight: 700; font-size: 15px; }
.cf-head-sub { font-size: 11.5px; color: rgba(255,255,255,0.7); }
.cf-head .cf-status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #7ef7b3; }
.cf-head .cf-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #25D366; animation: cf-ping 1.6s infinite; }
#compaFishClose { background: none; border: 0; color: rgba(255,255,255,0.85); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 2px; }
#compaFishClose:hover { color: #fff; }

#compaFishChat { flex: 1; overflow-y: auto; padding: 16px; background: #f4f7fb; display: flex; flex-direction: column; gap: 10px; }

.cf-msg { display: flex; align-items: flex-end; gap: 8px; }
.cf-bot { justify-content: flex-start; }
.cf-user { justify-content: flex-end; }
.cf-avatar { width: 32px; height: 32px; object-fit: cover; flex-shrink: 0; border-radius: 8px; border: 2px solid rgba(11,30,61,0.55); }
.cf-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  background: #fff; color: var(--text); font-size: 14px; line-height: 1.45;
  border: 1px solid rgba(0,0,0,0.06); box-shadow: 0 4px 12px rgba(11,30,61,0.06);
  border-bottom-left-radius: 4px;
}
.cf-bubble-user { background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #fff; border: 0; border-bottom-right-radius: 4px; }

.cf-dots i { font-style: normal; animation: cf-blink 1.2s infinite; }
.cf-dots i:nth-child(2) { animation-delay: 0.2s; }
.cf-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes cf-blink { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }

#compaFishChoices { display: flex; flex-direction: column; gap: 8px; }
.cf-choice {
  text-align: left; background: #fff; border: 1.5px solid rgba(11,30,61,0.15);
  color: var(--navy); border-radius: 14px; padding: 11px 16px; font-size: 14px;
  font-family: var(--font); font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.cf-choice:hover { border-color: var(--cyan); background: rgba(0,180,255,0.06); }

#compaFishInputWrap { display: flex; gap: 8px; padding: 12px; background: #fff; border-top: 1px solid rgba(0,0,0,0.06); }
#compaFishText {
  flex: 1; padding: 12px 16px; border-radius: 980px; border: 1.5px solid rgba(0,0,0,0.12);
  font-size: 14px; font-family: var(--font); outline: none;
}
#compaFishText:focus { border-color: var(--cyan); }
#compaFishSend {
  background: var(--navy); color: #fff; border: 0; border-radius: 50%;
  width: 44px; height: 44px; cursor: pointer; font-size: 16px; flex-shrink: 0;
}
#compaFishSend:hover { background: var(--blue); }

.cf-wa {
  display: block; text-align: center; background: #25D366; color: #fff;
  padding: 12px 16px; border-radius: 14px; font-weight: 700; font-size: 14.5px;
  text-decoration: none; transition: transform 0.2s;
}
.cf-wa:hover { color: #fff; transform: translateY(-2px); }
.cf-again {
  margin-top: 8px; width: 100%; background: none; border: 1px solid rgba(0,0,0,0.15);
  color: var(--text-2); border-radius: 12px; padding: 9px; font-size: 13px;
  font-family: var(--font); cursor: pointer;
}
.cf-again:hover { border-color: var(--navy); color: var(--navy); }

.cf-hidden { display: none !important; }

/* ── Compa robot caminando en el fondo ── */
.compa-walker {
  position: fixed; bottom: 10px; left: 0; z-index: 5;
  pointer-events: none;
  animation: compa-walk 36s linear infinite;
}
.compa-walker img {
  width: 110px; height: 110px; object-fit: cover; display: block;
  border-radius: 24px;
  border: 3px solid rgba(11,30,61,0.55);
  box-shadow: 0 12px 28px rgba(11,30,61,0.35);
  animation: compa-bob 0.55s ease-in-out infinite;
}
@keyframes compa-walk {
  0%   { transform: translateX(-140px); }
  50%  { transform: translateX(calc(100vw - 0px)); }
  50.01% { transform: translateX(calc(100vw - 0px)) scaleX(-1); }
  100% { transform: translateX(-140px) scaleX(-1); }
}
@keyframes compa-bob {
  0%,100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

@media (max-width: 600px) {
  .compa-walker { display: none; }
  .compa-walker img { width: 60px; height: 60px; border-radius: 16px; }
  #compaFishBtn { width: 54px; height: 54px; bottom: 16px; left: 16px; }
  #compaFishBtn img { width: 44px; height: 44px; }
  #compaFishPanel { 
    left: 12px; right: 12px; bottom: 80px; 
    width: auto; height: min(480px, calc(100vh - 100px));
  }
  .cf-head { padding: 12px 14px; }
  .cf-head img { width: 36px; height: 36px; }
  .cf-head-title { font-size: 14px; }
  .cf-bubble { font-size: 13px; padding: 9px 12px; }
  .cf-choice { font-size: 13px; padding: 10px 14px; }
}

/* respetar reducir-movimiento */
@media (prefers-reduced-motion: reduce) {
  .compa-walker, .compa-walker img { animation: none; }
  #compaFishBtn { animation: none; }
}