/**
 * ================================================
 * MAP-FOLLOW.CSS v1.10.0
 * ================================================
 * Estilos para navegacao Waze-like:
 * - Botao grande "INICIAR NAVEGACAO"
 * - Seta direcional no mapa
 * - Botao voltar para rotas
 * - Rotacao heading-up
 * - Mensagem de chegada ao destino
 *
 * 🔧 v1.9.0 (v2.20.0): Tilt 35° Waze — perspective-origin 70%, counter-rotateX 35°
 * 🔧 v1.7.0 (BUG VISUAL 47): Indicadores de curva no mapa estilo Waze
 * 🔧 v1.6.0 (ERRO VISUAL 44): Perspective/tilt estilo Waze (classe .map-tilted)
 * 🔧 v1.5.0 (ERRO VISUAL 42): Background matching + container otimizado
 * 🔧 v1.4.0 (ERRO VISUAL 38): Mensagem visual de chegada + botão voltar
 * 🔧 v1.3.0 (ERRO VISUAL 32): Movimento suave do marcador tipo Waze
 * 🔧 v1.2.0 (ERRO VISUAL 31): GPU acceleration para tiles
 * 🔧 v1.1.0 (ERRO VISUAL 29): Removido botão re-centralizar azul
 * ================================================
 */

/* ==================== BOTAO GRANDE "INICIAR NAVEGACAO" ==================== */

.btn-iniciar-nav-grande {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: calc(var(--z-tela-cheia) + 1);

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 16px 40px;
    min-width: 280px;

    background: linear-gradient(135deg, #FF6B35 0%, #E05A2E 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;

    font-family: 'Segoe UI', -apple-system, sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;

    box-shadow: 0 6px 24px rgba(255, 107, 53, 0.5),
                0 2px 8px rgba(0, 0, 0, 0.2);

    animation: btnNavPulse 2s ease-in-out infinite;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-iniciar-nav-grande:active {
    transform: translateX(-50%) scale(0.96);
    box-shadow: 0 3px 12px rgba(255, 107, 53, 0.4);
}

.btn-nav-icon {
    font-size: 22px;
}

@keyframes btnNavPulse {
    0%, 100% {
        box-shadow: 0 6px 24px rgba(255, 107, 53, 0.5),
                    0 2px 8px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 32px rgba(255, 107, 53, 0.7),
                    0 4px 12px rgba(0, 0, 0, 0.25);
    }
}

/* ==================== BOTAO VOLTAR PARA ROTAS ==================== */

.btn-voltar-rotas {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: calc(var(--z-tela-cheia) + 1);

    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;

    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4),
                0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;

    animation: voltarFadeIn 0.3s ease;
}

.btn-voltar-rotas:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(46, 204, 113, 0.5);
}

.btn-voltar-rotas:active {
    transform: scale(0.95);
}

@keyframes voltarFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ==================== SETA DIRECIONAL NO MAPA ==================== */

