#intelecta-chatbot * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#intelecta-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;

  --primary: #0084ff;
  --primary-2: #0a6bff;
  --panel: #ffffff;
  --chat-bg: #f0f2f5;
  --text: #1c1e21;
  --muted: #65676b;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 14px 60px rgba(0, 0, 0, 0.18);
  --radius: 16px;
}

/* SVG icons */
#intelecta-chatbot .icon {
  width: 20px;
  height: 20px;
  display: block;
}
#intelecta-chatbot .chatbot-toggle .icon { width: 24px; height: 24px; }

/* Toggle */
#intelecta-chatbot .chatbot-toggle {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  z-index: 10001;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 132, 255, 0.38);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
#intelecta-chatbot .chatbot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 132, 255, 0.52);
}
#intelecta-chatbot .chatbot-toggle:active { transform: scale(0.98); }

#intelecta-chatbot .toggle-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  animation: pulse 1.9s infinite ease-in-out;
  pointer-events: none;
}
@keyframes pulse {
  0% { transform: scale(0.92); opacity: 0.35; }
  60% { transform: scale(1.06); opacity: 0; }
  100% { transform: scale(1.06); opacity: 0; }
}

/* Container */
#intelecta-chatbot .chatbot-container {
  position: fixed;
  bottom: 100px;
  right: 22px;
  width: 390px;
  max-width: calc(100vw - 44px);
  height: 620px;
  max-height: calc(100vh - 130px);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}
#intelecta-chatbot .chatbot-container.open {
  display: flex;
  animation: pop 0.2s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#intelecta-chatbot .chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
#intelecta-chatbot .header-left { display: flex; align-items: center; gap: 12px; }
#intelecta-chatbot .chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  display: grid;
  place-items: center;
  color: var(--primary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
#intelecta-chatbot .header-info { display: flex; flex-direction: column; gap: 2px; }
#intelecta-chatbot .chatbot-title { color: #fff; font-weight: 800; font-size: 15.5px; }
#intelecta-chatbot .chatbot-status {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  gap: 6px;
  align-items: center;
}
#intelecta-chatbot .status-dot {
  width: 8px; height: 8px; border-radius: 99px;
  background: #37d67a;
  box-shadow: 0 0 0 3px rgba(55, 214, 122, 0.22);
}
#intelecta-chatbot .header-right { display: flex; gap: 8px; align-items: center; }

#intelecta-chatbot .theme-toggle,
#intelecta-chatbot .close-chatbot,
#intelecta-chatbot .whatsapp-header {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
}
#intelecta-chatbot .whatsapp-header {
  background: rgba(37, 211, 102, 0.22);
  border-color: rgba(37, 211, 102, 0.35);
}
#intelecta-chatbot .theme-toggle:hover,
#intelecta-chatbot .close-chatbot:hover,
#intelecta-chatbot .whatsapp-header:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
}
#intelecta-chatbot .whatsapp-header:hover { background: rgba(37, 211, 102, 0.30); }

/* Theme icon switch (sin depender del JS) */
#intelecta-chatbot .icon-moon { display: none; }
#intelecta-chatbot.dark-theme .icon-sun { display: none; }
#intelecta-chatbot.dark-theme .icon-moon { display: block; }

/* ✅ Mensajes con MÁS aire lateral (para que no se pegue a la caja) */
#intelecta-chatbot .chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;              /* ✅ evita scroll horizontal */
  background: var(--chat-bg);
  padding: 22px 26px 18px;         /* ✅ MÁS margen */
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ✅ Burbujas más “respiradas” */
#intelecta-chatbot .message { max-width: 72%; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#intelecta-chatbot .message.ai { align-self: flex-start; }
#intelecta-chatbot .message.user { align-self: flex-end; }

/* ✅ MÁS padding interior para que el texto NO se vea pegado */
#intelecta-chatbot .message-content {
  padding: 16px 18px;              /* ✅ aquí está la mejora principal */
  border-radius: 18px;
  line-height: 1.6;                /* ✅ más cómodo */
  font-size: 14.8px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  position: relative;
  word-break: break-word;
  max-width: 100%;
}

#intelecta-chatbot .message.ai .message-content {
  margin-left: 10px;
  border-top-left-radius: 10px;
}

#intelecta-chatbot .message.user .message-content {
  margin-right: 10px;
  border-top-right-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 18px rgba(0, 132, 255, 0.22);
}

/* Colitas */
#intelecta-chatbot .message.ai .message-content:before {
  content: "";
  position: absolute;
  left: -6px;
  top: 14px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  border-bottom-right-radius: 4px;
}
#intelecta-chatbot .message.user .message-content:before {
  content: "";
  position: absolute;
  right: -6px;
  top: 14px;
  width: 12px;
  height: 12px;
  background: var(--primary);
  transform: rotate(45deg);
  border-bottom-left-radius: 4px;
}

#intelecta-chatbot .message-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  padding: 0 10px;
}
#intelecta-chatbot .message.user .message-time { text-align: right; color: rgba(255, 255, 255, 0.78); }
#intelecta-chatbot .message.ai .message-time { text-align: left; }

/* Input */
#intelecta-chatbot .chatbot-input-area {
  padding: 12px 14px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
#intelecta-chatbot .input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f4f5f7;
  border-radius: 999px;
  padding: 6px 8px 6px 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
#intelecta-chatbot .attach-button,
#intelecta-chatbot .send-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
#intelecta-chatbot .send-button {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 18px rgba(0, 132, 255, 0.22);
}
#intelecta-chatbot .chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 10px 0;
  color: var(--text);
  font-size: 15px;
}

/* Typing */
#intelecta-chatbot .typing-indicator { align-self: flex-start; margin-left: 10px; }
#intelecta-chatbot .typing-indicator .message-content { padding: 12px 16px; }
#intelecta-chatbot .typing-dots { display: flex; gap: 6px; align-items: center; }
#intelecta-chatbot .typing-dots span {
  width: 8px; height: 8px; border-radius: 99px;
  background: rgba(0, 0, 0, 0.35);
  animation: typing 1.2s infinite ease-in-out;
}
#intelecta-chatbot .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
#intelecta-chatbot .typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes typing {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 0.95; }
}

/* Dark theme */
#intelecta-chatbot.dark-theme {
  --panel: #242526;
  --chat-bg: #18191a;
  --text: #e4e6eb;
  --muted: #b0b3b8;
  --border: rgba(255, 255, 255, 0.10);
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.45);
}
#intelecta-chatbot.dark-theme .message-content { background: #2f3031; color: var(--text); }
#intelecta-chatbot.dark-theme .message.ai .message-content:before { background: #2f3031; }
#intelecta-chatbot.dark-theme .input-group { background: #2a2b2c; border-color: rgba(255, 255, 255, 0.08); }
#intelecta-chatbot.dark-theme .typing-dots span { background: rgba(255, 255, 255, 0.50); }

/* Responsive */
@media (max-width: 768px) {
  #intelecta-chatbot .chatbot-toggle { right: 16px; bottom: 16px; width: 58px; height: 58px; }
  #intelecta-chatbot .chatbot-container { right: 14px; left: 14px; width: auto; bottom: 88px; height: 72vh; border-radius: 18px; }
  #intelecta-chatbot .chatbot-messages { padding: 18px 20px 16px; }
  #intelecta-chatbot .message { max-width: 80%; }
}
@media (max-width: 480px) {
  #intelecta-chatbot .chatbot-container { bottom: 0; right: 0; left: 0; height: 84vh; max-width: 100%; border-radius: 16px 16px 0 0; }
}
