/**
 * ===============================================
 * NAVIGATION.CSS - RotaTruck v8.1.0
 * ===============================================
 * Painel de navegação turn-by-turn COMPACTO
 * Visual consistente com cards flutuantes
 * 
 * Data: Dezembro 2025
 * ===============================================
 */

/* ==================== VARIÁVEIS ==================== */
:root {
    --nav-bg: #0f172a; /* v11.2.181: opaco (era alpha .95 + backdrop-filter) */
    --nav-text: #ffffff;
    --nav-text-muted: #94a3b8;
    --nav-accent: #FFB800;
    --nav-success: #22c55e;
    --nav-warning: #f59e0b;
    --nav-danger: #ef4444;
    --nav-border: rgba(255, 255, 255, 0.15);
    --nav-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --nav-panel-height: 90px;
    --nav-arrow-size: 40px;
}

/* Tema claro - MANTÉM fundo escuro para melhor contraste */
.theme-light {
    --nav-bg: #1e3a5f; /* v11.2.181: opaco (era alpha .95 + backdrop-filter) */
    --nav-text: #ffffff;
    --nav-text-muted: #b8c5d6;
    --nav-border: rgba(255, 255, 255, 0.2);
    --nav-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* ==================== PAINEL DE NAVEGAÇÃO ==================== */
.navigation-panel {
    position: fixed !important;
    top: 10px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 20px) !important;
    max-width: 400px !important;
    background: var(--nav-bg);
    /* 🔧 v11.2.181 (logs 5244/8090 — "mapa quebrando na chegada"):
     * backdrop-filter REMOVIDO. O painel fica por cima do #map, que em navegação é
     * uma camada composta com transform 3D (perspective+rotateX+rotate+scale),
     * will-change:transform e overflow:visible. O blur obriga o Chrome a capturar e
     * borrar esse backdrop A CADA FRAME; sob pressão de raster o backdrop volta
     * parcial/velho e o painel exibe um pedaço de MAPA BORRADO no lugar do próprio
     * fundo — exatamente a mancha do print. Com --nav-bg opaco o blur não acrescenta
     * nada visualmente e custa um snapshot de tela cheia por frame.
     */
    border-radius: 14px;
    border: 1px solid var(--nav-border);
    box-shadow: var(--nav-shadow);
    z-index: calc(var(--z-nav-ui) + 3);
    display: none;
    padding: 10px 14px;
    transition: opacity 0.3s ease;
}

.navigation-panel.active,
.navigation-active .navigation-panel {
    display: block;
}

/* ==================== HEADER DO PAINEL ==================== */
.nav-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Ícone da Manobra */
.nav-arrow {
    width: var(--nav-arrow-size);
    height: var(--nav-arrow-size);
    min-width: var(--nav-arrow-size);
    background: linear-gradient(135deg, #FF6B35, #ff8f5a);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 107, 53, 0.3);
}

.nav-arrow .arrow-icon {
    font-size: 20px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

/* Conteúdo da Instrução */
.nav-instruction {
    flex: 1;
    min-width: 0;
}

.nav-instruction-distance {
    font-size: 20px;
    font-weight: 700;
    color: var(--nav-accent);
    line-height: 1.1;
    margin-bottom: 1px;
}

.nav-instruction-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--nav-text);
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    text-overflow: clip !important;
}

.nav-street-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--nav-accent);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    margin-top: 3px;
}

/* Botão Fechar */
.nav-close-btn {
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.15);
    border: none;
    border-radius: 6px;
    color: #ef4444;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.nav-close-btn:hover {
    background: #ef4444;
    color: white;
}

/* ==================== BARRA DE PROGRESSO ==================== */
.nav-progress {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--nav-border);
}

.nav-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.theme-light .nav-progress-bar {
    background: rgba(0, 0, 0, 0.08);
}

.nav-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--nav-success), var(--nav-accent));
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ==================== FOOTER COM ETA ==================== */
.nav-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 6px;
}

.nav-eta-container,
.nav-distance-container {
    text-align: center;
}

.nav-eta-label,
.nav-distance-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--nav-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
}

.nav-eta,
.nav-distance {
    font-size: 13px;
    font-weight: 700;
    color: var(--nav-text);
}

.nav-eta {
    color: var(--nav-accent);
}

/* ==================== BÚSSOLA - LADO ESQUERDO (TOPO) ==================== */
.compass-widget,
#compass-widget,
div.compass-widget {
    position: fixed !important;
    bottom: 224px !important;
    left: 16px !important;
    right: auto !important;
    width: 56px;
    height: 56px;
    z-index: var(--z-nav-ui);
    display: none;
}

.compass-widget.visible,
#compass-widget.visible {
    display: block !important;
}

.navigation-active .compass-widget.visible {
    display: block !important;
}

/* Ajuste quando bottom nav visível */
body.has-bottom-nav .compass-widget,
body.has-bottom-nav #compass-widget {
    bottom: 288px !important;
}

/* ==================== SIMULADOR - LADO DIREITO (ACIMA DOS FABs) ==================== */
#fab-simulator,
.fab-simulator {
    position: fixed !important;
    bottom: 420px !important;
    right: 16px !important;
    left: auto !important;
}

body.has-bottom-nav #fab-simulator,
body.has-bottom-nav .fab-simulator {
    bottom: 420px !important;
}

