/* CraneNav NextBillion Login Test Styles */

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html, body { 
    height: 100%; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 
}
/* iOS/WKWebView: ensure full screen height incl. notch, with fallbacks */
html {
    height: 100% !important;
    height: 100svh !important;
    min-height: -webkit-fill-available !important;
}
body { 
    height: 100svh; 
    min-height: -webkit-fill-available; 
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100svh;
    min-height: -webkit-fill-available;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.3s ease-out;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.splash-content {
    text-align: center;
}

.splash-title {
    font-size: 2rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.splash-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login View */
.login-view { 
    display: none; /* Changed from flex - will be shown by showLogin() if needed */
    align-items: center; 
    justify-content: center; 
    min-height: 100vh; 
    background: #f5f5f5; 
}

.login-form { 
    max-width: 400px; 
    width: 100%; 
    padding: 2rem; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    /* OPTIMIZATION: CSS containment for isolated login form */
    contain: layout paint;
}

.login-title { 
    font-size: 1.5rem; 
    font-weight: 600; 
    text-align: center; 
    margin-bottom: 1.5rem; 
}

.form-group { 
    margin-bottom: 1rem; 
}

.form-input { 
    width: 100%; 
    padding: 0.75rem; 
    border: 1px solid #d1d5db; 
    border-radius: 4px; 
    font-size: 1rem; 
}

.form-input:focus { 
    outline: none; 
    border-color: #3b82f6; 
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); 
}

.login-btn { 
    width: 100%; 
    padding: 0.75rem; 
    background: #3b82f6; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    font-size: 1rem; 
    cursor: pointer; 
}

.login-btn:hover { 
    background: #2563eb; 
}

.login-btn:disabled { 
    background: #9ca3af; 
    cursor: not-allowed; 
}

.error-message { 
    color: #dc2626; 
    font-size: 0.875rem; 
    margin-top: 0.5rem; 
    display: none; 
}

.success-message { 
    color: #16a34a; 
    font-size: 0.875rem; 
    margin-top: 0.5rem; 
    display: none; 
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.terms-link {
    color: #3b82f6;
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.terms-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

.terms-checkbox-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-top: 0.5rem;
}

.terms-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.5;
}

.terms-checkbox {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.terms-checkbox-text {
    flex: 1;
}

.terms-link-inline {
    color: #3b82f6;
    text-decoration: none;
}

.terms-link-inline:hover {
    text-decoration: underline;
}

.terms-link-container {
    margin-top: 0.5rem;
}

.forgot-password-link {
    color: #0b5bd3;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
}

.forgot-password-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* App View - Fixed container like Main branch .map-container */
.app-view { 
    display: none; 
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100svh !important; /* dynamic viewport height for iPhone */
    min-height: -webkit-fill-available !important; /* iOS fallback */
}

#mapContainer {
    /* Hardware acceleration for smooth map rendering and rotation */
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform; 
    position: fixed !important; /* Match parent positioning to fill viewport - LOCKED */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important; 
    height: 100vh !important; 
    height: 100svh !important; /* dynamic viewport height for iPhone - LOCKED */
    min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
    z-index: 0 !important;
    /* PERFORMANCE OPTIMIZATION: CSS containment for better rendering performance */
    contain: layout style paint;
}
/* Force map layers to sit below our UI in iOS WKWebView */
#mapContainer * { 
    z-index: 0 !important; 
}
/* UI overlay above map for WKWebView */
#uiOverlay { 
    position: fixed; 
    inset: 0; 
    z-index: 10000; 
    pointer-events: none;
    /* PERFORMANCE OPTIMIZATION: CSS containment for better rendering performance */
    contain: layout style paint;
}
#uiOverlay > * { 
    pointer-events: auto;
    /* PERFORMANCE OPTIMIZATION: CSS containment for UI elements */
    contain: layout style;
}
/* Navigation bars with proper z-index for iPhone */
#navBottomBar, .overlay-controls { 
    z-index: 10000 !important;
    /* PERFORMANCE OPTIMIZATION: CSS containment for better rendering performance */
    contain: layout style paint;
}

