/**
 * CC Bot — Asistente conversacional (sin IA)
 * Paleta alineada con Credidata Cloud (styles.css :root)
 */
#cc-bot-root {
  --cc-bg: #0b1228;
  --cc-bg-elev: #0f172a;
  --cc-border: rgba(59, 130, 246, 0.22);
  --cc-cyan: #06b6d4;
  --cc-accent: #2563eb;
  --cc-text: #f1f5f9;
  --cc-muted: #94a3b8;
  --cc-bot-bubble: rgba(15, 23, 42, 0.92);
  --cc-user-bubble: rgba(6, 182, 212, 0.18);
  --cc-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  --cc-radius: 16px;
  --cc-fab-size: 58px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  position: fixed;
  inset: auto 0 0 auto;
  z-index: 100000;
  pointer-events: none;
}

#cc-bot-root * {
  box-sizing: border-box;
}

/* El inner no debe capturar clics: si no, bloquea enlaces/nav aunque el panel tenga pointer-events:none */
#cc-bot-root .cc-bot-inner {
  pointer-events: none;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* FAB */
#cc-bot-root .cc-bot-fab-shell {
  position: relative;
  width: var(--cc-fab-size);
  height: var(--cc-fab-size);
  flex-shrink: 0;
  pointer-events: none;
}

#cc-bot-root .cc-bot-fab-shell::before,
#cc-bot-root .cc-bot-fab-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(6, 182, 212, 0.55);
  pointer-events: none;
  animation: cc-bot-ripple 2.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

#cc-bot-root .cc-bot-fab-shell::after {
  animation-delay: 1.4s;
  border-color: rgba(37, 99, 235, 0.4);
}

#cc-bot-root .cc-bot-fab {
  pointer-events: auto;
  position: relative;
  z-index: 1;
  width: var(--cc-fab-size);
  height: var(--cc-fab-size);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cc-cyan) 0%, var(--cc-accent) 50%, var(--cc-cyan) 100%);
  background-size: 200% 200%;
  color: #fff;
  box-shadow: 0 8px 28px rgba(6, 182, 212, 0.45), 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  animation: cc-bot-fab-glow 3s ease-in-out infinite, cc-bot-shimmer 4.5s ease-in-out infinite;
}

#cc-bot-root .cc-bot-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 40px rgba(6, 182, 212, 0.6), 0 8px 20px rgba(0, 0, 0, 0.42);
  animation-play-state: paused;
}

#cc-bot-root .cc-bot-fab:hover .cc-bot-fab-icon {
  animation-play-state: paused;
}

#cc-bot-root .cc-bot-fab:focus-visible {
  outline: 2px solid var(--cc-cyan);
  outline-offset: 3px;
}

#cc-bot-root .cc-bot-fab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cc-bot-icon-bob 2.6s ease-in-out infinite;
}

#cc-bot-root .cc-bot-fab svg {
  width: 28px;
  height: 28px;
}

@keyframes cc-bot-ripple {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }
  70% {
    opacity: 0.08;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

@keyframes cc-bot-fab-glow {
  0%, 100% {
    box-shadow: 0 8px 28px rgba(6, 182, 212, 0.45), 0 4px 12px rgba(0, 0, 0, 0.35),
      0 0 0 0 rgba(6, 182, 212, 0.35);
  }
  50% {
    box-shadow: 0 10px 34px rgba(6, 182, 212, 0.58), 0 6px 16px rgba(0, 0, 0, 0.38),
      0 0 0 6px rgba(6, 182, 212, 0.12);
  }
}

@keyframes cc-bot-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes cc-bot-icon-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-2px) rotate(-2deg); }
  60% { transform: translateY(1px) rotate(2deg); }
}

@keyframes cc-bot-avatar-nod {
  0%, 100% { transform: translateY(2px); }
  50% { transform: translateY(3.5px); }
}

@keyframes cc-bot-antenna-sway {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}

@keyframes cc-bot-blink {
  0%, 44%, 52%, 100% { transform: scaleY(1); }
  48% { transform: scaleY(0.12); }
}

@media (prefers-reduced-motion: reduce) {
  #cc-bot-root .cc-bot-fab-shell::before,
  #cc-bot-root .cc-bot-fab-shell::after,
  #cc-bot-root .cc-bot-fab,
  #cc-bot-root .cc-bot-fab-icon {
    animation: none !important;
  }

  #cc-bot-root .cc-bot-fab {
    background: linear-gradient(145deg, var(--cc-cyan), var(--cc-accent));
    background-size: auto;
  }

  #cc-bot-root .cc-bot-avatar-svg,
  #cc-bot-root .cc-bot-antenna-anim,
  #cc-bot-root .cc-bot-eye {
    animation: none !important;
  }
}