.nav-arrow-marker {
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.nav-arrow-marker svg {
    display: block;
}

/* 🔧 v1.3.0: Marcador com GPU acceleration para movimento suave */
.leaflet-marker-icon.arrow-marker-icon {
    background: transparent !important;
    border: none !important;
    /* GPU acceleration para evitar "pulinhos" */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ==================== RESPONSIVO ==================== */

@media (max-width: 480px) {
    .btn-iniciar-nav-grande {
        min-width: 250px;
        padding: 14px 32px;
        font-size: 16px;
        bottom: 90px;
    }

    .btn-voltar-rotas {
        width: 40px;
        height: 40px;
    }

    .arrival-message {
        bottom: 90px;
    }

    .arrival-message-content {
        padding: 16px 24px;
    }

    .arrival-text {
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .btn-iniciar-nav-grande {
        min-width: 220px;
        padding: 12px 24px;
        font-size: 15px;
    }
}

/* ==================== DARK MODE ==================== */

[data-theme="dark"] .btn-iniciar-nav-grande,
.tema-escuro .btn-iniciar-nav-grande {
    box-shadow: 0 6px 24px rgba(255, 107, 53, 0.3),
                0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .btn-voltar-rotas,
.tema-escuro .btn-voltar-rotas {
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3),
                0 2px 4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .arrival-message-content,
.tema-escuro .arrival-message-content {
    background: rgba(0, 0, 0, 0.92);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* 🔧 v1.5.0 (ERRO VISUAL 42): Background escuro para gaps durante rotação */
[data-theme="dark"] #map.map-rotating,
.tema-escuro #map.map-rotating {
    background: #2b2b2b; /* CartoDB Dark approximation */
}

/* ==================== ROTACAO HEADING-UP (WAZE) ==================== */

/* 🔧 v1.8.0: Background do container Leaflet — minimiza bordas/gaps ao arrastar */
.leaflet-container {
    background: #e8e8e8; /* 🔧 v1.8.0: Cinza neutro (combina com Voyager + grayscale) */
}

[data-theme="dark"] .leaflet-container,
.tema-escuro .leaflet-container {
    background: #2b2b2b; /* CartoDB Dark approximation */
}

/* 🔧 v1.5.0: Background matching para gaps residuais serem invisíveis */
#map.map-rotating {
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    transform-origin: center center;
    overflow: visible; /* IMPORTANTE: visible para ver tiles extras */
    will-change: transform; /* GPU acceleration */
    backface-visibility: hidden; /* Otimizacao 3D */
    -webkit-backface-visibility: hidden;
    background: #e8e8e8; /* 🔧 v1.8.0: Cinza neutro (combina com filtro grayscale da navegação) */
}

/* Container de tiles precisa ser maior para cobrir rotacao */
#map.map-rotating .leaflet-tile-pane {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Filtro cinza/dark gerenciado via JS (mapFollowController + themeManager) */
}

#map.map-rotating .leaflet-control-container {
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    transform-origin: center center;
    will-change: transform;
}

/* ==================== MENSAGEM DE CHEGADA (ERRO VISUAL 38) ==================== */

.arrival-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: calc(var(--z-tela-cheia) + 1);
    animation: arrivalFadeIn 0.4s ease;
}

.arrival-message-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 32px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.arrival-icon {
    font-size: 36px;
}

.arrival-text {
    color: white;
    font-family: 'Segoe UI', -apple-system, sans-serif;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
}

.arrival-btn-voltar {
    padding: 12px 28px;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.arrival-btn-voltar:active {
    transform: scale(0.95);
}

@keyframes arrivalFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==================== TILT/PERSPECTIVE ESTILO WAZE (ERRO VISUAL 44) ==================== */

/* 🔧 v1.9.0 (v2.20.0): Perspective/tilt — ponto de fuga abaixo do centro para efeito Waze */
#map.map-tilted {
    perspective-origin: center 70%; /* 🔧 v1.9.0: 60→70% (seta mais embaixo, horizonte mais longe) */
}

/* Popups e tooltips não devem ficar inclinados — counter-rotate */
/* 🔧 v11.1.134: Usa var(--tilt-angle) para acompanhar ângulo configurável */
#map.map-tilted .leaflet-popup,
#map.map-tilted .leaflet-tooltip {
    transform: rotateX(calc(-1 * var(--tilt-angle, 35deg)));
}

/* Dark mode para .map-tilted */
[data-theme="dark"] #map.map-tilted,
.tema-escuro #map.map-tilted {
    background: #2b2b2b;
}

/* ==================== CHEVRONS DE DIREÇÃO NA ROTA (BUG VISUAL 47) ==================== */

/* 🔧 v1.10.0 (BUG 81): GPU acceleration — chevrons visíveis no modo tiltado 3D */
.turn-chevron-icon {
    background: transparent !important;
    border: none !important;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.turn-chevron {
    line-height: 0;
}

.turn-chevron svg {
    display: block;
}

/* ==================== ACESSIBILIDADE ==================== */

@media (prefers-reduced-motion: reduce) {
    .btn-iniciar-nav-grande,
    .btn-voltar-rotas,
    .nav-arrow-marker,
    .arrival-message {
        animation: none !important;
        transition: none !important;
    }

    #map.map-rotating,
    #map.map-rotating .leaflet-control-container {
        transition: none !important;
    }

    /* 🔧 v1.6.0 (ERRO VISUAL 44): Sem perspective em modo reduzido */
    #map.map-tilted {
        perspective: none !important;
    }
}
