/**
 * Mapa Mobile Optimizations
 * Melhorias específicas para visualização do mapa em dispositivos móveis
 * Turismo Mato Grosso - 2025
 */

/* ============================================
   CONTAINER DO MAPA
   ============================================ */

.mapa-container,
#mapa-completo {
    position: relative;
    width: 100%;
    height: 500px;
    border-radius: 12px;
    overflow: hidden;
    margin: 30px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#mapa,
#mapa-completo {
    width: 100%;
    height: 100%;
}

/* Layout Grid Responsivo - FORÇA SOBRESCREVER INLINE STYLES */
.section .container > div[style*="grid"] {
    display: grid !important;
    grid-template-columns: 280px 1fr !important;
    gap: 30px !important;
}

@media (max-width: 992px) {
    .section .container > div[style*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* Garantir que o mapa seja visível */
    #mapa-completo {
        display: block !important;
        width: 100% !important;
        height: 400px !important;
    }
}

/* ============================================
   FILTROS DE BIOMA - MOBILE
   ============================================ */

.filtros-sidebar,
.filtros-bioma {
    background: rgba(10, 26, 20, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

@media (max-width: 992px) {
    .filtros-sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .filtros-sidebar h3 {
        color: var(--primary-green);
        font-size: 1.1rem;
        margin-bottom: 15px;
        font-weight: 600;
    }
    
    .filtros-sidebar label {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 12px;
        margin-bottom: 10px !important;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        cursor: pointer !important;
        transition: all 0.3s ease;
    }
    
    .filtros-sidebar label:hover,
    .filtros-sidebar label:active {
        background: rgba(255, 255, 255, 0.1);
        transform: translateX(5px);
    }
    
    .filtros-sidebar input[type="checkbox"] {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px;
        min-height: 24px;
        cursor: pointer;
        accent-color: var(--primary-green);
    }
    
    .filtros-sidebar label span {
        width: 16px !important;
        height: 16px !important;
        border-radius: 50% !important;
        display: inline-block !important;
        box-shadow: 0 0 8px currentColor;
    }
}

.filtros-bioma h3 {
    color: var(--primary-green);
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.bioma-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.bioma-checkbox:hover,
.bioma-checkbox:active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.bioma-checkbox input[type="checkbox"] {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    cursor: pointer;
    accent-color: var(--primary-green);
}

.bioma-checkbox label {
    flex: 1;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.bioma-checkbox .bioma-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px currentColor;
}

/* Cores dos biomas */
.bioma-checkbox.amazonia .bioma-dot {
    background: var(--amazonia);
}

.bioma-checkbox.araguaia .bioma-dot {
    background: var(--araguaia);
}

.bioma-checkbox.cerrado .bioma-dot {
    background: var(--cerrado);
}

.bioma-checkbox.pantanal .bioma-dot {
    background: var(--pantanal);
}

/* Checkbox checked state */
.bioma-checkbox input[type="checkbox"]:checked + label {
    color: var(--primary-green);
}

.bioma-checkbox input[type="checkbox"]:checked {
    border-color: var(--primary-green);
}

/* ============================================
   CONTROLES DO LEAFLET - MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Container do mapa menor em mobile */
    .mapa-container {
        height: 400px;
        margin: 20px 0;
        border-radius: 8px;
    }

    /* Controles de zoom maiores */
    .leaflet-control-zoom {
        border: none !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }

    .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 24px !important;
        background: rgba(10, 26, 20, 0.95) !important;
        color: var(--primary-green) !important;
        border: none !important;
        border-radius: 8px !important;
        margin-bottom: 8px !important;
        backdrop-filter: blur(10px);
        font-weight: bold;
    }

    .leaflet-control-zoom a:hover,
    .leaflet-control-zoom a:active {
        background: rgba(0, 230, 118, 0.2) !important;
        color: white !important;
    }

    /* Posicionar controles */
    .leaflet-top.leaflet-left {
        top: 15px;
        left: 15px;
    }

    /* Popup do mapa */
    .leaflet-popup-content-wrapper {
        border-radius: 12px !important;
        padding: 4px !important;
        background: rgba(10, 26, 20, 0.98) !important;
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
    }

    .leaflet-popup-content {
        margin: 12px !important;
        font-size: 14px !important;
        line-height: 1.5 !important;
        color: white !important;
        min-width: 200px !important;
    }

    .leaflet-popup-content strong {
        color: var(--primary-green);
        font-size: 1.1rem;
        display: block;
        margin-bottom: 8px;
    }

    .leaflet-popup-content a {
        color: var(--primary-blue);
        font-weight: 600;
        text-decoration: none;
        display: inline-block;
        margin-top: 8px;
        padding: 6px 12px;
        background: rgba(0, 230, 118, 0.1);
        border-radius: 6px;
        transition: all 0.3s ease;
    }

    .leaflet-popup-content a:hover,
    .leaflet-popup-content a:active {
        background: rgba(0, 230, 118, 0.2);
        transform: translateX(3px);
    }

    .leaflet-popup-close-button {
        width: 32px !important;
        height: 32px !important;
        font-size: 24px !important;
        padding: 4px !important;
        color: white !important;
        font-weight: bold;
    }

    .leaflet-popup-tip {
        background: rgba(10, 26, 20, 0.98) !important;
    }

    /* Marcadores maiores */
    .leaflet-marker-icon {
        transition: transform 0.2s ease;
    }

    .leaflet-marker-icon:active {
        transform: scale(1.2);
    }

    /* Attribution menor */
    .leaflet-control-attribution {
        font-size: 10px !important;
        background: rgba(10, 26, 20, 0.8) !important;
        color: rgba(255, 255, 255, 0.6) !important;
        padding: 4px 8px !important;
        border-radius: 4px !important;
    }

    .leaflet-control-attribution a {
        color: var(--primary-green) !important;
    }
}

/* ============================================
   LEGENDA DO MAPA - MOBILE
   ============================================ */

.mapa-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 26, 20, 0.5);
    border-radius: 12px;
    margin-top: 20px;
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.legenda-item:hover,
.legenda-item:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.legenda-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.legenda-item.amazonia .legenda-dot {
    background: var(--amazonia);
}

