/* ============================================================
   DarkLine AI Widget v2 — Estilos completos
   Variables CSS controladas por primaryColor desde config.js
   ============================================================ */

:root {
  --dl-primary:      #6c63ff;
  --dl-primary-dark: #5a52d5;
  --dl-bg:           #ffffff;
  --dl-surface:      #f5f5f5;
  --dl-text:         #1a1a2e;
  --dl-text-light:   #666;
  --dl-user-bubble:  var(--dl-primary);
  --dl-bot-bubble:   #f0f0f0;
  --dl-radius:       18px;
  --dl-shadow:       0 8px 32px rgba(0, 0, 0, 0.18);
  --dl-font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Botón flotante ─────────────────────────────────────────── */

#dl-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--dl-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--dl-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s ease, background 0.2s ease;
}

#dl-chat-toggle:hover {
  transform: scale(1.08);
  background: var(--dl-primary-dark);
}

#dl-chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

#dl-chat-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

#dl-chat-badge.visible { display: block; }

/* ── Panel del chat ─────────────────────────────────────────── */

#dl-chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  background: var(--dl-bg);
  border-radius: var(--dl-radius);
  box-shadow: var(--dl-shadow);
  z-index: 9999;
  font-family: var(--dl-font);
  overflow: hidden;
  transform: scale(0.95) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

#dl-chat-widget.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Cabecera ───────────────────────────────────────────────── */

#dl-chat-header {
  background: var(--dl-primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

#dl-chat-header .dl-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

#dl-chat-header .dl-header-info { flex: 1; }

#dl-chat-header .dl-header-info strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

/* Estado "en línea" con punto verde */
.dl-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  opacity: 0.9;
  margin-top: 2px;
}

.dl-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
  animation: dl-pulse 2s infinite;
}

@keyframes dl-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

#dl-chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.15s;
  display: flex;
}

#dl-chat-close:hover { opacity: 1; }

/* ── Área de mensajes ───────────────────────────────────────── */

#dl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#dl-chat-messages::-webkit-scrollbar       { width: 5px; }
#dl-chat-messages::-webkit-scrollbar-track { background: transparent; }
#dl-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

/* Burbujas */
.dl-message {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: dl-fadeIn 0.2s ease;
}

@keyframes dl-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.dl-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--dl-text);
  word-break: break-word;
}

.dl-message.bot  .dl-bubble { background: var(--dl-bot-bubble); border-bottom-left-radius: 4px; }
.dl-message.user .dl-bubble { background: var(--dl-user-bubble); color: #fff; border-bottom-right-radius: 4px; }

.dl-bubble a { color: inherit; text-decoration: underline; }

/* ── Typing indicator ───────────────────────────────────────── */

.dl-typing .dl-bubble {
  background: var(--dl-bot-bubble);
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dl-typing-text {
  font-size: 12px;
  color: var(--dl-text-light);
  font-style: italic;
  white-space: nowrap;
}

.dl-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
}

.dl-dots span {
  width: 6px;
  height: 6px;
  background: var(--dl-text-light);
  border-radius: 50%;
  animation: dl-bounce 1.2s infinite;
}

.dl-dots span:nth-child(2) { animation-delay: 0.2s; }
.dl-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dl-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-5px); }
}

/* ── Preguntas rápidas ──────────────────────────────────────── */

#dl-quick-questions {
  padding: 0 12px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dl-quick-btn {
  background: #fff;
  border: 1.5px solid var(--dl-primary);
  color: var(--dl-primary);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--dl-font);
  line-height: 1.4;
}

.dl-quick-btn:hover {
  background: var(--dl-primary);
  color: #fff;
}

/* ── Botón de contacto ──────────────────────────────────────── */

#dl-contact-bar {
  padding: 8px 12px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

#dl-contact-btn {
  width: 100%;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
  font-family: var(--dl-font);
  text-decoration: none;
}

#dl-contact-btn:hover { background: #1da855; }

/* ── Input de texto ─────────────────────────────────────────── */

#dl-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

#dl-chat-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  font-family: var(--dl-font);
  color: var(--dl-text);
  transition: border-color 0.15s;
  height: 40px;
}

#dl-chat-input:focus { border-color: var(--dl-primary); }

#dl-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--dl-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

#dl-chat-send:hover    { background: var(--dl-primary-dark); transform: scale(1.05); }
#dl-chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#dl-chat-send svg      { width: 18px; height: 18px; fill: #fff; }

/* ── Formulario de captura de leads ─────────────────────────── */

.dl-lead-bubble {
  background: linear-gradient(135deg, #f8f7ff 0%, #ede9ff 100%) !important;
  border: 1.5px solid var(--dl-primary) !important;
  width: 100%;
  box-sizing: border-box;
}

.dl-message.bot:has(.dl-lead-bubble) {
  max-width: 100%;
}

.dl-lead-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--dl-primary);
}

.dl-lead-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--dl-text-light);
  line-height: 1.4;
}

#dl-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dl-lead-input {
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--dl-font);
  outline: none;
  color: var(--dl-text);
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.dl-lead-input:focus { border-color: var(--dl-primary); }

.dl-lead-submit {
  background: var(--dl-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--dl-font);
  transition: background 0.15s;
  margin-top: 2px;
}

.dl-lead-submit:hover { background: var(--dl-primary-dark); }

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 420px) {
  #dl-chat-widget {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    max-height: calc(100vh - 120px);
  }

  #dl-chat-toggle {
    right: 16px;
    bottom: 16px;
  }
}
