/**
 * Estilos para o mapa interativo
 */

/* Container principal */
.mapa-fetracse-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    min-height: 600px;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    border: none;
}

/* Wrapper do mapa */
.mapa-wrapper {
    position: relative;
    flex: 1;
    background: #fafbfc;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: none;
    height: 100%;
    min-height: 0;
}

/* Dica flutuante de interatividade */
.mapa-tooltip {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #070865;
    color: #fff;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(7, 8, 101, 0.3);
    z-index: 50;
    max-width: 280px;
    animation: tooltipSlideIn 0.5s ease;
    transition: all 0.3s ease;
}

.mapa-tooltip.hidden {
    opacity: 0;
    transform: translateX(100%);
    pointer-events: none;
}

.tooltip-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.tooltip-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
}

.tooltip-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.tooltip-text strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

.tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tooltip-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

@keyframes tooltipSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Container do SVG */
.mapa-svg-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #fff;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* SVG do mapa */
.mapa-svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    margin: 0 auto;
    transition: all 0.3s ease;
    object-fit: contain;
}

/* Caminhos das cidades */
.mapa-svg .city-path,
.mapa-svg path.cls-3,
.mapa-svg g[id] {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    fill: #2a4ea2 !important; /* Cor padrão sempre visível */
    stroke: #ffffff;
    stroke-width: 1px;
    opacity: 1 !important; /* Sempre visível */
    /* Melhoria para mobile - área de toque maior */
    min-width: 44px;
    min-height: 44px;
    position: relative;
}

.mapa-svg .city-path:hover,
.mapa-svg path.cls-3:hover,
.mapa-svg g[id]:hover {
    fill: #e6e7ff;
    stroke: #070865;
    stroke-width: 2px;
    filter: none;
}

.mapa-svg .city-path:active,
.mapa-svg path.cls-3:active,
.mapa-svg g[id]:active {
    transform: scale(0.98);
}

/* Estados touch para mobile */
.mapa-svg .city-path.touch-active,
.mapa-svg path.cls-3.touch-active,
.mapa-svg g[id].touch-active {
    fill-opacity: 0.8 !important;
    stroke: #070865 !important;
    stroke-width: 3px !important;
    transform: scale(0.95) !important;
    transition: all 0.15s ease !important;
    filter: brightness(1.1) !important;
}

/* Estados touch para dropdown */
.dropdown-toggle.touch-active,
.dropdown-item.touch-active,
.tooltip-close.touch-active {
    background: rgba(7, 8, 101, 0.1) !important;
    transform: scale(0.98) !important;
    transition: all 0.1s ease !important;
}

/* Efeito ripple para feedback visual em mobile */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(7, 8, 101, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
    z-index: 10;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Estado ativo/selecionado */
.city-path.active,
path.cls-3.active,
g[id].active,
[data-city-id].active,
.mapa-svg .city-path.active,
.mapa-svg path.cls-3.active,
.mapa-svg g[id].active,
.mapa-svg [data-city-id].active {
    fill: #070865 !important;
    stroke: #05054a !important;
    stroke-width: 2px !important;
    transition: all 0.2s ease !important;
    opacity: 1 !important;
}

/* Painel de informações */
.mapa-info-panel {
    width: 420px;
    background: #fff;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
    border-radius: 0 12px 12px 0;
    height: 100%;
    overflow-y: auto;
}

/* Cabeçalho do painel */
.mapa-info-panel .panel-header {
    padding: 24px 28px;
    border-bottom: 1px solid #e8ecf0;
    background: #fafbfc;
}

/* Dropdown de cidades */
.cities-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-toggle {
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 2px solid #e8ecf0;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
}

.dropdown-toggle:hover {
    border-color: #070865;
    background: #f8f9ff;
}

.dropdown-toggle.active {
    border-color: #070865;
    background: #f8f9ff;
    box-shadow: 0 0 0 3px rgba(7, 8, 101, 0.1);
}

.dropdown-icon {
    color: #070865;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-text {
    flex: 1;
    text-align: left;
}

.dropdown-arrow {
    color: #666;
    transition: transform 0.2s ease;
}

.dropdown-toggle.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #e8ecf0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.dropdown-menu.show {
    display: block;
    animation: slideDown 0.2s ease;
}