/* Mobile-specific fixes - Like Main branch */
@media (max-width: 768px) {
    body { 
        overflow: hidden !important; /* Prevent scrolling - LOCKED */
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        height: 100svh !important; /* iPhone viewport height - LOCKED */
        min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
    }
    .app-view {
        touch-action: manipulation !important; /* Prevent zoom/pan gestures */
        height: 100svh !important; /* iPhone viewport height - LOCKED */
        min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
    }
    #mapContainer {
        touch-action: manipulation !important; /* Prevent zoom/pan gestures */
        height: 100svh !important; /* iPhone viewport height - LOCKED */
        min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
    }
    /* Ensure inputs don't zoom on focus */
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Fallback for browsers without svh support (older iOS) */
:root { 
    --safe-vh: 1vh; 
}
@supports not (height: 100svh) {
    .app-view { 
        height: calc(var(--safe-vh) * 100) !important; 
        min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
    }
    #mapContainer { 
        height: calc(var(--safe-vh) * 100) !important; 
        min-height: -webkit-fill-available !important; /* iOS fallback - LOCKED */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        /* Don't subtract safe area insets - let padding/positioning handle safe areas */
    }
}

/* iPhone-specific viewport fix - ensure full screen coverage - LOCKED */
@supports (-webkit-touch-callout: none) {
    /* This targets iOS Safari specifically */
    html {
        height: 100svh !important;
        min-height: -webkit-fill-available !important;
        width: 100% !important;
    }
    body {
        height: 100svh !important;
        min-height: -webkit-fill-available !important;
        /* Removed position: fixed - was preventing app from extending to bottom */
        width: 100% !important;
        overflow: hidden !important;
    }
    .app-view {
        height: 100svh !important;
        min-height: -webkit-fill-available !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
    #mapContainer {
        height: 100svh !important;
        min-height: -webkit-fill-available !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
    }
}


/* Overlay controls (top-left) - Compact for mobile */
.overlay-controls {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    max-width: calc(100vw - 36px - env(safe-area-inset-left) - env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 7px;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-sizing: border-box;
    /* OPTIMIZATION: CSS containment for isolated UI component */
    contain: layout paint;
}

.overlay-input { 
    width: 85%;
    padding: 12.5px 10px;
    border: 0;
    border-radius: 16px;
    font-size: 13px;
    background: rgba(17,24,39,0.92);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.overlay-select {
    width: 85%;
    padding: 12.5px 10px;
    border: 0;
    border-radius: 16px;
    font-size: 13px;
    background: rgba(17,24,39,0.92);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.overlay-field {
    position: relative;
}

.overlay-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    /* Lock flex container to prevent button movement */
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.overlay-button {
    background: #0071E3; /* updated blue color */
    color: #fff;
    padding: 14.4px 32px; /* reduced vertical padding by 10% from 16px */
    border: none;
    border-radius: 50px; /* pill shape - very rounded corners */
    font-size: 18px; /* clean, readable font size */
    font-weight: 500; /* medium weight like reference */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; /* clean sans-serif */
    cursor: pointer;
    width: fit-content;
    min-width: 120px; /* ensure consistent width */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    /* Initial hidden state for animation */
    opacity: 0;
    transform: translateX(-40px);
    /* Smooth hardware-accelerated transitions */
    transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
    /* Ensure buttons are accessible even when hidden */
    pointer-events: none;
    /* Lock position - prevent any movement */
    position: relative;
    flex-shrink: 0;
}

.overlay-button.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.overlay-button.start {
    background: #10b981; /* green */
    /* Lock Start button position - always next to Reset button */
    order: 2;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
}

/* Planning Menu (3-dot menu) - Top Right */
.planning-menu-container {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 12px);
    z-index: 10001 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.planning-menu-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
    padding: 0;
}

.planning-menu-btn:hover {
    opacity: 0.8;
}

.planning-menu-btn:active {
    opacity: 0.6;
}

.planning-menu-dots {
    color: #000;
    font-size: 30px;
    line-height: 1;
    font-weight: 900;
    display: inline-block;
}

.planning-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 8px 0;
    overflow: hidden;
    z-index: 2147483647 !important;
}

.planning-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    user-select: none;
}

