/* =========================================================
   TOP-NAV.CSS - Menu Superior Profissional
   Projeto: Monitor GeoAmbiental
========================================================= */

:root {
    --top-nav-height: 56px;
    --top-nav-bg: #1b5e20; /* Verde escuro */
    --top-nav-hover: #2e7d32; /* Verde hover */
}

/* ================= BARRA DE NAVEGAÇÃO ================= */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-nav-height);
    background-color: var(--top-nav-bg);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 2100; /* Acima de tudo */
    box-sizing: border-box;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
    white-space: nowrap;
    margin-right: 30px;
}

.nav-brand i {
    font-size: 1.6rem;
}

/* ================= MENU MÓDULOS (DROPDOWN) ================= */
.nav-menu {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-dropdown {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-dropdown-toggle {
    color: white;
    text-decoration: none;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
    height: 36px;
    box-sizing: border-box;
}

.nav-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%; /* Logo abaixo do toggle */
    left: 0;
    background: white;
    min-width: 280px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 0 0 8px 8px;
    z-index: 2200;
    display: none; /* Escondido por padrão */
    overflow: visible; /* Permite que a caixa de busca flutue para fora */
}

.nav-dropdown-menu.show {
    display: block;
}

.nav-dropdown-item {
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    transition: background 0.2s;
    font-size: 0.95rem;
    cursor: pointer;
}

.nav-dropdown-item:hover {
    background-color: #f5f5f5;
    color: var(--top-nav-bg);
}

.nav-dropdown-item i {
    width: 20px;
    text-align: center;
    color: #555;
}

.nav-dropdown-item:hover i {
    color: var(--top-nav-bg);
}

.nav-dropdown-divider {
    height: 1px;
    background-color: #e0e0e0;
    margin: 5px 0;
}

/* ================= BUSCA DENTRO DO DROPDOWN ================= */
.nav-search-container {
    padding: 15px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    position: relative; /* Base para a lista de resultados flutuar */
}

.nav-search-container .search-box-expanded {
    position: relative;
    width: 100%;
    display: block;
}

.search-box-inner {
    display: flex;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
}

.search-input-style {
    border: none;
    padding: 8px 12px;
    width: 100%;
    font-size: 0.95rem;
    outline: none;
    color: #333;
}

.search-btn-style {
    background: var(--top-nav-hover);
    border: none;
    color: white;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn-style:hover {
    background: #388e3c;
}

.search-results-dropdown {
    position: absolute; /* Flutua sobre o conteúdo */
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 2300;
    display: none;
    border-radius: 0 0 4px 4px;
    border: 1px solid #ddd;
}

/* ================= CONTROLES DO MAPA (DIREITA) ================= */
.nav-controls {
    margin-left: auto; /* Empurra para a direita */
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
}

.nav-control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.nav-control-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Container onde o controle de camadas do Leaflet será inserido */
#navbar-basemap-container {
    position: relative;
}

/* Estilizando o controle de camadas do Leaflet que foi movido */
#navbar-basemap-container .leaflet-control-layers {
    position: absolute;
    top: 46px; /* Abaixo do botão */
    right: 0;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 2200;
    color: #333;
    min-width: 180px;
    display: none; /* Controlado por JS */
    border: none;
}

#navbar-basemap-container .leaflet-control-layers.show {
    display: block;
}

/* Remove a seta e borda padrão do Leaflet para limpar o visual */
#navbar-basemap-container .leaflet-control-layers-toggle {
    display: none !important;
}
#navbar-basemap-container .leaflet-control-layers-list {
    margin: 0;
}

/* ================= PREVENÇÃO DE FLASH ================= */
/* Esconde os controles originais do Leaflet IMEDIATAMENTE enquanto eles 
   estiverem dentro do container original do mapa. Assim que o JS os move para 
   o menu superior, eles escapam desta regra e voltam a funcionar normalmente. */
.leaflet-top .leaflet-control-zoom,
.leaflet-top .leaflet-control-layers,
.leaflet-right .leaflet-control-layers {
    display: none !important;
}