* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
}

/* Painel de Upload */
.upload-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 10000;
    display: none; /* Escondido por padrão */
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

.upload-panel.show {
    display: flex; /* Mostrar apenas quando tiver classe 'show' */
}

.upload-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 600px;
    width: 90%;
    margin: 20px;
}

.upload-container h1 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 28px;
    text-align: center;
}

.upload-desc {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.upload-section {
    margin-bottom: 25px;
}

.upload-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    font-size: 20px;
}

.upload-input {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    background: #f9f9f9;
}

.upload-input:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.upload-status {
    margin-top: 8px;
    font-size: 13px;
    min-height: 20px;
}

.status-ok {
    color: #27ae60;
    font-weight: 500;
}

.status-erro {
    color: #e74c3c;
    font-weight: 500;
}

.btn-gerar {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-gerar:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-gerar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upload-info {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #666;
}

.upload-info p {
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.upload-info ul {
    margin: 8px 0 0 20px;
    line-height: 1.6;
}

.upload-info code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

#map {
    width: 100%;
    height: 100vh;
}

/* Legendas */
.legenda {
    position: fixed;
    bottom: 25px;
    z-index: 1000;
    background: white;
    padding: 12px 14px;
    border: 1px solid #999;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    font-size: 13px;
    max-width: 250px;
}

#legenda-municipios {
    right: 25px;
}

.legenda-grupos {
    left: 25px;
}

.legenda-titulo {
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
}

.legenda table {
    width: 100%;
    border-collapse: collapse;
}

.legenda table td {
    padding: 2px 0;
    vertical-align: middle;
}

.legenda-cor {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid #333;
    margin-right: 6px;
    vertical-align: middle;
}

.legenda-nota {
    margin-top: 6px;
    color: #666;
    font-size: 11px;
}

/* Botão Carregar Dados */
.btn-carregar-dados {
    position: fixed;
    top: 25px;
    left: 25px;
    z-index: 1000;
}

.btn-reload,
.btn-refresh-poligonos {
    background: white;
    padding: 10px 16px;
    border: 1px solid #999;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #2c3e50;
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.btn-reload:last-child,
.btn-refresh-poligonos:last-child {
    margin-bottom: 0;
}

.btn-reload:hover,
.btn-refresh-poligonos:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.btn-reload:active,
.btn-refresh-poligonos:active {
    transform: translateY(0);
}

/* Controlo de Camadas */
.layer-control {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 1000;
    background: white;
    padding: 12px 14px;
    border: 1px solid #999;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    font-size: 13px;
}

.layer-control-titulo {
    font-weight: 600;
    margin-bottom: 8px;
}

#layer-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.view-mode-control {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}

.btn-view-mode {
    width: 100%;
    padding: 8px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-view-mode:hover {
    background: #5568d3;
}

.btn-view-mode:active {
    background: #4457c2;
}

.layer-btn {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.layer-btn:hover {
    background: #e0e0e0;
}

.layer-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 16px;
    color: #333;
    margin-bottom: 20px;
}

.loading-progress {
    width: 300px;
    max-width: 90%;
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

/* Popup customizado */
.leaflet-popup-content {
    font-size: 13px;
    line-height: 1.5;
}

.leaflet-popup-content b {
    font-size: 14px;
    color: #2c3e50;
}

/* Responsive */
@media (max-width: 768px) {
    .legenda {
        font-size: 11px;
        padding: 8px 10px;
        max-width: 180px;
    }
    
    #legenda-municipios {
        right: 10px;
        bottom: 10px;
    }
    
    .legenda-grupos {
        left: 10px;
        bottom: 10px;
    }
    
    .btn-carregar-dados {
        top: 10px;
        left: 10px;
    }
    
    .btn-reload {
        padding: 8px 12px;
        font-size: 11px;
    }
    
    .layer-control {
        top: 10px;
        right: 10px;
        font-size: 11px;
        padding: 8px 10px;
    }
}

