/* ============================================
   DROPDOWN MULTINÍVEL - Bootstrap 5
   ============================================ */

/* Seta para dropdown de primeiro nível customizado */
.dropdown-toggle-custom::after {
  display: inline-block;
  margin-left: 0.255em;
  vertical-align: 0.255em;
  content: "";
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
}

.dropdown-toggle-custom:empty::after {
  margin-left: 0;
}

/* Submenus aninhados */
.dropdown-menu .dropdown {
  position: relative;
}

.dropdown-menu .dropdown-menu {
  position: absolute;
  top: 0;
  left: 100%;
  margin-top: -0.5rem;
  margin-left: 0.125rem;
}

/* Garantir que submenus fiquem visíveis */
.dropdown-menu .dropdown-menu.show {
  display: block;
}

/* Estilo para o toggle dentro do dropdown */
.dropdown-menu .dropdown-toggle {
  position: relative;
  padding-right: 2.5rem;
  cursor: pointer;
}

/* Indicador de submenu (seta clicável) */
.dropdown-menu .dropdown-toggle .submenu-indicator {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.dropdown-menu .dropdown-toggle .submenu-indicator:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Seta indicadora para submenus */
.dropdown-menu .dropdown-toggle .submenu-indicator::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0;
  vertical-align: 0;
  border-top: 0.3em solid transparent;
  border-right: 0;
  border-bottom: 0.3em solid transparent;
  border-left: 0.3em solid;
}

/* Remover seta padrão do Bootstrap */
.dropdown-menu .dropdown-toggle::after {
  display: none;
}

/* Prevenir que o submenu saia da tela */
.dropdown-menu .dropdown-menu {
  max-width: 250px;
}

/* ============================================
   RESPONSIVIDADE - MOBILE
   ============================================ */
@media (max-width: 991.98px) {
  /* Em mobile, submenus ficam abaixo */
  .dropdown-menu .dropdown-menu {
    position: relative;
    left: 0;
    margin-left: 1rem;
    margin-top: 0;
    box-shadow: none;
    border-left: 2px solid #dee2e6;
  }
  
  /* Ajustar seta para baixo em mobile */
  .dropdown-menu .dropdown-toggle .submenu-indicator::before {
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
  }
  
  /* Quando submenu está aberto, rotar seta */
  .dropdown-menu .dropdown-toggle[aria-expanded="true"] .submenu-indicator::before {
    transform: rotate(180deg);
  }
}

/* ============================================
   DESKTOP - HOVER E POSICIONAMENTO
   ============================================ */
@media (min-width: 992px) {
  /* Garantir que o dropdown principal não feche ao interagir com submenu */
  .navbar .dropdown:hover > .dropdown-menu {
    display: block;
  }
  
  /* Submenu aparece ao lado */
  .dropdown-menu .dropdown:hover > .dropdown-menu {
    display: block;
  }
  
  /* Z-index para submenus ficarem sobre outros elementos */
  .dropdown-menu .dropdown-menu {
    z-index: 1000;
  }
  
  /* Ajuste de margem para não sobrepor */
  .dropdown-menu {
    margin-top: 0;
  }
}

/* ============================================
   MELHORIAS VISUAIS
   ============================================ */

/* Transição suave */
.dropdown-menu {
  transition: opacity 0.2s ease;
}

/* Indicador visual de item com submenu */
.dropdown-menu .dropdown > .dropdown-toggle {
  font-weight: 500;
}

/* Prevenir quebra de linha no texto do menu */
.dropdown-menu .dropdown-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hover nos itens de submenu */
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
  background-color: #f8f9fa;
}

/* Item ativo no submenu */
.dropdown-menu .dropdown-item.active {
  background-color: #0d6efd;
  color: #fff;
}
