/* Tema escuro para dropdown/flyout WhatsApp */

/* Tema escuro refinado para dropdown/flyout WhatsApp */
.dark #modal-whatsapp-instances .rounded-xl {
  background: #19232F !important;
  border: 1px solid #314158 !important;
  color: #EEF6FE !important;
  box-shadow: 0 4px 24px rgba(13, 13, 18, 0.35);
}
.dark #modal-whatsapp-instances h4 {
  color: #EEF6FE !important;
}
.dark #modal-whatsapp-instances .status-badge {
  background: #14304C !important;
  color: #EEF6FE !important;
  border: 1px solid #314158 !important;
}
.dark #modal-whatsapp-instances .instance-label {
  color: #EEF6FE !important;
}
.dark #modal-whatsapp-instances .instance-name {
  color: #AEB0B2 !important;
}
.dark #modal-whatsapp-instances .phone-number {
  color: #AEB0B2 !important;
}
.dark #modal-whatsapp-instances button[data-close] {
  background: #14304C !important;
  color: #EEF6FE !important;
  border: 1px solid #314158 !important;
  box-shadow: none !important;
}
.dark #modal-whatsapp-instances button[data-close]:hover {
  background: #19232F !important;
}
/* Dropdown/flyout para instâncias WhatsApp */
.animate-fade-in {
  animation: fadeInDropdown 0.18s cubic-bezier(0.4,0,0.2,1);
}

@keyframes fadeInDropdown {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
/**
 * SIDEBAR FRONTEND - CSS MODULAR
 * Estilos isolados para o componente sidebar
 */

/* ===================================
   VARIÁVEIS CSS
   =================================== */
:root {
  --sidebar-width-expanded: 208px; /* 52 * 4px = w-52 */
  --sidebar-width-collapsed: 64px;
  --sidebar-transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===================================
   BOTÃO DE TOGGLE EXTERNO
   =================================== */
#sidebar-toggle-external,
.sidebar-toggle-external {
  position: absolute;
  top: 1rem;
  z-index: 50;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: left var(--sidebar-transition), 
              background-color 200ms ease,
              transform 200ms ease;
}

.dark #sidebar-toggle-external,
.dark .sidebar-toggle-external {
  background: #1a2633;
  border-color: #374151;
}

#sidebar-toggle-external:hover,
.sidebar-toggle-external:hover {
  background: #f9fafb;
  transform: scale(1.1);
}

.dark #sidebar-toggle-external:hover,
.dark .sidebar-toggle-external:hover {
  background: #1f2937;
}

#sidebar-toggle-external:active,
.sidebar-toggle-external:active {
  transform: scale(0.95);
}

/* ===================================
   CONTAINER PRINCIPAL
   =================================== */
.zap-sidebar {
  width: var(--sidebar-width-expanded);
  transition: width var(--sidebar-transition),
              transform var(--sidebar-transition);
  will-change: width, transform;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Garantir que nav expanda e footer fique no final */
.zap-sidebar > nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

/* Footer sempre no final da sidebar */
.zap-sidebar .sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
}

/* Estado colapsado */
.zap-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

/* Logo container quando colapsado */
.zap-sidebar.collapsed .p-3 {
  justify-content: center;
}

/* ===================================
   ELEMENTOS QUE ESCONDEM/MOSTRAM
   =================================== */

/* Esconde texto quando colapsado */
.zap-sidebar.collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 150ms ease-out;
}

/* Esconde badges quando colapsado */
.zap-sidebar.collapsed .sidebar-badge {
  display: none;
}

/* Mostra texto quando expandido */
.zap-sidebar:not(.collapsed) .sidebar-text {
  opacity: 1;
  width: auto;
  transition: opacity 200ms ease-in 100ms;
}

/* ===================================
   FOOTER QUANDO COLAPSADO
   =================================== */
.zap-sidebar.collapsed .sidebar-footer {
  padding: 0.5rem;
}

/* Botões de tema empilhados quando colapsado */
.zap-sidebar.collapsed .sidebar-footer > div:first-child {
  flex-direction: column;
}

/* Divisor vertical vira horizontal */
.zap-sidebar.collapsed .sidebar-footer > div:first-child .w-px {
  width: 100%;
  height: 1px;
}

/* Botão de logout quando colapsado - só ícone */
.zap-sidebar.collapsed #sidebar-logout-btn {
  padding: 0.5rem;
  justify-content: center;
}

/* ===================================
   TOOLTIPS QUANDO COLAPSADO
   =================================== */
.zap-sidebar.collapsed a[data-item-id],
.zap-sidebar.collapsed button {
  position: relative;
}

.zap-sidebar.collapsed a[data-item-id]:hover::after,
.zap-sidebar.collapsed button:hover::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  animation: tooltipFadeIn 150ms ease-out;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

/* Dark mode tooltip */
.dark .zap-sidebar.collapsed a[data-item-id]:hover::after,
.dark .zap-sidebar.collapsed button:hover::after {
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a1a;
}

/* ===================================
   ANIMAÇÕES SUAVES
   =================================== */

/* Hover nos items */
.zap-sidebar a[data-item-id] {
  transition: all 200ms ease;
}

.zap-sidebar:not(.collapsed) a[data-item-id]:hover {
  transform: translateX(2px);
}

/* Active state com pulse sutil */
.zap-sidebar a[data-item-id].bg-sky-blue {
  animation: activeItemPulse 2s ease-in-out infinite;
}

@keyframes activeItemPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(12, 136, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(12, 136, 241, 0);
  }
}

/* ===================================
   BADGES
   =================================== */
.sidebar-badge {
  animation: badgeBounce 500ms ease-out;
}

@keyframes badgeBounce {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ===================================
   RESPONSIVIDADE MOBILE
   =================================== */
@media (max-width: 768px) {
  .zap-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
  }
  
  .zap-sidebar.mobile-open {
    transform: translateX(0);
  }
  
  /* Overlay escuro quando aberto no mobile */
  .zap-sidebar.mobile-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
    animation: overlayFadeIn 300ms ease-out;
  }
  
  @keyframes overlayFadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

/* ===================================
   BOTÃO TOGGLE (se adicionar)
   =================================== */
.sidebar-toggle-btn {
  position: absolute;
  right: -12px;
  top: 20px;
  width: 24px;
  height: 24px;
  background: var(--sky-blue, #0C88F1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 12px;
  transition: transform 200ms ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.sidebar-toggle-btn:hover {
  transform: scale(1.1);
}

.zap-sidebar.collapsed .sidebar-toggle-btn {
  transform: rotate(180deg);
}

/* ===================================
   SCROLLBAR CUSTOMIZADA
   =================================== */
.zap-sidebar nav {
  overflow-y: auto;
  overflow-x: hidden;
}

.zap-sidebar nav::-webkit-scrollbar {
  width: 6px;
}

.zap-sidebar nav::-webkit-scrollbar-track {
  background: transparent;
}

.zap-sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.zap-sidebar nav::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.dark .zap-sidebar nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.dark .zap-sidebar nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===================================
   PERFORMANCE OPTIMIZATIONS
   =================================== */
.zap-sidebar * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* GPU acceleration para transições suaves */
.zap-sidebar,
.zap-sidebar a[data-item-id],
.sidebar-text,
.sidebar-badge {
  transform: translateZ(0);
  backface-visibility: hidden;
}