.planning-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.planning-menu-item:active {
    background: rgba(255, 255, 255, 0.15);
}

.planning-menu-item-text {
    color: #fff;
    font-size: 14px;
    font-weight: 400;
    flex: 1;
}

.planning-menu-item-check {
    color: #10b981;
    font-size: 18px;
    font-weight: bold;
    margin-left: 12px;
    flex-shrink: 0;
    display: none;
}

.planning-menu-item.active .planning-menu-item-check {
    display: inline-block;
}

/* Ensure Start button transform is reset when visible */
.overlay-button.start.visible {
    transform: translateX(0) !important;
}

/* Lock Reset button position */
#resetRouteBtn {
    order: 1;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
}

/* Hide snap button - snapping is now automatic */
#snapRouteBtn {
    display: none !important;
    order: 3;
    /* Remove from layout flow completely */
    position: absolute;
    visibility: hidden;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

/* Hide overlay controls during navigation for cleaner UI */
.overlay-controls.nav-active {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

/* Auto-suggest dropdown styling - matching original app.js */
.suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 240px;
    width: max(100%, 240px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.12);
    max-height: 50vh;
    overflow-y: auto;
    display: none;
    z-index: 1100;
    /* OPTIMIZATION: CSS containment for isolated dropdown component */
    contain: layout paint;
}

.suggestions.visible { 
    display: block; 
}

.suggestions .item { 
    padding: 8px 10px; 
    font-size: 14px; 
    cursor: pointer; 
}

.suggestions .item:hover { 
    background: #f3f4f6; 
}

/* Completely disable browser autocomplete styling */
input::-webkit-autofill,
input::-webkit-autofill:hover,
input::-webkit-autofill:focus,
input::-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(17,24,39,0.92) inset !important;
    -webkit-text-fill-color: #fff !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Hide browser autocomplete dropdown */
input::-webkit-calendar-picker-indicator {
    display: none !important;
}

/* Additional browser autocomplete prevention */
.overlay-input {
    -webkit-autocomplete: off;
    -moz-autocomplete: off;
    autocomplete: off;
}

/* Hide NextBillion attribution and controls */
.nextbillion-attribution,
.nextbillion-logo,
.mapboxgl-ctrl-attrib,
.mapboxgl-ctrl-logo,
[class*="nextbillion"],
[class*="mapboxgl-ctrl"] {
    display: none !important;
    visibility: hidden !important;
}

/* Hide browser suggestion chips */
input::-webkit-list-button,
input::-webkit-calendar-picker-indicator,
input::-webkit-clear-button,
input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Hide any browser-generated suggestion elements */
input[list]::-webkit-calendar-picker-indicator,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Additional prevention for modern browsers */
.overlay-input::-webkit-autofill,
.overlay-input::-webkit-autofill:hover,
.overlay-input::-webkit-autofill:focus,
.overlay-input::-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px rgba(17,24,39,0.92) inset !important;
    -webkit-text-fill-color: #fff !important;
    transition: background-color 5000s ease-in-out 0s;
    background-color: transparent !important;
    background-image: none !important;
}

/* Hide any suggestion chips that might appear */
.overlay-field::after,
.overlay-field::before {
    display: none !important;
    content: none !important;
}

/* Ensure no browser-generated elements appear */
.overlay-input:focus::-webkit-credentials-auto-fill-button,
.overlay-input:hover::-webkit-credentials-auto-fill-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}


