/**
 * History Panel - Estilos del panel de historial expandible
 */

/* Wrapper del historial - ya no necesita espacio para el botón */
.agent-v2-history-wrapper {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  margin-bottom: 0;
  overflow: visible;
  padding-top: 0; /* Sin padding, el botón está dentro del card */
  height: 0; /* Colapsar completamente en móvil */
}

/* Botón de historial dentro del card MENSAJE */
.history-toggle-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 245, 255, 0.1);
  border: 2px solid rgba(0, 245, 255, 0.3);
  color: var(--neon-cyan);
  font-size: 20px;
  cursor: pointer;
  display: none; /* Oculto inicialmente, se mostrará cuando haya mensajes */
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 20; /* Por encima del overflow hidden del contenedor */
  margin: 0;
  padding: 0;
}

.history-toggle-button svg {
  width: 20px;
  height: 20px;
  stroke: var(--neon-cyan);
}

.history-toggle-button:hover {
  background: rgba(0, 245, 255, 0.2);
  border-color: rgba(0, 245, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 245, 255, 0.4);
  transform: translateY(-2px);
}

/* Mostrar el botón cuando hay mensajes */
.history-toggle-button[style*="display: flex"],
.history-toggle-button[style*="display:block"] {
  display: flex !important;
}

/* Overlay del historial */
.history-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-overlay.active {
  pointer-events: auto;
  opacity: 1;
}

.history-overlay-content {
  position: absolute;
  background: rgba(29, 32, 40, 0.95);
  border: 2px solid rgba(139, 92, 246, 0.4);
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
  max-height: 50vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.history-overlay.active .history-overlay-content {
  transform: translateY(0);
}

/* Desktop: centrado y ancho similar al chat */
@media (min-width: 769px) {
  .history-overlay-content {
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% - 20px));
    width: 90%;
    max-width: 800px;
  }
  
  .history-overlay.active .history-overlay-content {
    transform: translate(-50%, -50%);
  }
}

/* Mobile: bottom-sheet */
@media (max-width: 768px) {
  .history-overlay-content {
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    width: 100%;
    transform: translateY(100%);
  }
  
  .history-overlay.active .history-overlay-content {
    transform: translateY(0);
  }
}

/* Backdrop */
.history-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.history-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.history-content {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 20px;
  max-height: none;
  overflow-y: auto;
  margin: 0;
  animation: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Estilos para mensajes en el overlay */
.history-overlay-content .history-message {
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  animation: fadeIn 0.3s ease;
}

.history-overlay-content .history-message-user {
  background: rgba(139, 92, 246, 0.1);
  border-left-color: var(--neon-purple);
}

.history-overlay-content .history-message-agent {
  background: rgba(0, 245, 255, 0.05);
  border-left-color: var(--neon-cyan);
}

.history-overlay-content .history-message-content {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.history-overlay-content .history-message-timestamp {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  opacity: 0.6;
}

.history-overlay-content .history-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

/* Scrollbar personalizado para overlay content */
.history-overlay-content::-webkit-scrollbar {
  width: 6px;
}

.history-overlay-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.history-overlay-content::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}

.history-overlay-content::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}
