/* Reset básico */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* CSS Custom Properties - Daniel Kishimoto Brand (Official) */
:root {
  /* === Base Colors === */
  --chatbot-base-white: #FFFFFF;
  --chatbot-base-black: #000000;

  /* === Brand Accent Colors (Bright - for dark backgrounds) === */
  --chatbot-cyan: #5FFBF1;           /* Primary accent */
  --chatbot-pink: #F9238A;           /* Secondary accent */
  --chatbot-yellow: #F9EF3A;         /* Tertiary accent */

  /* === Brand Accent Colors (Dark - for light backgrounds, WCAG AA) === */
  --chatbot-cyan-dark: #00B8A9;      /* Contrast 4.5:1 on white */
  --chatbot-pink-dark: #C0186D;      /* Contrast 4.5:1 on white */
  --chatbot-yellow-dark: #B8A800;    /* Contrast 4.5:1 on white */

  /* === Gradients (using official brand colors) === */
  /* Light mode: usar colores dark para mejor contraste con texto blanco */
  --chatbot-gradient-primary: linear-gradient(135deg, #00B8A9 0%, #C0186D 100%);  /* Cyan Dark → Pink Dark */
  --chatbot-gradient-creative: linear-gradient(135deg, #C0186D 0%, #B8A800 100%); /* Pink Dark → Yellow Dark */
  --chatbot-gradient-accent: linear-gradient(135deg, #00B8A9 0%, #B8A800 100%);   /* Cyan Dark → Yellow Dark */
  --chatbot-gradient-button: linear-gradient(135deg, #00B8A9 0%, #C0186D 100%);   /* Cyan Dark → Pink Dark */

  /* Gradiente header con mejor contraste (más oscuro) */
  --chatbot-gradient-header: linear-gradient(135deg, #008c80 0%, #9d1557 100%);   /* Cyan más oscuro → Pink más oscuro */

  /* === Base Colors === */
  --chatbot-bg: #ffffff;
  --chatbot-surface: #f9fafb;
  --chatbot-border: #e5e7eb;
  --chatbot-text: #111827;
  --chatbot-text-secondary: #6b7280;

  /* === Message Colors === */
  --chatbot-user-bg: var(--chatbot-cyan-dark);
  --chatbot-user-text: #ffffff;
  --chatbot-assistant-bg: #f3f4f6;
  --chatbot-assistant-text: #111827;
  --chatbot-assistant-border: var(--chatbot-cyan-dark);

  /* === Effects === */
  --chatbot-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  --chatbot-shadow-colored: 0 4px 12px rgba(95, 251, 241, 0.3);  /* Cyan glow */
  --chatbot-shadow-hover: 0 6px 16px rgba(95, 251, 241, 0.4);
  --chatbot-radius: 12px;
  --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --chatbot-transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* === Typography (Official DK Brand) === */
  --chatbot-font-heading: 'Oswald', sans-serif;  /* Display/Títulos */
  --chatbot-font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --chatbot-font-mono: 'Courier New', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

[data-theme="dark"] {
  /* === Base Colors (Dark) === */
  --chatbot-bg: #000000;  /* Pure black como brand oficial */
  --chatbot-surface: #111827;
  --chatbot-border: #374151;
  --chatbot-text: #FFFFFF;  /* Pure white como brand oficial */
  --chatbot-text-secondary: #666666;  /* Gray oficial */

  /* === Message Colors (Dark) === */
  --chatbot-assistant-bg: #374151;
  --chatbot-assistant-text: #FFFFFF;
  --chatbot-assistant-border: var(--chatbot-pink);  /* Pink bright en dark mode */

  /* === Gradients (Dark) - Usar bright colors === */
  --chatbot-gradient-primary: linear-gradient(135deg, #5FFBF1 0%, #F9238A 100%);  /* Cyan → Pink */
  --chatbot-gradient-creative: linear-gradient(135deg, #F9238A 0%, #F9EF3A 100%); /* Pink → Yellow */

  /* === Effects (Dark) === */
  --chatbot-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  --chatbot-shadow-colored: 0 4px 12px rgba(95, 251, 241, 0.5);  /* Cyan glow */
  --chatbot-shadow-hover: 0 6px 16px rgba(95, 251, 241, 0.6);
}

/* Estilos del chatbot widget */

.chatbot-wrapper {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
}

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chatbot-gradient-button);
  border: none;
  cursor: pointer;
  box-shadow: var(--chatbot-shadow-colored);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
  color: white;
}

.chatbot-toggle:hover {
  transform: scale(1.12) translateY(-3px) rotate(8deg);
  box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-toggle.active {
  transform: rotate(90deg);
}

.chatbot-toggle svg {
  width: 24px;
  height: 24px;
}

.chatbot-icon-close {
  display: none;
}

.chatbot-toggle.active .chatbot-icon-open {
  display: none;
}

.chatbot-toggle.active .chatbot-icon-close {
  display: block;
}

.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--chatbot-bg);
  border-radius: var(--chatbot-radius);
  box-shadow: var(--chatbot-shadow);
  display: none; /* Oculto por defecto */
  flex-direction: column;
  overflow: hidden;
  animation: chatbot-slide-up 0.3s ease-out;
}

/* Cuando el chat está abierto (controlado por JS) */
.chatbot-window[style*="display: flex"] {
  display: flex !important;
}

@keyframes chatbot-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing indicator */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  animation: typing 1.4s infinite;
  opacity: 0.4;
}

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

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

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

.chatbot-header {
  background: var(--chatbot-gradient-header);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Glow effect en dark mode */
[data-theme="dark"] .chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(103, 126, 234, 0.5), transparent);
}

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chatbot-gradient-accent);
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: hidden; /* Ocultar bordes cuadrados de la imagen */

  /* Usar imagen de avatar real encima del gradiente */
  background-image: url('../images/avatar.png');
  background-size: 110%; /* Hacer zoom para llenar mejor el círculo */
  background-position: center;
  background-repeat: no-repeat;
  font-size: 0; /* Ocultar cualquier texto que pudiera estar dentro */
}

.chatbot-header-text h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--chatbot-font-heading);
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Status indicator con breathing animation */
.chatbot-status::before {
  content: '●';
  color: var(--chatbot-green);
  animation: chatbot-pulse-status 2s ease-in-out infinite;
}

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

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-theme-toggle,
.chatbot-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: var(--chatbot-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-theme-toggle:hover,
.chatbot-close:hover {
  background: rgba(95, 251, 241, 0.15);
  transform: scale(1.1);
}

.chatbot-theme-toggle:hover svg {
  animation: rotate-icon 0.4s ease;
}

@keyframes rotate-icon {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(180deg); }
}