/* GPS puck marker on map with directional arrow */
.gps-puck-marker {
    width: 40px;
    height: 40px;
    position: relative;
    z-index: 1000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Prevent interference with map interactions */
    /* Hardware acceleration for smooth rendering */
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

.gps-puck-circle {
    width: 24px;
    height: 24px;
    background-color: #FF6600;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255,102,0,0.9), 0 3px 10px rgba(0,0,0,0.4);
    position: absolute;
    animation: pulse-puck 2s infinite;
    /* Hardware acceleration for smooth animation */
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    will-change: box-shadow;
}

.gps-puck-arrow {
    position: absolute;
    top: -8px;
    color: #FF6600;
    font-size: 20px;
    text-shadow: 0 0 4px white, 0 0 6px white, 0 2px 4px rgba(0,0,0,0.4);
    font-weight: bold;
    z-index: 1001;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transform-origin: center center;
    /* Hardware acceleration - arrow always points straight up in heading up mode */
    -webkit-transform: translate3d(0, -50%, 0);
    transform: translate3d(0, -50%, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

@keyframes pulse-puck {
    0% {
        box-shadow: 0 0 15px rgba(255,102,0,0.7), 0 0 30px rgba(255,102,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(255,102,0,1.0), 0 0 50px rgba(255,102,0,0.6), 0 2px 8px rgba(0,0,0,0.3);
    }
    100% {
        box-shadow: 0 0 15px rgba(255,102,0,0.7), 0 0 30px rgba(255,102,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
    }
}

/* Navigation session warning animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== HIGH-PERFORMANCE NAVIGATION STYLES ===== */

/* Animated instruction display */
.instruction-display {
    position: fixed;
    top: 20px;
    left: -100%;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    max-width: 280px;
    z-index: 1000;
    transition: left 0.3s ease-in-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.instruction-display.show {
    left: 20px;
}

.instruction-display.hide {
    left: -100%;
}

.instruction-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.instruction-text {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: #ffffff;
}

.instruction-distance {
    font-size: 14px;
    font-weight: 500;
    color: #a3a3a3;
    opacity: 0.9;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
    .instruction-display {
        top: 15px;
        left: -100%;
        right: auto;
        max-width: none;
        padding: 14px 18px;
    }
    
    .instruction-display.show {
        left: 15px;
    }
    
    .instruction-text {
        font-size: 15px;
    }
    
    .instruction-distance {
        font-size: 13px;
    }
}

/* Professional navigation styling */
.navigation-map {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f8fafc;
}

/* Clean map interface during navigation */
.nav-active .map-container {
    background: #000;
}

.nav-active .maplibregl-map {
    filter: brightness(1.1) contrast(1.05);
}

/* Smooth transitions for all navigation elements */
.instruction-display,
.gps-puck-marker {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* REMOVED: Navigation UI Styles - turn-by-turn navigation removed */

/* Bridge Modal Styles */
.bridge-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* OPTIMIZATION: CSS containment for isolated modal component */
    contain: layout paint;
}

.bridge-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.bridge-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.bridge-modal-title {
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.bridge-modal-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.bridge-modal-close:hover {
    color: #374151;
    background: #f3f4f6;
}

.bridge-modal-body {
    padding: 24px;
}

.bridge-info, .crane-info {
    margin-bottom: 20px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.bridge-name, .crane-name {
    color: #111827;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.bridge-details, .crane-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

.detail-value {
    color: #111827;
    font-size: 14px;
    font-weight: 600;
}

.compliance-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #ecfdf5;
    border: 1px solid #10b981;
    border-radius: 8px;
    margin-bottom: 20px;
}

.status-icon {
    font-size: 20px;
}

.status-text {
    color: #065f46;
    font-size: 14px;
    font-weight: 600;
}

.bridge-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.btn-primary {
    background: #3b82f6;
    color: #ffffff;
}

.btn-primary:hover {
    background: #2563eb;
}

/* Password Change Modal */
.password-change-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.password-change-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.password-change-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.password-change-modal-title {
    color: #111827;
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.password-change-modal-body {
    padding: 24px;
}

.password-change-modal-message {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.password-change-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-label {
    display: block;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-help-text {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-top: 4px;
}

.password-change-modal-footer {
    margin-top: 8px;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    /* REMOVED: Navigation UI mobile styles - turn-by-turn navigation removed */
    
    /* Ensure proper spacing for text fields on mobile (especially Android) */
    .overlay-input,
    .overlay-select {
        width: 84%; /* Additional 1% reduction on mobile for better right-side spacing */
    }
    
    .bridge-modal {
        padding: 10px;
    }
    
    .bridge-modal-content {
        border-radius: 12px;
    }
    
    .bridge-modal-header {
        padding: 16px 20px;
    }
    
    .bridge-modal-body {
        padding: 20px;
    }
    
    .bridge-modal-footer {
        padding: 16px 20px;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* High-Risk Bridges Modal Styles */
.high-risk-intro {
    color: #374151;
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.high-risk-bridges-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.high-risk-bridge-item {
    padding: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
}

.high-risk-bridge-item .bridge-item-name {
    color: #111827;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.high-risk-bridge-item .bridge-item-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.high-risk-bridge-item .bridge-item-detail {
    color: #6b7280;
    font-size: 14px;
}

.high-risk-bridge-item .bridge-item-detail strong {
    color: #374151;
    font-weight: 600;
}

/* Dark mode support for high-risk bridges modal */
@media (prefers-color-scheme: dark) {
    .high-risk-bridge-item {
        background: #1f1f1f;
        border-color: #7f1d1d;
        border-left-color: #dc2626;
    }
    
    .high-risk-bridge-item .bridge-item-name {
        color: #f9fafb;
    }
    
    .high-risk-bridge-item .bridge-item-detail {
        color: #9ca3af;
    }
    
    .high-risk-bridge-item .bridge-item-detail strong {
        color: #e5e7eb;
    }
}

@media (max-width: 768px) {
    .high-risk-bridges-list {
        max-height: 300px;
    }
}

/* High-Risk Bridges Modal - Positioned below Reset/Start buttons in planning layout */
#highRiskBridgesModal {
    /* Override full-screen overlay positioning for planning layout */
    position: fixed !important;
    top: auto !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90vw !important;
    max-width: calc(100vw - 36px - env(safe-area-inset-left) - env(safe-area-inset-right)) !important;
    height: auto !important;
    min-height: auto !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    padding: 0 !important;
    /* Position below overlay-controls: top of overlay-controls + estimated height + gap */
    /* overlay-controls starts at calc(env(safe-area-inset-top) + 8px) */
    /* Estimated height: crane select (~50px) + origin (~50px) + destination (~50px) + buttons (~60px) + gaps (~21px) = ~231px */
    /* Add 16px gap below buttons */
    top: calc(env(safe-area-inset-top) + 8px + 231px + 16px) !important;
    z-index: 1001 !important; /* Just above overlay-controls (1000) */
    /* Only show in planning layout (when overlay-controls is visible) */
    display: none !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
}

/* When modal is shown, use flex display */
#highRiskBridgesModal[style*="display: flex"],
#highRiskBridgesModal[style*="display:flex"] {
    display: flex !important;
}

/* Position modal content */
#highRiskBridgesModal .bridge-modal-content {
    margin-top: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 280px) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Hide modal during navigation (when overlay-controls has nav-active class) */
/* Note: This requires JavaScript to add/remove nav-active class, but CSS provides fallback */
.overlay-controls.nav-active ~ #highRiskBridgesModal {
    display: none !important;
}

/* Snap-to-Roads Diagnostic Modal Styles */
.snap-diagnostic-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.snap-diagnostic-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.snap-diagnostic-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.snap-diagnostic-modal-title {
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.snap-diagnostic-modal-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.snap-diagnostic-modal-close:hover {
    color: #374151;
    background: #f3f4f6;
}

.snap-diagnostic-modal-body {
    padding: 24px;
}

.snap-diagnostic-icon {
    text-align: center;
    margin-bottom: 16px;
}

.snap-diagnostic-message {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 16px;
    color: #111827;
}

.snap-diagnostic-details {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-top: 16px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.snap-diagnostic-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

/* Mobile responsive styles for diagnostic modal */
@media (max-width: 640px) {
    .snap-diagnostic-modal {
        padding: 10px;
    }
    
    .snap-diagnostic-modal-content {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .snap-diagnostic-modal-header {
        padding: 16px 20px;
    }
    
    .snap-diagnostic-modal-body {
        padding: 20px;
    }
    
    .snap-diagnostic-modal-footer {
        padding: 16px 20px;
    }
    
    .snap-diagnostic-details {
        max-height: 200px;
        font-size: 12px;
    }
}

/* Terms of Service Modal Styles */
.terms-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* OPTIMIZATION: CSS containment for isolated modal component */
    contain: layout paint;
}

/* Hide overlay controls when terms modal is open */
.overlay-controls.terms-modal-open {
    opacity: 0;
    pointer-events: none;
}

.terms-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.terms-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.terms-modal-title {
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.terms-modal-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.terms-modal-close:hover {
    color: #374151;
    background: #f3f4f6;
}

.terms-modal-body {
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.terms-modal-body iframe {
    flex: 1;
    min-height: 500px;
}

/* Mobile responsive styles for terms modal */
@media (max-width: 768px) {
    .terms-modal {
        padding: 10px;
    }
    
    .terms-modal-content {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .terms-modal-header {
        padding: 16px 20px;
    }
    
    .terms-modal-body iframe {
        min-height: 400px;
    }
}

/* Instructions Modal Styles */
.instructions-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* OPTIMIZATION: CSS containment for isolated modal component */
    contain: layout paint;
}

/* Hide overlay controls when instructions modal is open */
.overlay-controls.instructions-modal-open {
    opacity: 0;
    pointer-events: none;
}

.instructions-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.instructions-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.instructions-modal-title {
    color: #111827;
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.instructions-modal-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.instructions-modal-close:hover {
    color: #374151;
    background: #f3f4f6;
}

.instructions-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.instructions-image-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.instructions-image-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.instructions-image-title {
    color: #111827;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.instructions-image {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
}

/* Mobile responsive styles for instructions modal */
@media (max-width: 640px) {
    .instructions-modal {
        padding: 10px;
    }
    
    .instructions-modal-content {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px;
    }
    
    .instructions-modal-header {
        padding: 16px 20px;
    }
    
    .instructions-modal-title {
        font-size: 16px;
    }
    
    .instructions-modal-body {
        padding: 20px;
    }
    
    .instructions-image-container {
        gap: 24px;
    }
    
    .instructions-image-section {
        gap: 12px;
    }
    
    .instructions-image-title {
        font-size: 14px;
    }
}

/* Professional color scheme */
:root {
    --nav-primary: #1e40af;
    --nav-secondary: #3b82f6;
    --nav-accent: #60a5fa;
    --nav-text: #ffffff;
    --nav-text-secondary: #a3a3a3;
    --nav-background: rgba(0, 0, 0, 0.9);
    --nav-border: rgba(255, 255, 255, 0.1);
}

/* GPS puck styling */
.gps-puck {
    width: 20px;
    height: 20px;
    background-color: #FF6600;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Speed HUD Styles */
#speed-hud {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
    /* OPTIMIZATION: CSS containment for isolated HUD component */
    contain: layout paint;
}

#speed-hud:not(.speed-hud-hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    #current-speed-container {
        font-size: 2.2rem !important;
        padding: 6px 12px !important;
    }
    
    #current-speed-container span:last-child {
        font-size: 1rem !important;
        margin-left: 4px !important;
    }
    
    #speed-limit-sign {
        width: 52px !important;
        height: 52px !important;
        border-width: 4px !important;
        font-size: 1.4rem !important;
    }
}

/* Turn Direction Indicator Styles - Similar to Speed HUD */
#turnDirectionIndicator {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
    /* OPTIMIZATION: CSS containment for isolated HUD component */
    contain: layout paint;
}

#turnDirectionIndicator:not(.turn-direction-indicator-hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* Match turn direction container height to speed HUD container */
/* Speed HUD container height: 2.8rem font (44.8px) + line-height padding + 16px padding ≈ 72px */
#turn-direction-container {
    min-height: 72px;
    align-items: center;
    display: flex;
}

/* Arrow image - transparent background */
#turnDirectionArrowLeft,
#turnDirectionArrowRight {
    background: transparent;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    #turn-direction-container {
        padding: 6px 12px !important;
        gap: 10px !important;
        min-height: 60px !important; /* Match speed HUD mobile height (2.2rem font + padding) */
    }
    
    #turnDirectionArrowLeft,
    #turnDirectionArrowRight {
        width: 42px !important;
        height: 42px !important;
        background: transparent !important;
    }
    
    #turnDirectionDistance {
        font-size: 1.8rem !important;
    }
}

/* Camera Pitch Slider Styles */
#pitchSlider {
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Allow all touch interactions for slider */
    -webkit-touch-callout: none; /* Prevent iOS callout menu */
    display: none !important; /* Hidden by default - only shown during navigation */
}

#pitchSliderHandle {
    -webkit-tap-highlight-color: transparent;
    touch-action: none; /* Allow dragging on handle */
    -webkit-touch-callout: none; /* Prevent iOS callout menu */
}

#pitchSliderHandle:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.1);
}

#pitchSliderTrack {
    touch-action: none; /* Allow clicking/dragging on track */
    -webkit-touch-callout: none; /* Prevent iOS callout menu */
}

/* Audio Mute Button Styles */
#audioMuteButton {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-touch-callout: none; /* Prevent iOS callout menu */
    display: none !important; /* Hidden by default - only shown during navigation */
}

