/* =========================================================
   WooCommerce AI Chatbot — chatbot.css
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --wac-primary:    #1a1a2e;
  --wac-accent:     #e94560;
  --wac-surface:    #16213e;
  --wac-surface2:   #0f3460;
  --wac-text:       #edf2f4;
  --wac-text-muted: #8b9cb0;
  --wac-bubble-user: var(--wac-accent);
  --wac-bubble-bot:  #1e2d40;
  --wac-radius:     16px;
  --wac-font:       'DM Sans', sans-serif;
  --wac-mono:       'DM Mono', monospace;
  --wac-shadow:     0 24px 64px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  --wac-glow:       0 0 0 2px var(--wac-accent);
  --wac-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Botón flotante ---------- */
#wac-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--wac-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.45);
  z-index: 99998;
  transition: var(--wac-transition);
  overflow: hidden;
}

#wac-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(233, 69, 96, 0.6);
}

#wac-toggle-btn:active {
  transform: scale(0.96);
}

#wac-toggle-btn svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: var(--wac-transition);
  position: absolute;
}

#wac-toggle-btn .icon-chat  { opacity: 1;  transform: rotate(0deg) scale(1); }
#wac-toggle-btn .icon-close { opacity: 0;  transform: rotate(-90deg) scale(0.5); }

#wac-toggle-btn.is-open .icon-chat  { opacity: 0;  transform: rotate(90deg) scale(0.5); }
#wac-toggle-btn.is-open .icon-close { opacity: 1;  transform: rotate(0deg) scale(1); }

/* Badge de notificación */
#wac-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--wac-accent);
  display: none;
}

#wac-badge.show { display: block; }

/* ---------- Panel del chat ---------- */
#wac-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 380px;
  max-height: 580px;
  background: var(--wac-primary);
  border-radius: var(--wac-radius) var(--wac-radius) var(--wac-radius) 4px;
  box-shadow: var(--wac-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99997;
  font-family: var(--wac-font);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.07);

  /* Estado inicial: oculto */
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4,0,0.2,1),
              transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

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

/* ---------- Header ---------- */
#wac-header {
  background: var(--wac-surface2);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

#wac-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wac-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#wac-avatar svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

#wac-header-text { flex: 1; min-width: 0; }

#wac-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--wac-text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#wac-status {
  font-size: 11px;
  color: #4ade80;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

#wac-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

/* ---------- Mensajes ---------- */
#wac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#wac-messages::-webkit-scrollbar { width: 4px; }
#wac-messages::-webkit-scrollbar-track { background: transparent; }
#wac-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

/* Burbujas */
.wac-msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: wac-slide-in 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
  max-width: 100%;
}

@keyframes wac-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wac-msg.user  { flex-direction: row-reverse; }
.wac-msg.bot   { flex-direction: row; }

.wac-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--wac-surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

.wac-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.wac-msg.user .wac-bubble {
  background: var(--wac-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.wac-msg.bot .wac-bubble {
  background: var(--wac-bubble-bot);
  color: var(--wac-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Links dentro de burbujas del bot */
.wac-msg.bot .wac-bubble a {
  color: var(--wac-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-weight: 500;
}

.wac-msg.bot .wac-bubble a:hover {
  opacity: 0.85;
}

/* Hora del mensaje */
.wac-time {
  font-size: 10px;
  color: var(--wac-text-muted);
  margin-top: 4px;
  text-align: right;
}
.wac-msg.bot .wac-time { text-align: left; }

/* ---------- Typing indicator ---------- */
#wac-typing {
  display: none;
  align-items: center;
  gap: 10px;
  animation: wac-slide-in 0.25s ease forwards;
}

#wac-typing.show { display: flex; }

.wac-dots {
  background: var(--wac-bubble-bot);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.wac-dot {
  width: 6px;
  height: 6px;
  background: var(--wac-text-muted);
  border-radius: 50%;
  animation: wac-bounce 1.2s infinite;
}

.wac-dot:nth-child(2) { animation-delay: 0.2s; }
.wac-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wac-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Chips de sugerencias ---------- */
#wac-suggestions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.wac-chip {
  background: transparent;
  border: 1px solid rgba(233, 69, 96, 0.4);
  color: var(--wac-accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--wac-font);
  cursor: pointer;
  transition: var(--wac-transition);
  white-space: nowrap;
}

.wac-chip:hover {
  background: var(--wac-accent);
  color: #fff;
  border-color: var(--wac-accent);
}

/* ---------- Input ---------- */
#wac-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--wac-surface);
  flex-shrink: 0;
}

#wac-input {
  flex: 1;
  background: var(--wac-primary);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--wac-text);
  font-family: var(--wac-font);
  font-size: 13.5px;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

#wac-input::placeholder { color: var(--wac-text-muted); }

#wac-input:focus {
  border-color: var(--wac-accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.12);
}

#wac-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--wac-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--wac-transition);
}

#wac-send-btn:hover  { background: #c73852; transform: scale(1.05); }
#wac-send-btn:active { transform: scale(0.95); }
#wac-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#wac-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ---------- Footer ---------- */
#wac-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  font-family: var(--wac-mono);
  letter-spacing: 0.03em;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  #wac-panel {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    max-height: 70vh;
    border-radius: var(--wac-radius);
  }

  #wac-toggle-btn {
    right: 16px;
    bottom: 16px;
  }
}
