/**
 * Sidebar do Assistente Inteligente
 * Componente lateral flutuante e elegante
 */

/* ========== Botão Flutuante Toggle ========== */
.sidebar-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-primary-dark) 100%);
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  z-index: var(--z-modal);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s ease-in-out infinite;
  overflow: visible; /* Permite que o badge apareça fora do botão */
}

.sidebar-toggle:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.6);
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 4px 30px rgba(59, 130, 246, 0.8);
  }
}

/* Esconde o botão quando sidebar está aberto */
.sidebar-toggle.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Badge de notificação no botão */
.sidebar-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent-danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  border: 2px solid var(--bg-primary);
  animation: popIn 0.3s ease;
  z-index: 1;
}

@keyframes popIn {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Animação de shake para notificação */
.sidebar-toggle.shake {
  animation: shake 0.5s ease;
}

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

/* ========== Overlay ========== */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ========== Sidebar Principal ========== */
.sidebar-assistente {
  position: fixed;
  top: 0;
  right: -420px; /* Escondido inicialmente */
  width: 420px;
  height: 100vh;
  background: var(--surface-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
}

.sidebar-assistente.open {
  right: 0;
}

/* ========== Header do Sidebar ========== */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xl);
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--surface-primary) 0%, var(--surface-secondary) 100%);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.sidebar-icon {
  font-size: 28px;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.sidebar-title h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.sidebar-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sidebar-close:hover {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: white;
  transform: rotate(90deg);
}

/* ========== Conteúdo do Sidebar ========== */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-secondary);
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary-hover);
}

.sidebar-section {
  margin-bottom: var(--spacing-lg);
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

/* Mensagem quando vazio */
.sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xxl) var(--spacing-lg);
  text-align: center;
  min-height: 300px;
}

.sidebar-empty-icon {
  font-size: 64px;
  margin-bottom: var(--spacing-lg);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.sidebar-empty-text {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--spacing-sm) 0;
}

.sidebar-empty-subtext {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  margin: 0;
}

/* ========== Footer do Sidebar ========== */
.sidebar-footer {
  padding: var(--spacing-lg) var(--spacing-xl);
  border-top: 1px solid var(--border-color);
  background: var(--surface-secondary);
}

.sidebar-footer-text {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
}

/* ========== Responsividade ========== */
@media (max-width: 768px) {
  .sidebar-assistente {
    width: 100%;
    right: -100%;
  }
  
  .sidebar-assistente.open {
    right: 0;
  }
}

@media (max-width: 480px) {
  .sidebar-toggle {
    width: 56px;
    height: 56px;
    font-size: 24px;
    bottom: 20px;
    right: 20px;
  }
  
  .sidebar-header {
    padding: var(--spacing-lg);
  }
  
  .sidebar-title h2 {
    font-size: var(--font-size-base);
  }
  
  .sidebar-icon {
    font-size: 24px;
  }
  
  .sidebar-content {
    padding: var(--spacing-md);
  }
}

/* ========== Animações ========== */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Classe helper para esconder elementos */
.hidden {
  display: none !important;
}
