/**
 * Agent V2 - Estilos principales de la nueva interfaz
 * Tema: Neon
 */

:root {
  --neon-teal: #00f5ff;
  --neon-cyan: #0ff0fc;
  --neon-magenta: #ff00ff;
  --neon-purple: #8b5cf6;
  --neon-yellow: #ffff00;
  --neon-pink: #ff1493;
  --bg-dark: #0a0b0e;
  --bg-darker: #000000;
  --text-primary: #edeffb;
  --text-secondary: rgba(237, 239, 251, 0.7);
  --glow-intensity: 0.5;
  
  /* Tamaños del agente - control centralizado */
  --agentSizeDesktop: 350px;
  --agentSizeMobile: 220px;
  --agentSizeMobileSmall: 200px;
}

/* Fuentes con fallbacks robustos para producción */
.agent-v2-container,
.agent-v2-container * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1;
  text-rendering: optimizeLegibility;
}

/* Contenedor principal V2 */
.agent-v2-container {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0b0e 0%, #1a0f2e 50%, #0a0b0e 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

/* En móvil usar dvh para evitar problemas con la barra del navegador */
@media (max-width: 768px) {
  .agent-v2-container {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* Asegurar que no haya scroll en body cuando V2 está activo */
body.agent-v2-active {
  overflow: hidden;
  height: 100vh;
}

/* Efecto de partículas/estrellas en el fondo */
.agent-v2-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(2px 2px at 60% 70%, rgba(0, 245, 255, 0.2), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(139, 92, 246, 0.3), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(2px 2px at 90% 40%, rgba(0, 245, 255, 0.15), transparent),
    radial-gradient(1px 1px at 33% 60%, rgba(139, 92, 246, 0.2), transparent),
    radial-gradient(1px 1px at 66% 20%, rgba(255, 255, 255, 0.25), transparent);
  background-size: 200% 200%;
  background-position: 0% 0%, 100% 0%, 50% 50%, 0% 100%, 100% 100%, 50% 0%, 0% 50%;
  animation: starfield 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes starfield {
  0% {
    background-position: 0% 0%, 100% 0%, 50% 50%, 0% 100%, 100% 100%, 50% 0%, 0% 50%;
  }
  100% {
    background-position: 100% 100%, 0% 100%, 50% 50%, 100% 0%, 0% 0%, 50% 100%, 100% 50%;
  }
}

.agent-v2-container > * {
  position: relative;
  z-index: 1;
}

/* Contenedor de diálogo (agente + panel) */
.agent-v2-dialog-container {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 20px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 30px;
  height: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* Wrapper del agente visual */
.agent-v2-visual-wrapper {
  position: relative;
  width: auto;
  min-width: var(--agentSizeDesktop);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  align-self: flex-start;
  justify-content: center;
  padding: 20px 10px;
  min-height: var(--agentSizeDesktop);
  max-height: none !important;
  height: auto;
  max-width: none !important;
}

/* Panel principal */
.agent-v2-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  gap: 0;
  background: rgba(29, 32, 40, 0.3);
  border-radius: 16px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.15);
  /* Padding vertical para espaciado, sin padding horizontal para que ocupe 100% */
  padding: 32px 0;
  /* Usar overflow: visible para permitir sombras, pero el scroll se maneja en dialog-panel */
  overflow: visible;
  position: relative; /* Para contexto de apilamiento */
  /* Asegurar que el contenido interno no se desborde horizontalmente */
  min-width: 0;
}

/* Agente interno (solo visible en desktop) */
.agent-v2-visual-internal {
  display: none; /* Oculto por defecto, visible solo en desktop */
}

/* Agente externo (visible por defecto, oculto en desktop) */
.agent-v2-visual-external {
  display: flex; /* Visible por defecto */
}

/* Panel de diálogo (chat + action area) */
.agent-v2-dialog-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow-y: auto;
  /* Cambiar overflow-x para permitir que las sombras se vean */
  /* Pero limitar el ancho del contenido para evitar scroll horizontal */
  overflow-x: visible;
  /* Sin padding horizontal para que ocupe 100% del ancho */
  padding: 0 0 200px 0; /* Solo padding-bottom para textarea expandida */
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0; /* Prevenir que crezca más allá del contenedor */
  position: relative; /* Para contexto de apilamiento */
  /* Asegurar que el contenido interno no cause scroll horizontal */
  contain: layout style;
}

/* Scrollbar personalizado para dialog panel */
.agent-v2-dialog-panel::-webkit-scrollbar {
  width: 6px;
}

.agent-v2-dialog-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.agent-v2-dialog-panel::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}

.agent-v2-dialog-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* Contenedor principal (mantener para compatibilidad si se usa) */
.agent-v2-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  max-width: none;
  margin: 0;
}

/* Wrapper del historial - estilos movidos a history-panel.css */

/* Media query para móvil - reducir espacios */
@media (max-width: 768px) {
  .agent-v2-dialog-container {
    padding: 12px 16px;
    gap: 8px;
  }
}

/* Wrapper del chat */
.agent-v2-chat-wrapper {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Sin padding para que coincida con el input wrapper */
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 1;
}

/* Wrapper del Action Area */
.agent-v2-action-area-wrapper {
  flex: 0 0 auto;
  margin: 0;
  min-height: 0;
  width: 100%;
}

/* Wrapper del input */
.agent-v2-input-wrapper {
  flex: 0 0 auto;
  margin-top: auto;
  /* Sin padding horizontal para que ocupe 100% del ancho */
  padding: 24px 0 calc(24px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-top: 1px solid rgba(139, 92, 246, 0.2);
  position: relative;
  z-index: 10;
  background: rgba(29, 32, 40, 0.3);
  backdrop-filter: blur(10px);
  background: rgba(29, 32, 40, 0.2);
}

/* Utilidades para vistas */
.agent-view-container {
  width: 100%;
  height: 100%;
}

.agent-v1-container {
  /* Vista actual - sin cambios */
}

/* Toggle button en header */
.view-toggle-container {
  display: flex;
  align-items: center;
}

.view-toggle-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.view-toggle-button:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.view-toggle-icon {
  font-size: 16px;
}

.view-toggle-label {
  font-weight: 500;
}