/* ==================== WAYPOINTS (PARADAS) - LADO ESQUERDO ==================== */
#fab-waypoints,
.fab-waypoints {
    position: fixed !important;
    bottom: 160px !important;
    left: 16px !important;
    right: auto !important;
}

body.has-bottom-nav #fab-waypoints,
body.has-bottom-nav .fab-waypoints {
    bottom: 224px !important;
}

/* ==================== ZOOM DO LEAFLET - ESCONDIDO ==================== */
/* Usar gestos (pinch) para zoom - interface mais limpa */
.leaflet-control-zoom {
    display: none !important;
}

/* ==================== FABs REORGANIZADOS - LADO DIREITO ==================== */
/* Container principal dos FABs - posição fixa acima do SOS */
.fab-container,
.fab-navigation-container {
    position: fixed;
    right: 16px;
    bottom: 160px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: calc(var(--z-nav-ui) + 2);
}

/* Quando bottom nav está visível */
body.has-bottom-nav .fab-container,
body.has-bottom-nav .fab-navigation-container {
    bottom: 160px;
}

/* FAB Individual */
.fab-btn {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.fab-btn:hover {
    transform: scale(1.05);
}

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

/* Cores dos FABs */
.fab-btn.fab-map {
    background: linear-gradient(135deg, #FF6B35, #ff8f5a);
    color: white;
}

.fab-btn.fab-search {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: white;
}

.fab-btn.fab-compass {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
}

.fab-btn.fab-close {
    background: linear-gradient(135deg, #ef4444, #f87171);
    color: white;
}

.fab-btn.fab-simulator {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: white;
}

/* Tooltip do FAB */
.fab-btn[data-tooltip] {
    position: relative;
}

.fab-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    right: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
}

.fab-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ==================== SIMULADOR COMPACTO ==================== */
.simulator-panel {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 80px;
    background: var(--nav-bg);
    /* v11.2.181: backdrop-filter removido (idem .navigation-panel) */
    border-radius: 12px;
    border: 1px solid var(--nav-border);
    box-shadow: var(--nav-shadow);
    padding: 12px 16px;
    z-index: calc(var(--z-nav-ui) + 1);
    display: none;
}

.simulator-panel.active {
    display: block;
}

body.has-bottom-nav .simulator-panel {
    bottom: 144px;
}

.simulator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.simulator-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--nav-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.simulator-close {
    background: none;
    border: none;
    color: var(--nav-text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}

.simulator-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.simulator-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 107, 53, 0.15);
    color: var(--nav-accent);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.simulator-btn:hover {
    background: var(--nav-accent);
    color: white;
}

.simulator-btn.active {
    background: var(--nav-accent);
    color: white;
}

.simulator-speed {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.simulator-speed input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.simulator-speed input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--nav-accent);
    cursor: pointer;
}

.simulator-speed-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--nav-text);
    min-width: 50px;
    text-align: right;
}

/* ==================== ALERTAS ==================== */
.nav-alert {
    position: fixed;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: var(--nav-bg);
    border-radius: 10px;
    border: 1px solid var(--nav-warning);
    box-shadow: var(--nav-shadow);
    display: none;
    align-items: center;
    gap: 10px;
    z-index: calc(var(--z-nav-ui) + 4);
    animation: alertSlideIn 0.3s ease;
}

.nav-alert.visible {
    display: flex;
}

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

.nav-alert-icon {
    font-size: 18px;
}

.nav-alert-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--nav-text);
}

/* ==================== MODO NOTURNO ==================== */
.navigation-night .navigation-panel {
    --nav-bg: #0f0a0a; /* v11.2.181: opaco */
    --nav-text: #ffccaa;
    --nav-text-muted: #aa8866;
    --nav-accent: #ff8844;
    --nav-border: rgba(255, 136, 68, 0.15);
}

.navigation-night .nav-arrow {
    background: linear-gradient(135deg, #cc4400, #ff6600);
}

/* ==================== RESPONSIVO ==================== */
@media (max-width: 480px) {
    .navigation-panel {
        width: calc(100% - 20px);
        max-width: none;
        padding: 8px 10px;
    }

    /* nav-maneuver-icon e nav-icon: tamanhos via inline style (JS/HTML) */

    .nav-instruction-distance {
        font-size: 18px;
    }

    .nav-instruction-text {
        font-size: 13px;
    }
}

@media (max-width: 380px) {
    .navigation-panel {
        width: calc(100% - 16px);
        padding: 6px 8px;
    }

    /* nav-maneuver-icon e nav-icon: tamanhos via inline style (JS/HTML) */

    .nav-instruction-distance {
        font-size: 16px;
    }

    .nav-instruction-text {
        font-size: 12px;
    }

    .nav-info-label {
        font-size: 9px;
    }

    .nav-info-value {
        font-size: 12px;
    }
}

/* ==================== ANIMAÇÕES ==================== */
/* Animação desativada para não conflitar com transform: translateX(-50%) */
.navigation-panel.visible,
.navigation-panel.active {
    opacity: 1;
}

/* ==================== ACESSIBILIDADE ==================== */
@media (prefers-reduced-motion: reduce) {
    .navigation-panel,
    .nav-alert,
    .fab-btn {
        animation: none !important;
        transition: none !important;
    }
}

/* ==================== PRINT ==================== */
@media print {
    .navigation-panel,
    .nav-alert,
    .fab-container,
    .simulator-panel,
    .compass-widget {
        display: none !important;
    }
}