.legend-horizontal {
  width: 100%;
  max-width: 100vw;
  background: white;
  padding: 8px 10px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
  border-radius: 12px 12px 0 0;
  overflow-x: auto;
  box-sizing: border-box;
  font-size: 14px;
}

.legend-container {
  display: flex;
  flex-direction: column;
}

.legend-title {
  margin-bottom: 6px;
  font-weight: bold;
}

.legend-items {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  white-space: nowrap;
  gap: 6px;
  font-size: 13px;
}

.legend-item img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.legend-item .box {
  width: 18px;
  height: 18px;
  border: 1px solid #000;
}

.box.iphan {
  background-color: #FFD700;
}

.box.unesco {
  background-color: #DAA520;
}

/* Scroll estético */
.legend-horizontal::-webkit-scrollbar {
  height: 6px;
}
.legend-horizontal::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

    body {
      padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
      box-sizing: border-box;
    }
    html, body { height: 100%; margin: 0; padding: 0; font-family: Arial, sans-serif; background-color: #ffffff; }
    #mapweb { height: calc(100vh - 30px); width: 100%; }

    /* Painel retrátil superior (Busca/Ferramentas) */
    .search-container { position: absolute; top: 0; left: 0; right: 0; z-index: 999; transition: top 0.3s; }
    .search-panel { background: #fff; border-radius: 10px; margin: 6px auto; width: max-content; box-shadow: 0 2px 6px rgba(0,0,0,0.3); overflow: hidden; }
    .search-header { padding: 8px 16px; font-weight: bold; background: #f0f0f0; cursor: pointer; border-bottom: 1px solid #ccc; text-align: center; user-select: none; }
    #searchContainer .search-body { display: none; }
    #searchContainer.open .search-body {
    display: flex;
    flex-direction: column; /* EMPILHA AS LINHAS */
    gap: 8px; /* Espaço entre a linha de busca e a de categorias */
    align-items: center;
    padding: 8px;
}

    .search-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
    .search-body input { border: 1px solid #ccc; padding: 6px 10px; border-radius: 20px; width: 160px; outline: none; }
    .search-buttons button { background-color: white; border: none; padding: 6px; border-radius: 50%; font-size: 16px; cursor: pointer; }

    .whatsapp-btn { position: fixed; bottom: 80px; right: 20px; background-color: #25D366; color: white; font-size: 24px; padding: 12px; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.3); text-decoration: none; z-index: 10000; }

    /* Pop-up de resultados (busca) */
    #resultadoBusca { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); z-index: 9999; display: none; justify-content: center; align-items: center; padding: 10px; }
    #resultadoBusca .conteudo { background: white; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; border-radius: 10px; padding: 16px; font-family: sans-serif; }
    #resultadoBusca strong { font-size: 1.1rem; display: block; margin-bottom: 10px; }
    #listaResultados { list-style-type: disc; padding-left: 20px; font-size: 1rem; margin: 0; }
    #listaResultados li { margin-bottom: 6px; cursor: pointer; }
    #fecharPopupBusca { margin-top: 20px; width: 100%; background-color: #f44336; color: white; border: none; border-radius: 8px; padding: 10px; font-size: 1rem; font-weight: bold; cursor: pointer; }

    /* POPUP (layout grande) */

/* O Container Principal */

/* Remove a seta/bico do balão */
.leaflet-popup-tip-container, .leaflet-popup-tip {
    display: none !important;
}

/* O Container Externo (A "Janela") */
.leaflet-container .fullpopup .leaflet-popup-content-wrapper {
    width: 340px !important;
    max-width: 90vw !important; /* Celular */
    
    /* Altura segura: 60% da tela (dá espaço para menus em cima e embaixo) */
    height: 60vh !important; 
    max-height: 600px !important;
    
    border-radius: 16px !important;
    overflow: hidden !important; /* Corta o que sobrar */
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    padding: 0 !important;
    
    /* Garante que o conteúdo interno ocupe tudo */
    display: flex !important;
    flex-direction: column !important;
}

/* O Conteúdo do Leaflet */
.leaflet-container .fullpopup .leaflet-popup-content {
    width: 100% !important;
    height: 100% !important; /* Ocupa toda a altura da janela */
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* A SUA DIV PRINCIPAL (A PEÇA QUE FALTAVA!) */
.popup-big {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important; /* Isso obriga o popup a respeitar o limite */
    width: 100% !important;
}

/* --- Itens Internos --- */

/* Imagem (Fixo) */
.popup-big__media {
    flex-shrink: 0; /* Não encolhe */
    height: 160px !important;
    background: #eee;
}
.popup-big__media img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Título (Fixo) */
.popup-big__title {
    flex-shrink: 0;
    padding: 12px 15px 5px 15px !important;
    font-size: 16px !important;
    font-weight: bold;
    color: #222;
}

/* Descrição (A ÚNICA COISA QUE ENCOLHE) */
.popup-big__desc {
    flex: 1 !important; /* Ocupa o espaço livre e empurra botões p/ baixo */
    min-height: 0 !important; /* Bugfix para rolagem funcionar */
    padding: 5px 15px 10px 15px !important;
    font-size: 14px;
    line-height: 1.4;
    color: #555;
    overflow-y: auto !important; /* Barra de rolagem aparece AQUI */
}

/* Botões (Fixo no Rodapé) */
.popup-big__actions {
    flex-shrink: 0; /* GARANTE QUE NUNCA SOME */
    padding: 10px 15px 15px 15px !important;
    background: white;
    border-top: 1px solid #f0f0f0;
    
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
}

.popup-btn {
    flex: 1 !important;
    height: 44px !important;
    border-radius: 8px !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    font-size: 12px !important;
    font-weight: bold !important;
    color: white !important;
    cursor: pointer;
    text-transform: uppercase;
}

.popup-btn--close { background-color: #ff4d4d !important; }
.popup-btn--route { background-color: #28a745 !important; }

/* Ícones dentro dos botões */
.popup-btn i { font-size: 14px !important; margin: 0 !important; }

    .popup-big{ display:flex; flex-direction:column; background:#fff; }
    .popup-big__title{ padding:18px 18px 10px; font-size:22px; line-height:1.25; font-weight:700; color:#222; }
    .popup-big__media{ width:100%; height:32vh; overflow:hidden; }
    .popup-big__media img{ width:100%; height:100%; display:block; object-fit:cover; }
    .popup-big__desc{ padding:12px 18px; flex:1 1 auto; overflow-y:auto; -webkit-overflow-scrolling: touch; color:#333; font-size:14px; line-height:1.5; }
    .popup-big__actions{ padding:12px 18px 3px; display:grid; grid-template-columns:1fr 1fr; gap:12px; border-top:1px solid #eee; }
    .popup-btn{ height:46px; display:inline-flex; align-items:center; justify-content:center; gap:8px; font-size:15px; font-weight:700; border:0; border-radius:12px; color:#fff; cursor:pointer; }
    .popup-btn--close{ background:#f44336; }
    .popup-btn--route{ background:#28a745; }
    .popup-btn i{ font-size:16px; }

    @media (max-width: 420px){
      .leaflet-container .fullpopup .leaflet-popup-content-wrapper{ width:94vw; max-height:80vh; }
    }

    /* Splash */
    #splash { position:fixed; top:0; left:0; width:100vw; height:100vh; background:#ffffff; display:flex; align-items:center; justify-content:center; z-index:99999; }
    #splash .logo { width:min(72vw, 280px); height:auto; margin-bottom:16px; }
    .spinner { width:38px; height:38px; border-radius:50%; border:4px solid #cfe0ff; border-top-color:#0b376b; animation:spin 1s linear infinite; }
    @keyframes spin { to { transform: rotate(360deg); } }
    #splash.hide { display:none; }

    /* Barra inferior */
    .footer-bar { position:fixed; bottom:0; left:0; right:0; height:56px; background:#ffffff; border-top:1px solid #ddd; display:flex; justify-content:space-around; align-items:center; z-index:9999; font-family:sans-serif; }
    .footer-bar button { flex:1; height:100%; background:none; border:none; outline:none; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:11px; color:#444; cursor:pointer; }
    .footer-bar button i { font-size:18px; margin-bottom:2px; }
    .footer-bar button.active { color:#007bff; }
    .footer-credito { position:fixed; bottom:5px; left:0; right:0; text-align:center; font-size:12px; color:#555; z-index:999; font-family:sans-serif; }

    /* Painéis sobrepostos (Eventos/Rotas) */
    #painelEventos, #painelRotas{
      position:fixed; top:0; left:0; width:100vw; height:100vh;
      background:rgba(0,0,0,.6); z-index:10000; display:none;
      justify-content:center; align-items:center; padding:10px;
    }
    #painelEventos .conteudo, #painelRotas .conteudo{
      background:#fff; max-width:520px; width:100%;
      max-height:90vh; overflow-y:auto; border-radius:10px; padding:16px;
      font-family:sans-serif;
    }
    #painelEventos h3, #painelRotas h3 { margin:0 0 10px; font-size:18px; }

    /* Lista de eventos */
    #listaEventos .event-item{ padding:10px 0; border-bottom:1px solid #eee; }
    #listaEventos .event-line{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
    #listaEventos .event-name{ font-weight:700; }
    #listaEventos .event-date{ font-size:12px; color:#555; }
    #listaEventos .event-info{ margin-top:4px; font-size:13px; color:#333; }
    #listaEventos .event-go{
      margin-top:6px; background:#28a745; color:#fff; border:0; border-radius:8px;
      padding:6px 10px; font-weight:700; cursor:pointer;
    }
    #fecharPainelEventos{
      margin-top:14px; width:100%; background:#f44336; color:#fff; border:0;
      border-radius:8px; padding:10px; font-weight:700; cursor:pointer;
    }

    /* Lista de rotas */
    #listaRotas .route-item{ padding:10px 0; border-bottom:1px solid #eee; }
    #listaRotas .route-line{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
    #listaRotas .route-name{ font-weight:700; }
    #listaRotas .route-dist{ font-size:12px; color:#555; }
    #listaRotas .route-info{ margin-top:4px; font-size:13px; color:#333; }
    #listaRotas .route-actions{ margin-top:6px; display:flex; gap:8px; }
    #listaRotas .route-actions button{
      background:#eee; color:#222; border:0; border-radius:8px;
      padding:6px 10px; font-weight:700; cursor:pointer;
    }
    #listaRotas .route-actions .route-map{ background:#28a745; color:#fff; }
    #fecharPainelRotas{
      margin-top:14px; width:100%; background:#f44336; color:#fff; border:0;
      border-radius:8px; padding:10px; font-weight:700; cursor:pointer;
    }

    /* Ícone custom do "Estou aqui" (círculo) */
    .leaflet-div-icon.user-marker{ width:28px; height:28px; background:none; border:none; }
    .leaflet-div-icon.user-marker svg{ display:block; width:28px; height:28px; }

    /* LRM (Leaflet Routing Machine): retrátil + rolável */
    .leaflet-routing-container.leaflet-bar { max-height: 56vh; overflow: auto; }
    .routinguibox { transition: transform .25s ease, opacity .2s ease; }
    .routinguibox.collapsed { transform: translateX(110%); opacity: 0; pointer-events: none; }
    .leaflet-control.toggle-route {
      background: #fff; border-radius: 10px; padding: 6px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.25);
      font-weight: 600; cursor: pointer; user-select: none;
    }

    /* Evento de hoje já executado (hora passada) */
    #listaEventos .event-item.past .event-line,
    #listaEventos .event-item.past .event-info { text-decoration: line-through; opacity: .7; }

    /* Badge com número de eventos no marcador */
    .leaflet-event-marker { position: relative; display: inline-block; }
    .leaflet-event-badge {
      position: absolute; top: -6px; right: -6px;
      min-width: 14px; height: 14px; padding: 0 3px;
      background: #dc3545; color: #fff; font-weight: 700; font-size: 11px; line-height: 14px;
      border-radius: 10px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.35);
      pointer-events: none;
    }

    /* Oculta marcadores quando não estiver no zoom máximo */
    .leaflet-marker-icon.hidden { display: none !important; }

    /* Força rolagem no conteúdo do popup */
    .popup-big__desc{
      max-height: 36vh;
      overflow-y: auto;
      scrollbar-gutter: stable;
    }

    /* DENTRO DE styless.css */

/* Estilos para os botões de categoria */
.category-buttons {
    display: flex;
    gap: 6px;
    justify-content: center; /* Centraliza os botões */
    width: 100%;
}

.category-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.category-btn:hover {
    background-color: #e0e0e0;
}

/* Estilo para o botão quando uma categoria está ATIVA */
.category-btn.active {
    background-color: #cce5ff; /* Um azul claro */
    border-color: #007bff;
    color: #007bff;
}

/* --- ESTILO DO PAINEL ANUNCIE --- */

/* Reutiliza o estilo de fundo dos outros painéis */
#painelAnuncie {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6); /* Fundo escuro transparente */
    z-index: 10000;
    display: none; /* Começa escondido */
    justify-content: center;
    align-items: center;
    padding: 10px;
}

#painelAnuncie .conteudo {
    background: #fff;
    max-width: 450px; /* Um pouco mais estreito que os outros */
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 20px;
    font-family: sans-serif;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

/* Estilo do Formulário */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box; /* Garante que o padding não aumente a largura */
}

.form-group input:focus {
    border-color: #007bff;
    outline: none;
}

/* Botão de Enviar */
.btn-submit-anuncio {
    width: 100%;
    background-color: #007bff; /* Azul padrão */
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-submit-anuncio:hover {
    background-color: #0056b3; /* Azul mais escuro ao passar o mouse */
}

/*RESPONSIVIDADE (CELULARES E TABLETS)*/


@media (max-width: 768px) {

    /* Aumenta a largura do popup para ocupar 90% da tela do celular */
    .leaflet-popup-content-wrapper {
        width: 90vw !important; /* 90% da largura da tela */
        max-width: 380px !important; /* Trava para não ficar gigante em tablets */
        border-radius: 12px !important;
        padding: 0 !important; /* Remove borda branca interna */
    }

    .leaflet-popup-content {
        width: 100% !important;
        margin: 0 !important;
    }

    /* Ajusta a altura da imagem para sobrar espaço pro texto */
    /* Reduzimos de 220px (PC) para 160px (Celular) */
    .popup-big__media {
        height: 160px !important; 
        background-color: #f5f5f5 !important; /* Cinza clarinho elegante */
    }

    /* Título um pouco menor para não quebrar em 3 linhas */
    .popup-big__title {
        font-size: 16px !important;
        padding: 12px 15px 5px 15px !important;
    }

    /* Descrição com rolagem (scroll) se o texto for grande */
    .popup-big__desc {
        font-size: 14px !important;
        max-height: 120px !important; /* Altura máxima do texto */
        overflow-y: auto !important;  /* Cria barra de rolagem se passar */
        padding: 5px 15px 15px 15px !important;
        line-height: 1.4 !important;
    }

    /* Botões grandes e fáceis de tocar (Dedo gordo friendly) */
    .popup-big__actions {
        display: flex !important;
        gap: 10px !important;
        padding: 0 15px 15px 15px !important;
    }

    .popup-btn {
        flex: 1; /* Faz os dois botões terem o mesmo tamanho */
        height: 44px !important; /* Altura mínima recomendada pela Apple/Google */
        font-size: 14px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Ajuste fino para o ícone de fechar do Leaflet não atrapalhar */
    .leaflet-popup-close-button {
        top: 8px !important;
        right: 8px !important;
        font-size: 18px !important;
        color: white !important; /* X branco para aparecer em cima da foto/fundo */
        background: rgba(0,0,0,0.3) !important; /* Bolinha escura atrás do X */
        border-radius: 50% !important;
        width: 24px !important;
        height: 24px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* Garante que o conteúdo do Leaflet ocupe 100% da altura e use Flexbox */
.leaflet-container .fullpopup .leaflet-popup-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important; /* Remove margens padrões que empurram conteúdo */
}

/* A estrutura do seu cartão */
.popup-big {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important; /* Impede que o cartão vaze */
}

/* A IMAGEM e o TÍTULO não encolhem */
.popup-big__media, 
.popup-big__title {
    flex-shrink: 0 !important;
}

/* A DESCRIÇÃO é a única que pode encolher e criar barra de rolagem */
.popup-big__desc {
    flex: 1 1 auto !important; /* Ocupa o espaço que sobrar */
    overflow-y: auto !important; /* Cria scroll se o texto for grande */
    min-height: 0 !important; /* CRÍTICO: Permite que o flexbox encolha o texto */
    height: auto !important; /* Remove altura fixa se houver */
    max-height: none !important; /* Remove limite antigo */
}

/* O RODAPÉ (Botões) nunca encolhe e fica fixo embaixo */
.popup-big__actions {
    flex-shrink: 0 !important;
    margin-top: auto !important; /* Empurra para o fundo se sobrar espaço */
    background: white; /* Garante que o texto não passe por trás */
    z-index: 10;
}

/* Remove os botões de zoom (+ e -) apenas em telas menores que 768px (celulares e tablets pequenos) */
@media (max-width: 768px) {
    .leaflet-control-zoom {
        display: none !important;
    }
}

/* 1. Reseta o container externo do Leaflet apenas para este popup */
/* Usa !important para sobrescrever as regras dos popups principais */
.popup-aviso .leaflet-popup-content-wrapper {
    width: auto !important;
    max-width: 260px !important; /* Largura fixa compacta para mobile */
    height: auto !important;     /* Altura automática baseada no conteúdo */
    border-radius: 16px !important;
    padding: 0 !important;       /* Remove padding padrão */
    background: #fff;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25) !important; /* Sombra mais suave */
}

/* Garante que o conteúdo interno se ajuste */
.popup-aviso .leaflet-popup-content {
    width: 100% !important;
    margin: 0 !important;
}

/* 2. Estilização do Conteúdo Interno (Classes novas) */
.aviso-container {
    padding: 24px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px; /* Espaço entre os elementos */
}

/* Ícone */
.aviso-icon {
    font-size: 32px; /* Ícone maior */
    color: #f39c12;  /* Cor laranja */
    margin-bottom: 4px;
    /* Adiciona um fundo circular suave atrás do ícone */
    background-color: #fff3cd;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Título */
.aviso-title {
    font-size: 16px;
    font-weight: 700;
    color: #222;
    margin: 0;
}

/* Subtítulo */
.aviso-subtitle {
    font-size: 13px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}
/* PAINEL HISTÓRICA*/

#painelHistorico {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.6); /* Fundo escuro suave */
    backdrop-filter: blur(2px); /* Desfoque leve no fundo (efeito vidro) */
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

#painelHistorico .conteudo {
    background: #fff;
    width: 100%;
    max-width: 360px; /* Largura de celular (fica elegante no PC) */
    height: 70vh;     /* Altura fixa (70% da tela) */
    max-height: 600px;
    border-radius: 20px; /* Cantos bem arredondados */
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column; /* Organiza: Cabeçalho, Lista, Botão */
    overflow: hidden; /* Impede vazar conteúdo */
    animation: subirSuave 0.3s ease-out; /* Pequena animação ao abrir */
}

@keyframes subirSuave {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Cabeçalho do Painel */
#painelHistorico h3 {
    margin: 0;
    padding: 18px 20px;
    background-color: #f8f9fa; /* Cinza bem clarinho */
    border-bottom: 1px solid #eee;
    font-size: 16px;
    font-weight: 700;
    color: #444;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Não encolhe */
}

/* A Lista (Agora só ela rola) */
#listaHistorico {
    flex: 1; /* Ocupa todo o espaço do meio */
    overflow-y: auto; /* Scroll suave */
    padding: 0;
    background: #fff;
}

/* Itens da Lista */
.historico-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f4f4f4;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
}

.historico-item:hover {
    background-color: #f0f8ff;
    padding-left: 25px; /* Efeito visual de movimento */
}

.historico-item i {
    font-size: 16px;
    color: #8d6e63;
    opacity: 0.8;
}

/* Botão Fechar (Fixo embaixo) */
#fecharPainelHistorico {
    margin: 0;
    width: 100%;
    border: none;
    border-radius: 0; /* Quadrado para fechar o rodapé do card */
    padding: 16px;
    background: #f44336;
    color: white;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

#fecharPainelHistorico:hover {
    background: #d32f2f;
}