/* ═══════════════════════════════════════════════════════════════
   DimensionTech — Chatbot Widget
   Dark cyber theme, consistent with main.css variables
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables locales ─────────────────────────────────────────── */
:root {
  --chat-purple:      #a814e7;
  --chat-purple-dim:  rgba(168, 20, 231, 0.15);
  --chat-cyan:        #00e5ff;
  --chat-bg:          #060608;
  --chat-bg-card:     #0a0a0d;
  --chat-bg-surface:  #0f0f14;
  --chat-border:      rgba(168, 20, 231, 0.25);
  --chat-border-cyan: rgba(0, 229, 255, 0.2);
  --chat-white:       #f0f0f4;
  --chat-gray:        #6a6a78;
  --chat-gray-light:  #b8b8c0;
  --chat-w:           380px;
  --chat-h:           520px;
  --chat-radius:      2px;
  --chat-ease:        cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Botón flotante ────────────────────────────────────────────── */
#dt-chat-toggle {
  position: fixed;
  bottom: 90px; /* encima del botón WhatsApp */
  right: 24px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(168, 20, 231, 0.3), 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.25s var(--chat-ease), box-shadow 0.25s var(--chat-ease);
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#dt-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 0 32px rgba(168, 20, 231, 0.5), 0 4px 20px rgba(0,0,0,0.6);
}

#dt-chat-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--chat-purple);
  transition: opacity 0.2s;
}

#dt-chat-toggle .icon-close {
  display: none;
}

#dt-chat-toggle.open .icon-chat {
  display: none;
}

#dt-chat-toggle.open .icon-close {
  display: block;
}

/* Badge punto verde (online) */
#dt-chat-toggle::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  background: #00d084;
  border-radius: 50%;
  border: 2px solid var(--chat-bg);
}

/* ── Ventana del chat ──────────────────────────────────────────── */
#dt-chat-window {
  position: fixed;
  bottom: 154px;
  right: 24px;
  z-index: 9999;
  width: var(--chat-w);
  max-width: calc(100vw - 32px);
  height: var(--chat-h);
  max-height: calc(100vh - 180px);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(168, 20, 231, 0.2), 0 20px 60px rgba(0,0,0,0.7);

  /* Esquina cortada cyber — solo con pseudo-elemento para no bloquear touch */
  border-top-right-radius: 0;

  /* Animación entrada/salida */
  transform-origin: bottom right;
  transition: opacity 0.25s var(--chat-ease), transform 0.25s var(--chat-ease);
  opacity: 1;
  transform: scale(1) translateY(0);
}

#dt-chat-window.hidden {
  opacity: 0;
  transform: scale(0.92) translateY(16px);
  pointer-events: none;
}

/* ── Header ────────────────────────────────────────────────────── */
#dt-chat-header {
  flex-shrink: 0;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(168,20,231,0.25), rgba(0,229,255,0.08));
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

#dt-chat-header .dt-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-purple), var(--chat-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Michroma', sans-serif;
  font-size: 11px;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

#dt-chat-header .dt-chat-info {
  flex: 1;
  min-width: 0;
}

#dt-chat-header .dt-chat-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--chat-gray-light);
  letter-spacing: 0.08em;
  line-height: 1;
  margin-bottom: 3px;
}

#dt-chat-header .dt-chat-title span {
  color: var(--chat-purple);
}

#dt-chat-header .dt-chat-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: #00d084;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
}

#dt-chat-header .dt-chat-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00d084;
  box-shadow: 0 0 6px #00d084;
  animation: dt-pulse 2s infinite;
}

@keyframes dt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

#dt-chat-messages::-webkit-scrollbar {
  width: 4px;
}
#dt-chat-messages::-webkit-scrollbar-track {
  background: var(--chat-bg);
}
#dt-chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 2px;
}

/* Burbujas */
.dt-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
  animation: dt-msg-in 0.25s var(--chat-ease) both;
}

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

/* Bot — izquierda */
.dt-msg.bot {
  align-self: flex-start;
}

.dt-msg.bot .dt-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--chat-purple-dim);
  border: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--chat-purple);
  font-weight: 700;
}

.dt-msg.bot .dt-msg-bubble {
  background: var(--chat-bg-surface);
  border: 1px solid var(--chat-border);
  border-radius: 0 8px 8px 8px;
  padding: 10px 13px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--chat-gray-light);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

/* Usuario — derecha */
.dt-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.dt-msg.user .dt-msg-bubble {
  background: linear-gradient(135deg, rgba(168,20,231,0.25), rgba(168,20,231,0.12));
  border: 1px solid rgba(168,20,231,0.4);
  border-radius: 8px 0 8px 8px;
  padding: 10px 13px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: var(--chat-white);
}

/* Typing indicator */
.dt-msg.typing .dt-msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.dt-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-gray);
  animation: dt-typing 1.2s infinite;
}

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

@keyframes dt-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ────────────────────────────────────────────────── */
#dt-chat-input-area {
  flex-shrink: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg-card);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#dt-chat-input {
  flex: 1;
  background: var(--chat-bg-surface);
  border: 1px solid rgba(168,20,231,0.2);
  border-radius: 2px;
  color: var(--chat-white);
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 1.5;
  padding: 9px 12px;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
}

#dt-chat-input::placeholder {
  color: var(--chat-gray);
}

#dt-chat-input:focus {
  border-color: rgba(168,20,231,0.5);
}

#dt-chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--chat-border);
  background: var(--chat-purple-dim);
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, box-shadow 0.2s;
  outline: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#dt-chat-send:hover:not(:disabled) {
  background: rgba(168,20,231,0.3);
  box-shadow: 0 0 12px rgba(168,20,231,0.3);
}

#dt-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#dt-chat-send svg {
  width: 16px;
  height: 16px;
  fill: var(--chat-purple);
}

/* ── Footer caption ────────────────────────────────────────────── */
#dt-chat-footer {
  flex-shrink: 0;
  padding: 5px 14px 8px;
  background: var(--chat-bg-card);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--chat-gray);
  letter-spacing: 0.05em;
  border-top: 1px solid rgba(255,255,255,0.03);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #dt-chat-window {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    clip-path: none;        /* quitar clip-path en mobile — bloquea touch en bordes */
    border: none;
    border-top: 1px solid var(--chat-border);
  }

  /* iOS: evita zoom al tocar el input (font-size mínimo 16px) */
  #dt-chat-input {
    font-size: 16px;
  }

  /* Input area más alta para dedos */
  #dt-chat-input-area {
    padding: 12px 12px 20px; /* espacio extra abajo por safe-area iOS */
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  /* Botón toggle más fácil de tocar */
  #dt-chat-toggle {
    bottom: 88px;
    right: 16px;
    width: 60px;
    height: 60px;
  }

  /* Cuando el chat está abierto, ocultar el toggle */
  #dt-chat-toggle.open {
    bottom: 16px;
    right: 16px;
    z-index: 10001;
  }
}