/* Mostrar/ocultar iconos de tema según el modo actual */
.theme-icon-light {
  display: block;
}

.theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark {
  display: block;
}

/* Canvas de fondo para animaciones */
.chatbot-bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(255, 255, 255, 0.75);
  position: relative;
  z-index: 1;
}

[data-theme="dark"] .chatbot-messages {
  background: rgba(31, 41, 55, 0.75);
}

/* Scrollbar personalizado con DK Brand */
.chatbot-messages::-webkit-scrollbar {
  width: 10px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 5px;
  margin: 4px 0;
}

[data-theme="dark"] .chatbot-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-cyan-dark);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background 0.2s ease;
}

[data-theme="dark"] .chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chatbot-cyan);
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-pink-dark);
}

[data-theme="dark"] .chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chatbot-pink);
}

.chatbot-messages::-webkit-scrollbar-thumb:active {
  background: var(--chatbot-yellow-dark);
}

[data-theme="dark"] .chatbot-messages::-webkit-scrollbar-thumb:active {
  background: var(--chatbot-yellow);
}

.chatbot-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease-out;
  position: relative;
  z-index: 1;
}

/* Animación de entrada de mensajes mejorada */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.96);
  }
  50% {
    transform: translateY(-2px) scale(1.01);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chatbot-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.chatbot-message-user .chatbot-message-avatar {
  background: var(--chatbot-user-bg);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-message-assistant .chatbot-message-avatar {
  background: var(--chatbot-assistant-bg);
  overflow: hidden; /* Ocultar bordes cuadrados de la imagen */

  /* Usar imagen de avatar real encima del fondo */
  background-image: url('../images/avatar.png');
  background-size: 110%; /* Hacer zoom para llenar mejor el círculo */
  background-position: center;
  background-repeat: no-repeat;
  font-size: 0; /* Ocultar cualquier texto que pudiera estar dentro */
}

.chatbot-message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chatbot-message-text {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message-user .chatbot-message-text {
  background: var(--chatbot-gradient-primary);
  color: var(--chatbot-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 184, 169, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  font-weight: 500;
}

.chatbot-message-assistant .chatbot-message-text {
  background: var(--chatbot-assistant-bg);
  color: var(--chatbot-assistant-text);
  border-bottom-left-radius: 4px;
  border-left: 3px solid var(--chatbot-assistant-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Code blocks en mensajes */
.chatbot-message-text code {
  font-family: var(--chatbot-font-mono);
  background: rgba(103, 126, 234, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--chatbot-purple);
  font-size: 13px;
}

[data-theme="dark"] .chatbot-message-text code {
  background: rgba(103, 126, 234, 0.2);
  color: var(--chatbot-cyan);
}

.chatbot-message-time {
  font-size: 11px;
  color: var(--chatbot-text-secondary);
  padding: 0 4px;
}

.chatbot-typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.chatbot-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: chatbot-typing 1.4s ease-in-out infinite;
}

/* Official DK Brand colors para cada dot: Cyan → Pink → Yellow */
.chatbot-typing-indicator span:nth-child(1) {
  background: var(--chatbot-cyan-dark);  /* Cyan */
}

.chatbot-typing-indicator span:nth-child(2) {
  background: var(--chatbot-pink-dark);  /* Pink */
  animation-delay: 0.2s;
}

.chatbot-typing-indicator span:nth-child(3) {
  background: var(--chatbot-yellow-dark);  /* Yellow */
  animation-delay: 0.4s;
}

@keyframes chatbot-typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

.chatbot-input-wrapper {
  border-top: 1px solid var(--chatbot-border);
  background: var(--chatbot-bg);
  padding: 12px 16px;
  position: relative;
  z-index: 2;
}

.chatbot-input-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  background: var(--chatbot-bg);
  color: var(--chatbot-text);
  transition: var(--chatbot-transition);
}

.chatbot-input:focus {
  outline: none;
  border-color: transparent;
  box-shadow:
    0 0 0 2px var(--chatbot-purple),
    0 4px 12px rgba(103, 126, 234, 0.2);
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--chatbot-gradient-button);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--chatbot-transition);
  flex-shrink: 0;
}

.chatbot-send:hover {
  box-shadow: var(--chatbot-shadow-hover);
  transform: scale(1.08) translateY(-2px);
}

.chatbot-send:active {
  transform: scale(0.95) rotate(-15deg);
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-input-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.chatbot-char-count {
  font-size: 11px;
  color: var(--chatbot-text-secondary);
}

@media (max-width: 768px) {
  .chatbot-wrapper {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }

  .chatbot-window {
    position: fixed;
    top: 10px; /* Start from top with small margin */
    left: 10px;
    right: 10px;
    bottom: 80px; /* Space for toggle button */
    width: auto;
    height: auto; /* Auto height based on top/bottom */
    max-height: none; /* Remove max-height restriction */
  }
}

/* ========================================
   ALERTAS DE GUARDRAILS
   ======================================== */

/* Mensajes de advertencia (Guardrails) */
.chatbot-message-warning {
  background: #fef3c7 !important;
  border-left: 4px solid #f59e0b;
  animation: chatbot-pulse-warning 0.5s ease-in-out;
}

.chatbot-message-warning .chatbot-message-avatar {
  background: #f59e0b;
  color: white;
  font-size: 20px;
}

.chatbot-message-warning .chatbot-message-text {
  color: #92400e;
  font-weight: 500;
}

/* Mensajes de bloqueo */
.chatbot-message-blocked {
  background: #fee2e2 !important;
  border-left: 4px solid #dc2626;
  animation: chatbot-shake 0.5s ease-in-out;
}

.chatbot-message-blocked .chatbot-message-avatar {
  background: #dc2626;
  color: white;
  font-size: 20px;
}

.chatbot-message-blocked .chatbot-message-text {
  color: #991b1b;
  font-weight: 600;
}

/* Estilos de contenido de alerta */
.chatbot-alert-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-alert-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.chatbot-violation-counter {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 4px;
}

/* Animaciones de alertas */
@keyframes chatbot-pulse-warning {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.02);
    opacity: 0.9;
  }
}

@keyframes chatbot-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Mini Art Canvas (Easter Egg /art) */
.mini-art-container {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#mini-art-canvas,
.mini-art-container canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 200px;
}

.chatbot-message-art .mini-art-container {
  animation: fadeIn 0.5s ease-out;
}

/* Generative Media Club Badge */
.chatbot-footer-badge {
  padding: 8px 16px;
  text-align: center;
  font-size: 11px;
  color: var(--chatbot-text-secondary);
  background: var(--chatbot-surface);
  border-top: 1px solid var(--chatbot-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--chatbot-transition-fast);
}

.badge-icon {
  font-size: 14px;
  filter: grayscale(1);
  transition: filter 0.3s ease;
}

.badge-text {
  color: var(--chatbot-text-secondary);
  text-decoration: none;
  transition: color 0.3s ease;
  font-family: var(--chatbot-font-body);
  font-weight: 500;
}

.chatbot-footer-badge:hover {
  background: var(--chatbot-gradient-accent);
  cursor: pointer;
}

.chatbot-footer-badge:hover .badge-icon {
  filter: grayscale(0);
}

.chatbot-footer-badge:hover .badge-text {
  color: white;
  background: linear-gradient(135deg, var(--chatbot-cyan), var(--chatbot-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .chatbot-footer-badge {
  background: var(--chatbot-surface);
  border-top-color: var(--chatbot-border);
}

/* Dark mode para alertas */
[data-theme="dark"] .chatbot-message-warning {
  background: #78350f !important;
  border-left-color: #f59e0b;
}

[data-theme="dark"] .chatbot-message-warning .chatbot-message-avatar {
  background: #f59e0b;
}

[data-theme="dark"] .chatbot-message-warning .chatbot-message-text {
  color: #fef3c7;
}

[data-theme="dark"] .chatbot-message-blocked {
  background: #7f1d1d !important;
  border-left-color: #dc2626;
}

[data-theme="dark"] .chatbot-message-blocked .chatbot-message-avatar {
  background: #dc2626;
}

[data-theme="dark"] .chatbot-message-blocked .chatbot-message-text {
  color: #fee2e2;
}

/* ===================================
   LANGUAGE SELECTOR
   =================================== */

.chatbot-language-selector {
  position: relative;
}

.chatbot-lang-toggle {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: var(--chatbot-transition);
  display: flex;
  align-items: center;
  font-size: 18px;
}

.chatbot-lang-toggle:hover {
  background: rgba(95, 251, 241, 0.15);
  transform: scale(1.1);
}

.chatbot-lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--chatbot-bg);
  border-radius: 8px;
  box-shadow: var(--chatbot-shadow);
  padding: 8px;
  display: none;
  min-width: 150px;
  z-index: 1000;
  border: 1px solid var(--chatbot-border);
}

.chatbot-lang-menu.active {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  width: 100%;
  text-align: left;
  transition: background 0.2s ease;
  color: var(--chatbot-text);
  font-family: var(--chatbot-font-body);
}

.lang-option:hover {
  background: var(--chatbot-surface);
}

.lang-option.active {
  background: var(--chatbot-gradient-primary);
  color: white;
}

.lang-flag {
  font-size: 18px;
}

.lang-name {
  font-size: 13px;
  font-weight: 500;
}

/* Dark mode adjustments */
[data-theme="dark"] .chatbot-lang-menu {
  background: var(--chatbot-surface);
  border-color: var(--chatbot-border);
}

[data-theme="dark"] .lang-option:hover {
  background: #374151;
}