#audioMuteButton:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

#audioMuteButton:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.9);
}

#audioMuteButton svg {
    transition: opacity 0.2s ease;
}

/* ===== Navigation UI Elements - Unified for iOS and Android ===== */

/* Force hardware acceleration and proper rendering for all platforms */
#navBottomBar,
#navStopButton {
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
    
    /* Ensure proper stacking context */
    -webkit-perspective: 1000;
    perspective: 1000;
    
    /* Fixed positioning - bottom position set by JavaScript */
    position: fixed !important;
    
    /* Ensure elements are clickable and visible */
    pointer-events: auto !important;
    -webkit-touch-callout: none;
    
    /* High z-index to ensure visibility above map */
    z-index: 99999 !important;
    /* OPTIMIZATION: CSS containment for isolated navigation components */
    contain: layout paint;
}

/* Desktop-only fix: Combine centering transform with hardware acceleration */
@media (min-width: 769px) {
    #navBottomBar {
        /* Combine translateX(-50%) for centering with translateZ(0) for hardware acceleration */
        transform: translateX(-50%) translateZ(0);
        -webkit-transform: translateX(-50%) translateZ(0);
    }
}

/* New Zealand Stop Sign Button Hover Effects */
#navExitBtn:hover svg {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

#navExitBtn:active svg {
    transform: scale(0.95);
}