/* Panel */
#cc-bot-root .cc-bot-panel {
  width: min(380px, calc(100vw - 24px));
  max-height: min(720px, 86vh);
  background: var(--cc-bg);
  border: 1px solid var(--cc-border);
  border-radius: var(--cc-radius);
  box-shadow: var(--cc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

#cc-bot-root.cc-bot-panel-open .cc-bot-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#cc-bot-root.cc-bot-panel-open .cc-bot-fab-shell::before,
#cc-bot-root.cc-bot-panel-open .cc-bot-fab-shell::after {
  animation: none;
  opacity: 0;
}

#cc-bot-root.cc-bot-panel-open .cc-bot-fab {
  animation: none;
  background: linear-gradient(145deg, var(--cc-cyan), var(--cc-accent));
  background-size: auto;
}

#cc-bot-root.cc-bot-panel-open .cc-bot-fab-icon {
  animation: none;
}

/* Header */
#cc-bot-root .cc-bot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(37, 99, 235, 0.08));
  border-bottom: 1px solid var(--cc-border);
}

#cc-bot-root .cc-bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--cc-cyan), var(--cc-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

#cc-bot-root .cc-bot-avatar-svg {
  display: block;
  margin: 0 auto;
  transform-origin: 50% 50%;
  animation: cc-bot-avatar-nod 3.2s ease-in-out infinite;
}

#cc-bot-root .cc-bot-antenna-anim {
  transform-origin: 12px 7px;
  transform-box: fill-box;
  animation: cc-bot-antenna-sway 2.4s ease-in-out infinite;
}

#cc-bot-root .cc-bot-eye {
  transform-origin: center;
  transform-box: fill-box;
  animation: cc-bot-blink 5s ease-in-out infinite;
}

#cc-bot-root .cc-bot-eye--r {
  animation-delay: 0.04s;
}

#cc-bot-root .cc-bot-header-text {
  flex: 1;
  min-width: 0;
}

#cc-bot-root .cc-bot-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--cc-text);
  letter-spacing: -0.02em;
}

#cc-bot-root .cc-bot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--cc-muted);
  margin-top: 2px;
}

#cc-bot-root .cc-bot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

#cc-bot-root .cc-bot-header-actions {
  display: flex;
  gap: 4px;
}

#cc-bot-root .cc-bot-icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cc-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#cc-bot-root .cc-bot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Messages */
#cc-bot-root .cc-bot-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#cc-bot-root .cc-bot-msg {
  max-width: 92%;
  animation: cc-bot-msg-in 0.35s ease forwards;
}

@keyframes cc-bot-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#cc-bot-root .cc-bot-msg--bot {
  align-self: flex-start;
}

#cc-bot-root .cc-bot-msg--user {
  align-self: flex-end;
}

#cc-bot-root .cc-bot-bubble {
  padding: 12px 14px;
  border-radius: 14px 14px 14px 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cc-text);
  background: var(--cc-bot-bubble);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#cc-bot-root .cc-bot-msg--user .cc-bot-bubble {
  border-radius: 14px 14px 4px 14px;
  background: var(--cc-user-bubble);
  border-color: rgba(6, 182, 212, 0.35);
}

#cc-bot-root .cc-bot-typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  align-self: flex-start;
  background: var(--cc-bot-bubble);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#cc-bot-root .cc-bot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc-cyan);
  opacity: 0.35;
  animation: cc-bot-typing 1.1s ease-in-out infinite;
}

#cc-bot-root .cc-bot-typing span:nth-child(2) { animation-delay: 0.15s; }
#cc-bot-root .cc-bot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cc-bot-typing {
  0%, 80%, 100% { opacity: 0.35; transform: scale(1); }
  40% { opacity: 1; transform: scale(1.15); }
}

/* Chips / opciones */
#cc-bot-root .cc-bot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

#cc-bot-root .cc-bot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.08);
  color: var(--cc-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  text-align: left;
  font-family: inherit;
}

#cc-bot-root .cc-bot-chip:hover {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.55);
  transform: translateY(-1px);
}

#cc-bot-root .cc-bot-chip--link {
  text-decoration: none;
  color: inherit;
}

#cc-bot-root .cc-bot-footer-hint {
  padding: 8px 16px 12px;
  font-size: 11px;
  color: var(--cc-muted);
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobile: panel ~90% width */
@media (max-width: 520px) {
  #cc-bot-root .cc-bot-inner {
    right: 5%;
    left: 5%;
    width: auto;
    align-items: stretch;
  }

  #cc-bot-root .cc-bot-panel {
    width: 100%;
    max-width: none;
    max-height: min(82vh, 620px);
  }

  #cc-bot-root .cc-bot-fab-shell {
    align-self: flex-end;
  }
}