.dropdown-list {
    padding: 8px 0;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 15px;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Estado normal do texto da cidade */
.dropdown-item .city-name-text {
    color: #1a1a1a;
    transition: color 0.2s ease;
}

/* Estado normal do indicador de cor */
.dropdown-item .city-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Estado hover */
.dropdown-item:hover {
    background: #f8f9ff;
}

.dropdown-item:hover .city-name-text {
    color: #070865 !important;
}

.dropdown-item:hover .city-color-indicator {
    border-color: #070865;
    transform: scale(1.1);
}

/* Estado selecionado */
.dropdown-item.selected {
    background: #070865;
    color: #fff;
}

.dropdown-item.selected .city-name-text {
    color: #fff !important;
}

.dropdown-item.selected .city-color-indicator {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mapa-info-panel .info-content {
    padding: 24px;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Estado padrão quando nenhuma cidade está selecionada */
.mapa-info-panel .default-state {
    text-align: center;
    color: #666;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.mapa-info-panel .default-state .icon {
    width: 64px;
    height: 64px;
    margin-bottom: 24px;
    opacity: 0.6;
    background: #f0f0f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.mapa-info-panel .default-state h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.mapa-info-panel .default-state p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #666;
    max-width: 280px;
}

.mapa-info-panel .city-name {
    margin: 0 0 24px 0;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
    padding-bottom: 16px;
    border-bottom: 3px solid #070865;
}

/* Lista de cidades */
.mapa-info-panel .cities-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mapa-info-panel .city-item {
    padding: 20px 0;
    border-bottom: 1px solid #f0f0f0;
}

.mapa-info-panel .city-item:last-child {
    border-bottom: none;
}


.mapa-info-panel .city-item-title {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}

.mapa-info-panel .city-item-link {
    color: #070865;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-block;
}

.mapa-info-panel .city-item-link:hover {
    color: #05054a;
    text-decoration: underline;
    transform: translateX(2px);
}

.mapa-info-panel .city-item p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.mapa-info-panel .city-instagram {
    margin-bottom: 12px;
}

.mapa-info-panel .instagram-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #e1306c;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mapa-info-panel .instagram-link:hover {
    color: #c13584;
}

.mapa-info-panel .city-description {
    margin-bottom: 16px;
    color: #5a6c7d;
    line-height: 1.5;
}

.mapa-info-panel .city-link {
    margin-bottom: 0;
}

.mapa-info-panel .external-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mapa-info-panel .external-link:hover {
    color: #2980b9;
}

/* Botão de fechar */
.close-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #95a5a6;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-panel:hover {
    background: #ecf0f1;
    color: #7f8c8d;
}

/* Estados de loading e erro */
.mapa-info-panel .loading,
.mapa-info-panel .error {
    padding: 24px;
    text-align: center;
    color: #7f8c8d;
}

.mapa-info-panel .error {
    color: #e74c3c;
}

/* Responsividade */
@media (max-width: 768px) {
    .mapa-fetracse-container {
        flex-direction: column;
        min-height: auto;
        height: auto !important; /* Força altura automática em mobile */
        display: flex;
        flex-direction: column;
    }
    
    .mapa-wrapper {
        padding: 15px;
        min-height: 60vh; /* Aumenta para 60% da altura da tela */
        max-height: 70vh; /* Reduz para 70% da tela */
        border-right: none;
        border-bottom: 1px solid #e8ecf0;
        flex: 1;
        overflow: hidden;
        position: relative;
    }
    
    .mapa-info-panel {
        width: 100%;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        height: auto !important; /* Força altura automática */
        max-height: none !important; /* Remove limite máximo */
        overflow-y: visible !important; /* Remove scroll interno */
        flex-shrink: 0; /* Não encolhe o painel */
        display: flex !important; /* Força display flex */
        flex-direction: column !important; /* Força direção da coluna */
    }
    
    .mapa-svg-container {
        padding: 0;
        height: 100%;
        position: relative;
    }
    
    .mapa-info-panel .panel-header {
        padding: 20px 24px;
        background: #fafbfc;
        border-bottom: 1px solid #e8ecf0;
    }
    
    .mapa-info-panel .info-content {
        padding: 20px 24px;
    }
    
    /* Ajustes para tooltip em mobile */
    .mapa-tooltip {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .tooltip-text {
        font-size: 13px;
    }
    
    .tooltip-text strong {
        font-size: 14px;
    }
    
    /* Ajustes para dropdown em mobile */
    .dropdown-menu {
        max-height: 200px;
        position: absolute !important; /* Força posição absoluta */
        top: 100% !important; /* Posiciona abaixo do botão */
        left: 0 !important;
        right: 0 !important;
        bottom: auto !important; /* Remove posição bottom */
        border-radius: 0 0 8px 8px !important; /* Mantém bordas normais */
        border: 2px solid #e8ecf0 !important;
        border-top: none !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important; /* Sombra normal */
        z-index: 1000 !important;
    }
    
    .dropdown-item {
        padding: 12px 16px; /* Área de toque maior */
        font-size: 14px;
        min-height: 44px; /* Altura mínima para touch */
        display: flex;
        align-items: center;
    }
    
    .dropdown-item .city-name-text {
        font-size: 14px;
    }
    
    .dropdown-item .city-color-indicator {
        width: 12px;
        height: 12px;
    }
    
    /* Melhorias para cidades em mobile */
    .mapa-svg .city-path,
    .mapa-svg path.cls-3,
    .mapa-svg g[id] {
        min-width: 48px !important; /* Área de toque otimizada */
        min-height: 48px !important;
        padding: 4px !important; /* Padding reduzido */
        margin: -4px !important; /* Compensa o padding */
        touch-action: manipulation; /* Previne zoom duplo toque */
    }
    
    /* Feedback visual melhorado para touch */
    .mapa-svg .city-path:active,
    .mapa-svg path.cls-3:active,
    .mapa-svg g[id]:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

@media (max-width: 480px) {
    .mapa-fetracse-container {
        margin: 0;
        border-radius: 0;
    }
    
    .mapa-wrapper {
        padding: 10px;
        min-height: 50vh; /* Mantém mínimo de 50% */
        max-height: 75vh; /* Máximo 75% em telas pequenas */
    }
    
    .mapa-info-panel {
        width: 100%;
        max-width: none;
        height: auto !important; /* Força altura automática */
        max-height: none !important; /* Remove limite máximo */
        border-radius: 0;
        display: flex !important; /* Força display flex */
        flex-direction: column !important; /* Força direção da coluna */
        overflow-y: visible !important; /* Remove scroll interno */
    }
    
    .mapa-info-panel .info-content {
        padding: 15px;
    }
    
    .mapa-info-panel .city-name {
        font-size: 18px;
    }
    
    .mapa-info-panel .panel-header {
        padding: 15px;
    }
    
    /* Tooltip mais compacto */
    .mapa-tooltip {
        top: 5px;
        right: 5px;
        left: 5px;
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .tooltip-text {
        font-size: 12px;
    }
    
    .tooltip-text strong {
        font-size: 13px;
    }
    
    /* Dropdown mais compacto */
    .dropdown-item {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .dropdown-item .city-color-indicator {
        width: 10px;
        height: 10px;
    }
    
    /* Cidades com área de toque ainda maior */
    .mapa-svg .city-path,
    .mapa-svg path.cls-3,
    .mapa-svg g[id] {
        min-width: 60px !important;
        min-height: 60px !important;
        padding: 10px !important; /* Área de toque ainda maior */
        margin: -10px !important; /* Compensa o padding */
    }
}

/* Animações */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mapa-info-panel.show .info-content {
    animation: fadeInUp 0.3s ease;
}

/* Animação para conteúdo do painel */
#city-info-content.show {
    animation: fadeInUp 0.3s ease;
}

/* Garante que o painel seja sempre visível no mobile */
@media (max-width: 768px) {
    .mapa-info-panel {
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
    }
    
    #city-info-content {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* Melhorias de acessibilidade */
.mapa-svg:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.city-path:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}


/* Proteção contra interferência de temas WordPress */
.mapa-fetracse-container * {
    box-sizing: border-box;
}

.mapa-fetracse-container .dropdown-item,
.mapa-fetracse-container .dropdown-item * {
    font-family: inherit !important;
}

/* Força especificidade para evitar sobrescrita de temas */
.mapa-fetracse-container .cities-dropdown .dropdown-item .city-name-text {
    color: #1a1a1a !important;
}

.mapa-fetracse-container .cities-dropdown .dropdown-item:hover .city-name-text {
    color: #070865 !important;
}

.mapa-fetracse-container .cities-dropdown .dropdown-item.selected .city-name-text {
    color: #fff !important;
}

/* Estilos para dispositivos móveis */
.mobile-device .mapa-fetracse-container {
    /* Otimizações específicas para mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Estado quando dropdown está aberto em mobile */
body.dropdown-open {
    overflow: hidden;
}

body.dropdown-open .mapa-fetracse-container {
    position: relative;
    z-index: 1;
}

.mobile-device .mapa-svg {
    /* Melhora renderização em mobile */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Otimizações adicionais de performance */
    will-change: transform;
    -webkit-perspective: 1000;
    perspective: 1000;
}

.mobile-device .mapa-svg path,
.mobile-device .mapa-svg g {
    /* Aceleração de hardware para elementos SVG */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Modo retrato */
.portrait-mode .mapa-wrapper {
    min-height: 70vh;
    max-height: 70vh;
}

.portrait-mode .mapa-info-panel {
    height: 30vh;
    max-height: 30vh;
}

/* Modo paisagem */
@media (orientation: landscape) and (max-height: 500px) {
    .mapa-fetracse-container {
        flex-direction: row !important;
    }
    
    .mapa-wrapper {
        min-height: 100vh !important;
        max-height: 100vh !important;
        width: 70% !important;
    }
    
    .mapa-info-panel {
        height: 100vh !important;
        max-height: 100vh !important;
        width: 30% !important;
    }
}

/* Melhorias de acessibilidade para touch */
.mobile-device .city-path:focus,
.mobile-device path.cls-3:focus,
.mobile-device g[id]:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Previne zoom duplo toque em elementos interativos */
.mobile-device .city-path,
.mobile-device path.cls-3,
.mobile-device g[id] {
    touch-action: manipulation;
}

/* Otimizações de performance para mobile */
.mobile-device * {
    /* Reduz repaints desnecessários */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Otimizações balanceadas para mobile */
.mobile-device .mapa-svg path,
.mobile-device .mapa-svg g {
    /* Aceleração de hardware moderada */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

.mobile-device .mapa-fetracse-container {
    /* Otimiza composição de camadas */
    contain: layout style paint;
}

.mobile-device .mapa-svg-container {
    /* Isola o contexto de renderização */
    isolation: isolate;
}

/* Reduz animações em dispositivos lentos */
@media (prefers-reduced-motion: reduce) {
    .mobile-device * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .mapa-info-panel {
        display: none;
    }
    
    .mapa-svg-container {
        background: none;
        padding: 0;
    }
}