.legenda-item.araguaia .legenda-dot {
    background: var(--araguaia);
}

.legenda-item.cerrado .legenda-dot {
    background: var(--cerrado);
}

.legenda-item.pantanal .legenda-dot {
    background: var(--pantanal);
}

@media (max-width: 768px) {
    .mapa-legenda {
        gap: 8px;
        padding: 15px;
    }

    .legenda-item {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .legenda-dot {
        width: 12px;
        height: 12px;
    }
}

/* ============================================
   LOADING DO MAPA
   ============================================ */

.mapa-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 26, 20, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
}

.mapa-loading.hidden {
    display: none;
}

.mapa-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 230, 118, 0.2);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.mapa-loading-text {
    margin-top: 20px;
    color: var(--primary-green);
    font-size: 1rem;
    font-weight: 500;
}

/* ============================================
   BOTÃO DE CONTROLE DE DRAG (MOBILE)
   ============================================ */

.leaflet-control-drag {
    background: rgba(10, 26, 20, 0.95) !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px);
}

.leaflet-control-drag a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 20px !important;
    color: var(--primary-green) !important;
    text-decoration: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ============================================
   HINT DE INTERAÇÃO
   ============================================ */

.mapa-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 230, 118, 0.95);
    color: var(--bg-dark);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 999;
    animation: fadeInOut 4s ease-in-out;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 230, 118, 0.4);
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    10%, 90% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 768px) {
    .mapa-hint {
        font-size: 0.75rem;
        padding: 8px 16px;
        bottom: 15px;
    }
}

/* ============================================
   MOBILE SMALL
   ============================================ */

@media (max-width: 480px) {
    .mapa-container {
        height: 350px;
        border-radius: 6px;
    }

    .filtros-bioma {
        padding: 15px;
    }

    .bioma-checkbox {
        padding: 10px;
        margin-bottom: 8px;
    }

    .bioma-checkbox label {
        font-size: 0.9rem;
    }

    .leaflet-control-zoom a {
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        font-size: 20px !important;
    }

    .leaflet-popup-content {
        min-width: 180px !important;
        font-size: 13px !important;
    }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */

@media (max-width: 768px) and (orientation: landscape) {
    .mapa-container {
        height: 300px;
    }

    .filtros-bioma {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 15px;
    }

    .filtros-bioma h3 {
        width: 100%;
        margin-bottom: 10px;
    }

    .bioma-checkbox {
        flex: 0 0 calc(50% - 5px);
        margin-bottom: 0;
    }
}

/* ============================================
   ACESSIBILIDADE
   ============================================ */

@media (max-width: 768px) {
    /* Foco visível */
    .bioma-checkbox:focus-within {
        outline: 3px solid var(--primary-green);
        outline-offset: 2px;
    }

    .leaflet-control-zoom a:focus {
        outline: 3px solid var(--primary-green);
        outline-offset: 2px;
    }

    /* Alto contraste */
    @media (prefers-contrast: high) {
        .bioma-checkbox {
            border: 2px solid white;
        }

        .leaflet-control-zoom a {
            border: 2px solid white !important;
        }
    }
}