/* Ensure button is tappable on iOS and all mobile devices */
#navExitBtn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* Prevent double-tap zoom and improve touch responsiveness */
    cursor: pointer;
    user-select: none; /* Prevent text selection on touch */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== Route Calculation Loading Spinner ===== */
.route-loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.route-loading-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 32px 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 200px;
}

.route-loading-spinner-icon {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #0b5bd3;
    border-radius: 50%;
    animation: route-loading-spin 0.8s linear infinite;
    /* Hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

.route-loading-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    text-align: center;
}

@keyframes route-loading-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .route-loading-content {
        padding: 24px 32px;
        min-width: 180px;
    }
    
    .route-loading-spinner-icon {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
    
    .route-loading-text {
        font-size: 14px;
    }
}

/* Performance Metrics Dashboard (Development Only) */
.performance-metrics-dashboard {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 12px;
}

.performance-metrics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px 8px 0 0;
}

.performance-metrics-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.performance-metrics-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.performance-metrics-close:hover {
    background: #e5e7eb;
    color: #111827;
}

.performance-metrics-content {
    overflow-y: auto;
    padding: 16px;
    flex: 1;
}

.performance-metrics-section {
    margin-bottom: 16px;
}

.performance-metrics-section h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.performance-metrics-data {
    background: #f9fafb;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.6;
    color: #4b5563;
    white-space: pre-wrap;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

.performance-metrics-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 8px 8px;
}

