/* ============================================================
   DELPHOS ACADEMY — CHATBOT WIDGET
   ============================================================ */

#chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  pointer-events: none; /* el contenedor no bloquea eventos */
}

#chatbot-toggle {
  pointer-events: auto; /* el botón siempre es clicable */
}

#chatbot-panel.cb-open {
  pointer-events: all; /* el panel sólo captura eventos cuando está abierto */
}

/* Cuando el panel está abierto, el widget sube por encima del botón "volver arriba" y la barra de progreso */
#chatbot-widget:has(#chatbot-panel.cb-open) {
  z-index: 10001;
}

/* ── Toggle button ────────────────────────────────────────── */
#chatbot-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0a0a;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.45);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

#chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(245, 158, 11, 0.65);
}

#chatbot-toggle:active {
  transform: scale(0.97);
}

/* Notification badge */
.cb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #EF4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #0a0f1e;
  animation: cbBadgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes cbBadgePop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* ── Chat panel ───────────────────────────────────────────── */
#chatbot-panel {
  width: 340px;
  max-height: 520px;
  background: #080d1c;
  border: 1px solid rgba(245, 158, 11, 0.18);
  border-radius: 20px;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(245, 158, 11, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition:
    opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-panel.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────── */
.cb-header {
  background: linear-gradient(135deg, #166534 0%, #16A34A 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}

.cb-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='20' cy='20' r='1' fill='rgba(255,255,255,0.06)'/%3E%3C/svg%3E") repeat;
  pointer-events: none;
}

.cb-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.cb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #080d1c;
  border: 2px solid rgba(245, 158, 11, 0.5);
  overflow: hidden;
  flex-shrink: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cb-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.cb-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.cb-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px #4ade80;
  animation: cbPulse 2s ease-in-out infinite;
}

@keyframes cbPulse {
  0%, 100% { box-shadow: 0 0 4px #4ade80; }
  50%       { box-shadow: 0 0 10px #4ade80; }
}

.cb-close {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.cb-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ── Messages area ────────────────────────────────────────── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.2) transparent;
}

.cb-messages::-webkit-scrollbar        { width: 4px; }
.cb-messages::-webkit-scrollbar-track  { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb  { background: rgba(245, 158, 11, 0.2); border-radius: 4px; }

/* Message row */
.cb-msg {
  display: flex;
  max-width: 88%;
  animation: cbFadeIn 0.28s ease forwards;
}

@keyframes cbFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg--bot  { align-self: flex-start; }
.cb-msg--user { align-self: flex-end; flex-direction: row-reverse; }

/* Bubbles */
.cb-bubble {
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.58;
}

.cb-msg--bot .cb-bubble {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(245, 158, 11, 0.12);
  color: rgba(255, 255, 255, 0.88);
  border-radius: 4px 14px 14px 14px;
}

.cb-msg--user .cb-bubble {
  background: linear-gradient(135deg, #166534 0%, #16A34A 100%);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

.cb-bubble a {
  color: #F59E0B;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  transition: border-color 0.2s;
}
.cb-bubble a:hover { border-color: #F59E0B; }

.cb-bubble strong {
  color: #fff;
  font-weight: 700;
}

/* Typing indicator */
.cb-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 15px !important;
}

.cb-typing span {
  width: 7px;
  height: 7px;
  background: rgba(245, 158, 11, 0.55);
  border-radius: 50%;
  animation: cbTyping 1.2s infinite ease-in-out;
}
.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cbTyping {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.35; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ── Quick replies ────────────────────────────────────────── */
.cb-quick-replies {
  padding: 4px 12px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  min-height: 0;
}

.cb-qr {
  background: transparent;
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #F59E0B;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  animation: cbFadeIn 0.3s ease forwards;
}

.cb-qr:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.7);
}

.cb-qr:active {
  background: rgba(245, 158, 11, 0.2);
}

/* ── Input area ───────────────────────────────────────────── */
.cb-input-area {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.2);
}

#chatbot-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

#chatbot-input::placeholder { color: rgba(255, 255, 255, 0.3); }
#chatbot-input:focus        { border-color: rgba(245, 158, 11, 0.45); }

#chatbot-send {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  border: none;
  border-radius: 10px;
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

#chatbot-send:hover {
  transform: scale(1.06);
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.45);
}

#chatbot-send:active {
  transform: scale(0.96);
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-widget {
    bottom: 16px;
    right: 16px;
  }
  #chatbot-panel {
    width: calc(100vw - 32px);
    max-height: 460px;
  }
}
