/**
 * Navigation UI Styles
 * Turn-by-turn navigation for ATLAS PWA
 */

/* ===== Navigation Search Box ===== */
.nav-search {
    display: none; /* Hidden on desktop, shown on mobile */
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 1100;
    background: #1a1a2e;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 1024px) {
    .nav-search {
        display: block;
    }
}

/* Hide search box when actively navigating */
body.navigation-active .nav-search {
    display: none !important;
}

.nav-search-input-wrapper {
    display: flex;
    align-items: center;
    background: #16213e;
    border-radius: 8px;
    padding: 4px 12px;
}

.nav-search input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    padding: 12px 8px;
    outline: none;
}

.nav-search input::placeholder {
    color: #6c757d;
}

.nav-clear-btn {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
}

.nav-clear-btn:hover {
    color: #fff;
}

/* Search Results */
.nav-results {
    max-height: 250px;
    overflow-y: auto;
    margin-top: 8px;
    border-radius: 8px;
}

.nav-result-item {
    padding: 12px;
    color: #fff;
    cursor: pointer;
    border-radius: 8px;
    border-bottom: 1px solid #16213e;
    transition: background 0.2s;
}

.nav-result-item:last-child {
    border-bottom: none;
}

.nav-result-item:hover {
    background: #16213e;
}

.nav-result-item:active {
    background: #0f3460;
}

.nav-result-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-result-address {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Navigation Instructions Banner ===== */
.nav-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 1200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.nav-maneuver {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.nav-icon {
    font-size: 32px;
    color: #4285F4;
    line-height: 1;
}

.nav-distance {
    font-size: 14px;
    color: #9ca3af;
    margin-top: 4px;
}

.nav-instruction {
    flex: 1;
    font-size: 18px;
    color: #fff;
    padding: 0 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-eta {
    font-size: 16px;
    color: #4CAF50;
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

.nav-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    margin-left: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Speed Advice Overlay ===== */
.speed-advice {
    position: fixed;
    bottom: 200px;
    right: 16px;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 12px;
    padding: 12px 16px;
    text-align: center;
    z-index: 1100;
    border: 2px solid #4CAF50;
    min-width: 80px;
    backdrop-filter: blur(10px);
}

.speed-value {
    font-size: 36px;
    font-weight: bold;
    color: #4CAF50;
    line-height: 1;
}

.speed-unit {
    font-size: 14px;
    color: #9ca3af;
    margin-top: 2px;
}

.speed-reason {
    font-size: 12px;
    color: #4CAF50;
    margin-top: 4px;
}

/* Speed Advice States */
.speed-advice.slow-down {
    border-color: #FFC107;
}

.speed-advice.slow-down .speed-value,
.speed-advice.slow-down .speed-reason {
    color: #FFC107;
}

.speed-advice.speed-up {
    border-color: #4285F4;
}

.speed-advice.speed-up .speed-value,
.speed-advice.speed-up .speed-reason {
    color: #4285F4;
}

.speed-advice.stop {
    border-color: #f44336;
}

.speed-advice.stop .speed-value,
.speed-advice.stop .speed-reason {
    color: #f44336;
}

.speed-advice.caution {
    border-color: #FFC107;
    animation: pulse-caution 1s infinite;
}

@keyframes pulse-caution {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Route Preview Panel ===== */
.route-preview {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 16px;
    z-index: 1100;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.route-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.route-preview-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.route-preview-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 24px;
    cursor: pointer;
}

.route-preview-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.route-stat {
    display: flex;
    flex-direction: column;
}

.route-stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.route-stat-label {
    font-size: 12px;
    color: #9ca3af;
}

.route-preview-actions {
    display: flex;
    gap: 12px;
}

.btn-start-nav {
    flex: 1;
    background: #4CAF50;
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-start-nav:hover {
    background: #45a049;
}

.btn-cancel-route {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-cancel-route:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Navigation FAB Button ===== */
.nav-fab {
    position: fixed;
    bottom: 380px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4285F4;
    color: #fff;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.nav-fab:hover {
    transform: scale(1.05);
    background: #3b78e7;
}

.nav-fab:active {
    transform: scale(0.95);
}

.nav-fab.active {
    background: #f44336;
}

/* ===== Destination Marker ===== */
.destination-marker {
    background: none;
    border: none;
}

.dest-pin {
    position: relative;
    width: 30px;
    height: 40px;
}

.dest-pin-head {
    width: 24px;
    height: 24px;
    background: #f44336;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    position: absolute;
    top: 0;
    left: 3px;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dest-pin-point {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid #f44336;
    position: absolute;
    bottom: 0;
    left: 9px;
}

/* ===== Voice Toggle Button ===== */
.voice-toggle {
    position: fixed;
    top: 90px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(26, 26, 46, 0.9);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1150;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.voice-toggle:hover {
    background: rgba(26, 26, 46, 1);
}

.voice-toggle.muted {
    color: #f44336;
}

.voice-toggle.muted::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 24px;
    background: #f44336;
    transform: rotate(45deg);
}

/* ===== Rerouting Overlay ===== */
.rerouting-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    padding: 24px 32px;
    border-radius: 12px;
    z-index: 1300;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.rerouting-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #16213e;
    border-top-color: #4285F4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.rerouting-text {
    color: #fff;
    font-size: 16px;
}

/* ===== Mobile Adjustments ===== */
@media (max-width: 1024px) {
    .nav-banner {
        height: 70px;
        padding: 0 12px;
    }

    .nav-icon {
        font-size: 28px;
    }

    .nav-instruction {
        font-size: 16px;
        padding: 0 12px;
    }

    .nav-maneuver {
        min-width: 60px;
    }

    .speed-advice {
        bottom: 160px;
        right: 12px;
    }

    .speed-value {
        font-size: 28px;
    }

    .nav-search {
        top: 58px;
        width: 95%;
    }
}

/* ===== When Navigation Active ===== */
body.navigation-active .header {
    display: none;
}

body.navigation-active .sidebar {
    display: none;
}

body.navigation-active .mobile-controls {
    bottom: 90px;
}

body.navigation-active .driving-hud {
    top: 90px;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