.performance-metrics-btn {
    flex: 1;
    padding: 6px 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}

.performance-metrics-btn:hover {
    background: #2563eb;
}

.performance-metrics-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.performance-metrics-toggle:hover {
    background: #2563eb;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .performance-metrics-dashboard {
        width: calc(100vw - 40px);
        max-width: calc(100vw - 40px);
        top: 10px;
        right: 10px;
        left: 10px;
        max-height: calc(100vh - 20px);
    }
}

/* ============================================
   Animated Navigation Instruction Box
   ============================================ */

/* Main container - positioned top-left with safe area support */
/* Navigation instruction box - constrained using right positioning to stop before speed HUD */
#navInstructionBox,
.nav-instruction-box {
    position: fixed !important;
    left: 12px !important;
    right: 240px !important; /* CRITICAL: Stop 240px from right edge (12px margin + ~220px speed HUD + 8px gap) */
    top: calc(env(safe-area-inset-top) + 12px) !important;
    z-index: 1300;
    pointer-events: none;
    /* Hidden by default - animated in via JavaScript */
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Visible state - slide in and fade in */
.nav-instruction-box.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    right: 240px !important; /* Maintain constraint to stop before speed HUD */
}

/* Fading out state */
.nav-instruction-box.fading-out {
    opacity: 0;
    transform: translateY(-15px) scale(0.97);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card container with beautiful styling - fills container */
.nav-instruction-card {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 100% !important; /* Fill container */
    max-width: 100% !important; /* Never exceed container */
    min-width: 0 !important; /* Prevent flex expansion */
    box-sizing: border-box !important;
    overflow: hidden !important;
    flex-shrink: 1 !important; /* Allow card to shrink if needed */
}

/* Arrow container - fixed width for consistent layout */
.nav-instruction-arrow-container {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Animated arrow bounce on appear */
.nav-instruction-box.visible .nav-instruction-arrow-container {
    animation: arrowBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s;
}

@keyframes arrowBounce {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Bridge marker bounce animation for proximity alert */
@keyframes bridgeMarkerBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* SVG Arrow - animated rotation and color */
.nav-instruction-arrow {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.3s ease;
}

/* Arrow directions via CSS transforms */
.nav-instruction-arrow.direction-up {
    transform: rotate(-90deg);
}

.nav-instruction-arrow.direction-down {
    transform: rotate(90deg);
}

.nav-instruction-arrow.direction-left {
    transform: rotate(180deg);
    color: #FF6600; /* Match GPS puck orange */
}

.nav-instruction-arrow.direction-right {
    transform: rotate(0deg);
    color: #FF6600; /* Match GPS puck orange */
}

.nav-instruction-arrow.direction-slight-left {
    transform: rotate(-135deg);
}

.nav-instruction-arrow.direction-slight-right {
    transform: rotate(45deg);
}

.nav-instruction-arrow.direction-sharp-left {
    transform: rotate(-150deg);
}

.nav-instruction-arrow.direction-sharp-right {
    transform: rotate(30deg);
}

.nav-instruction-arrow.direction-uturn {
    transform: rotate(0deg);
    color: #f59e0b;
}

.nav-instruction-arrow.direction-roundabout {
    transform: rotate(0deg);
    color: #8b5cf6;
}

.nav-instruction-arrow.direction-straight {
    transform: rotate(-90deg);
    color: #10b981;
}

/* Text container */
.nav-instruction-text-container {
    flex: 1 1 0 !important; /* Allow flex growth but start from 0 */
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    word-break: break-word !important; /* Force text to wrap */
    position: relative !important; /* Ensure it respects parent bounds */
    box-sizing: border-box !important;
}

/* Instruction text styling */
.nav-instruction-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: #ffffff;
    word-wrap: break-word;
    white-space: normal;
    letter-spacing: -0.01em;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #navInstructionBox,
    .nav-instruction-box {
        left: 8px !important;
        right: 200px !important; /* CRITICAL: Stop 200px from right edge on mobile (8px margin + ~180px speed HUD + 12px gap) */
        top: calc(env(safe-area-inset-top) + 8px) !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .nav-instruction-card {
        width: 100% !important; /* Fill container */
        max-width: 100% !important; /* Never exceed container */
        box-sizing: border-box !important;
        overflow: hidden !important;
        padding: 14px 16px;
        gap: 12px;
    }
    
    .nav-instruction-arrow-container {
        width: 44px;
        height: 44px;
    }
    
    .nav-instruction-arrow {
        width: 24px;
        height: 24px;
    }
    
    .nav-instruction-text {
        font-size: 16px;
    }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
    .nav-instruction-card {
        background: rgba(17, 24, 39, 0.98);
        border-color: rgba(255, 255, 255, 0.12);
    }
}

