/* ===== Base ===== */
:root {
  --header-bg-start: #155799;
  --header-bg-end: #159957;
  --header-text: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #111;
  overflow-x: hidden;
}

/* ===== Header ===== */
#novo_background {
  background: linear-gradient(120deg, var(--header-bg-start), var(--header-bg-end));
  width: 100%;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 40px;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
}

.container-logo-mp {
  display: flex;
  align-items: center;
  gap: 16px;
}

.container-logo-mp img {
  height: 70px;
  object-fit: contain;
}

/* ===== Hamburger Button ===== */
.menu-toggle {
  display: none;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 10px;
  outline-offset: 2px;
}

.menu-toggle .bar {
  display: block;
  width: 26px;
  height: 3px;
  margin: 5px 0;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ===== Navbar (Desktop default) ===== */
.navbar-nav {
  list-style: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
}

.nav-item {
  position: relative;
}

.nav-link,
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--header-text);
  text-decoration: none;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.3s ease;
}

.nav-link:hover,
.dropdown-item:hover {
  background: rgba(255, 255, 255, .12);
}

.nav-icon {
  display: inline-block;
}

/* ===== Dropdown (Desktop) ===== */
.nav-item.dropdown > .dropdown-toggle {
  cursor: pointer;
  user-select: none;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  min-width: 220px;
  max-width: 280px;
  margin-top: 6px;
  background: var(--header-bg-start);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
  padding: 6px 0;
  list-style: none;
  z-index: 1001;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.nav-item.dropdown.open > .dropdown-menu {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.navbar-nav .nav-item:last-child .dropdown-menu {
  right: 0;
  left: auto;
}

.navbar-nav .nav-item:first-child .dropdown-menu {
  left: 0;
  right: auto;
}

@media (min-width: 769px) {
  .dropdown-menu {
    max-width: calc(100vw - 40px);
  }
}

.dropdown-menu li {
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.dropdown-menu li:last-child {
  border-bottom: none;
}

.dropdown-menu .dropdown-item {
  width: 100%;
  justify-content: flex-start;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  #novo_background {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 20px;
    gap: 10px;
  }

  .container-logo-mp {
    width: 100%;
    justify-content: space-between;
  }

  .menu-toggle {
    display: block;
  }

  .menu-toggle.active .bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle.active .bar:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }

  /* CORREÇÃO PRINCIPAL: Menu mobile */
  .navbar-nav {
    display: none; /* fechado por padrão */
    flex-direction: column;
    width: 100%;
    background: var(--header-bg-start);
    border-radius: 10px;
    padding: 8px;
    gap: 4px;
  }

  .navbar-nav.open {
    display: flex; /* abre quando tem classe .open */
  }

  /* CORREÇÃO: Items do nav no mobile ocupam largura total */
  .nav-item {
    width: 100%;
  }

  /* CORREÇÃO: Link principal do nav */
  .nav-link {
    width: 100%;
    justify-content: flex-start;
  }

  /* CORREÇÃO CRÍTICA: Dropdown no mobile */
  .nav-item.dropdown > .dropdown-menu {
    position: static; /* não é absoluto, fica no fluxo */
    display: none; /* fechado por padrão */
    box-shadow: none;
    background: rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    margin: 4px 0 0 0;
    border-radius: 6px;
    opacity: 1;
    transform: none;
    transition: none;
    pointer-events: auto;
    width: 100%; /* ocupa largura total */
    min-width: auto;
    max-width: none;
    left: auto;
    right: auto;
  }

  /* Quando dropdown está aberto */
  .nav-item.dropdown.open > .dropdown-menu {
    display: block;
  }

  /* Items dentro do dropdown mobile */
  .dropdown-menu li {
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
  }

  .dropdown-item {
    width: 100%;
    padding: 10px 14px 10px 28px;
    font-weight: 600;
    white-space: normal; /* permite quebra de linha se necessário */
  }

  .dropdown-item:hover {
    background: rgba(255, 255, 255, .08);
  }

  /* CORREÇÃO: Remove animações no mobile */
  .dropdown-menu {
    animation: none;
  }

  /* CORREÇÃO: Garante que o nav-item não force posição absoluta */
  .nav-item.dropdown {
    position: relative;
    overflow: visible;
  }
}

/* ===== Acessibilidade (foco) ===== */
a:focus-visible,
button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Desktop: overflow visível */
@media (min-width: 769px) {
  .navbar-nav,
  #novo_background {
    overflow: visible !important;
  }

  .nav-item {
    overflow: visible !important;
  }
}

/* Mobile: overflow controlado */
@media (max-width: 768px) {
  #novo_background {
    overflow: visible;
  }

  .navbar-nav {
    overflow: visible;
  }
}

/* ===== Melhorias visuais ===== */
.dropdown-toggle::after {
  content: ' ▼';
  font-size: 0.7em;
  margin-left: 4px;
  transition: transform 0.3s ease;
}

.nav-item.dropdown.open > .dropdown-toggle::after {
  transform: rotate(180deg);
}

.nav-item {
  transition: all 0.3s ease;
}

@media (min-width: 769px) {
  .nav-link:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
}

/* ===== Estado ativo ===== */
.nav-link.active,
.dropdown-item.active {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Previne problemas de z-index ===== */
.navbar-nav {
  z-index: 1000;
}

.dropdown-menu {
  z-index: 1001;
}

@media (max-width: 768px) {
  /* Fundo branco dos itens do dropdown */
  .nav-item.dropdown > .dropdown-menu {
    background: #fff !important;
  }

  /* Texto escuro e mais visível no mobile */
  .dropdown-item {
    color: #111 !important;
  }

  /* Hover com leve cinza */
  .dropdown-item:hover {
    background: #f2f2f2 !important;
  }

  /* Ícones escuros também */
  .dropdown-item .nav-icon {
    color: #333 !important;
  }
}
