/* Estilos Gerais */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8fafc;
    color: #333;
}

header {
    text-align: center;
    background-color: #005f8a;
    color: white;
    padding: 20px 0;
    margin: 0;
    position: relative;
}

header img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

h1 {
    margin-top: 100px;
    font-size: 24px;
}

#controls {
    position: sticky;
    top: 0;
    z-index: 1000;
    margin: 10px;
    padding: 10px;
    background-color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

label {
    font-weight: bold;
    margin-bottom: 5px;
    text-align: center;
}

select {
    margin: 5px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.3s ease;
}

select:focus {
    border-color: #005f8a;
    outline: none;
}

button {
    background-color: #0077b6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: 150px;
    height: 60px;
}

button:hover {
    background-color: #005f8a;
    transform: scale(1.05);
}

/* Conteúdo Principal */
#content {
    width: 98%;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Mapa e Gráfico lado a lado */
#map-and-chart {
    display: flex;
    flex-direction: column; /* Mobile: empilhados */
    gap: 20px;
}

/* Mapa e Chart ocupam a mesma "altura" e se ajustam na horizontal no desktop */
#map {
    width: 100%;
    height: 400px; /* Altura menor para mobile */
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#chart-container {
    width: 100%;
}

#chart-container h2 {
    margin-top: 0;
}

#plotly-chart {
    width: 100%;
    height: 400px; /* Altura do gráfico para mobile */
}

/* Tabela */
#table-container {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

#data-table th, #data-table td {
    border: 1px solid #ddd;
    padding: 12px 15px;
    text-align: center;
}

#data-table th {
    background-color: #0077b6;
    color: white;
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 16px;
}

#data-table tr {
    transition: background-color 0.3s ease;
}

#data-table tr:nth-child(even) {
    background-color: #f2f9ff;
}

#data-table tr:hover {
    background-color: #d1e7f5;
}

#data-table td {
    font-size: 14px;
    color: #333;
}

/* Ícone de Filtro para Mobile */
#filter-button {
    display: none; /* Oculto por padrão */
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #0077b6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#filter-button:hover {
    background-color: #005f8a;
    transform: scale(1.1);
}

/* Modal para Filtros em Mobile */
.modal {
    display: none; /* Oculto por padrão */
    position: fixed;
    z-index: 1002; /* Acima do filtro button */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5); /* Fundo semi-transparente */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% do topo e centralizado */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Largura da modal */
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#mobile-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- Responsividade --- */
@media (min-width: 769px) {
    /* No desktop, exibe mapa e gráfico lado a lado */
    #map-and-chart {
        flex-direction: row; /* Lado a lado */
    }

    #map {
        width: 50%;      /* Mapa ocupa metade */
        height: 600px;   /* Maior altura para desktop */
    }

    #plotly-chart {
        width: 100%;
        height: 600px;   /* Mesmo tamanho do mapa */
    }
}

@media (max-width: 768px) {
    #controls {
        display: none; /* Oculta os controles na versão mobile */
    }

    #filter-button {
        display: block; /* Mostra o ícone de filtro na mobile */
    }

    #content {
        width: 95%;
    }

    #data-table {
        min-width: 100%;
    }

    /* Ajustes dentro da Modal no Mobile */
    .modal-content h2 {
        text-align: center;
        margin-bottom: 20px;
    }

    .control-group {
        width: 100%;
    }

    #mobile-controls select {
        width: 100%;
    }

    #apply-filters {
        align-self: center;
        width: 50%;
    }
}
