/**
 * Navigator Side Drawer - Google Maps Style
 * Mobile-first side navigation drawer
 */

/* === Drawer Overlay === */
.nav-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 1999;
    pointer-events: none;
    transition: background 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-drawer-overlay.visible {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* === Drawer Container === */
.nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    height: 100dvh;
    background: var(--ios-bg);
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

.nav-drawer.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

/* Drawer being dragged */
.nav-drawer.dragging {
    transition: none;
}

/* === Drawer Header === */
.nav-drawer-header {
    padding: calc(var(--safe-top, 0px) + 16px) 16px 16px;
    background: linear-gradient(135deg, var(--ios-blue) 0%, #5856D6 100%);
    color: white;
    flex-shrink: 0;
}

.nav-drawer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-drawer-logo {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-drawer-logo svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.nav-drawer-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.nav-drawer-subtitle {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 2px;
}

/* === Drawer Content === */
.nav-drawer-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    /* Ensure scrollable content works on all devices */
    min-height: 0;
    /* Minimal bottom padding - footer handles safe area */
    padding-bottom: 8px;
}

/* === Drawer Sections === */
.nav-drawer-section {
    padding: 8px 0;
}

.nav-drawer-section:not(:last-child) {
    border-bottom: 1px solid var(--ios-separator);
}

/* Last section has normal padding - footer provides spacing */
.nav-drawer-section:last-child {
    padding-bottom: 8px;
}

.nav-drawer-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--ios-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 16px 4px;
}

/* === Drawer Items === */
.nav-drawer-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    color: var(--ios-text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: var(--ios-font);
    font-size: 15px;
}

.nav-drawer-item:active {
    background: var(--ios-fill);
}

.nav-drawer-item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-text-secondary);
    flex-shrink: 0;
}

.nav-drawer-item-icon svg {
    width: 22px;
    height: 22px;
}

.nav-drawer-item-text {
    flex: 1;
    font-weight: 400;
}

.nav-drawer-item-badge {
    background: var(--ios-blue);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.nav-drawer-item.active {
    background: rgba(0, 122, 255, 0.1);
}

.nav-drawer-item.active .nav-drawer-item-icon {
    color: var(--ios-blue);
}

.nav-drawer-item.active .nav-drawer-item-text {
    color: var(--ios-blue);
    font-weight: 500;
}

/* === Chevron on expandable items === */
.nav-drawer-item-chevron {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-text-secondary);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}
.nav-drawer-item-chevron svg { width: 16px; height: 16px; }
.nav-drawer-item.active .nav-drawer-item-chevron { transform: rotate(180deg); color: var(--ios-blue); }

/* === My Lists Slide-Down Panel === */
.nav-lists-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--ios-bg-secondary, #f2f2f7);
}
[data-theme="dark"] .nav-lists-panel {
    background: var(--ios-bg-secondary, #1c1c1e);
}

.nav-lists-panel-body {
    padding: 4px 0;
}

.nav-lists-panel-footer {
    padding: 6px 16px 10px;
}

.nav-lists-create-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 1.5px dashed var(--ios-blue, #007AFF);
    border-radius: 10px;
    background: transparent;
    color: var(--ios-blue, #007AFF);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--ios-font);
}
.nav-lists-create-btn svg { width: 16px; height: 16px; }
.nav-lists-create-btn:active { background: rgba(0,122,255,0.08); }

/* List item row */
.nav-lists-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}

.nav-lists-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--ios-fill, rgba(120,120,128,0.12));
    color: var(--ios-blue, #007AFF);
    flex-shrink: 0;
}

.nav-lists-item-info { flex: 1; min-width: 0; }
.nav-lists-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--ios-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-lists-item-count {
    font-size: 12px;
    color: var(--ios-text-secondary);
    margin-top: 1px;
}

.nav-lists-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.nav-lists-action-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--ios-text-secondary);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}
.nav-lists-action-btn:active { background: var(--ios-fill); }
.nav-lists-action-btn.nav-lists-action-delete { color: var(--ios-red, #FF3B30); }

/* Places inside a list */
.nav-lists-places {
    padding: 0 16px 4px 60px;
}

.nav-lists-place {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 0.5px solid var(--ios-separator, rgba(60,60,67,0.12));
    cursor: pointer;
}
.nav-lists-place:last-child { border-bottom: none; }
.nav-lists-place:active { opacity: 0.6; }

.nav-lists-place-icon {
    color: var(--ios-text-secondary);
    flex-shrink: 0;
}
.nav-lists-place-info { flex: 1; min-width: 0; }
.nav-lists-place-name {
    font-size: 13px;
    color: var(--ios-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-lists-place-addr {
    font-size: 11px;
    color: var(--ios-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inline rename input */
.nav-lists-rename-input {
    flex: 1;
    border: none;
    border-bottom: 2px solid var(--ios-blue, #007AFF);
    background: transparent;
    color: var(--ios-text);
    font-size: 15px;
    font-weight: 500;
    padding: 2px 0;
    outline: none;
    font-family: var(--ios-font);
    min-width: 0;
}

/* Inline create row */
.nav-lists-create-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
}
.nav-lists-create-row .nav-lists-rename-input {
    font-size: 14px;
    font-weight: 400;
}
.nav-lists-create-confirm {
    color: var(--ios-blue, #007AFF) !important;
}

/* Empty state */
.nav-lists-empty {
    text-align: center;
    padding: 20px 16px;
    color: var(--ios-text-secondary);
}
.nav-lists-empty svg { margin-bottom: 8px; opacity: 0.4; }
.nav-lists-empty p { font-size: 13px; margin: 0; }

/* Toast */
.nav-drawer-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.nav-drawer-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === Drawer Footer === */
.nav-drawer-footer {
    padding: 12px 16px calc(var(--safe-bottom, 0px) + 12px);
    border-top: 1px solid var(--ios-separator);
    background: var(--ios-bg-secondary);
    flex-shrink: 0;
}

.nav-drawer-footer-text {
    font-size: 12px;
    color: var(--ios-text-secondary);
    text-align: center;
}

.nav-drawer-footer-link {
    color: var(--ios-blue);
    text-decoration: none;
}

/* === Mobile Search Bar (Google Maps style) === */
.nav-mobile-search-bar {
    display: none;
}

@media (max-width: 768px) {
    .nav-mobile-search-bar {
        display: flex;
        position: absolute;
        top: calc(var(--safe-top, 0px) + 12px);
        left: 12px;
        right: 12px;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.95);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-radius: 28px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        padding: 4px;
        align-items: center;
        gap: 4px;
    }

    /* Dark mode search bar */
    [data-theme="dark"] .nav-mobile-search-bar {
        background: rgba(44, 44, 46, 0.95);
    }

    .nav-mobile-menu-btn {
        width: 44px;
        height: 44px;
        border-radius: 22px;
        border: none;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #1a1a1a;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-mobile-menu-btn:active {
        background: rgba(0, 0, 0, 0.05);
    }

    .nav-mobile-menu-btn svg {
        width: 22px;
        height: 22px;
    }

    [data-theme="dark"] .nav-mobile-menu-btn {
        color: #ffffff;
    }
    [data-theme="dark"] .nav-mobile-menu-btn:active {
        background: rgba(255, 255, 255, 0.1);
    }

    .nav-mobile-search-input {
        flex: 1;
        border: none;
        background: transparent;
        font-size: 16px;
        padding: 12px 8px;
        color: #1a1a1a;
        outline: none;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    }

    .nav-mobile-search-input::placeholder {
        color: #8e8e93;
    }

    /* Dark mode */
    [data-theme="dark"] .nav-mobile-search-input {
        color: #ffffff;
    }
    [data-theme="dark"] .nav-mobile-search-input::placeholder {
        color: #8e8e93;
    }

    .nav-mobile-voice-btn {
        width: 36px;
        height: 36px;
        border-radius: 18px;
        border: none;
        background: var(--ios-fill);
        color: var(--ios-text);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        margin-right: 8px;
        -webkit-tap-highlight-color: transparent;
        font-size: 16px;
        transition: all 0.15s;
    }

    .nav-mobile-voice-btn:active {
        transform: scale(0.9);
        background: var(--ios-fill-secondary);
    }

    .nav-mobile-profile-btn {
        width: 36px;
        height: 36px;
        border-radius: 18px;
        border: none;
        background: var(--ios-blue);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        margin-right: 4px;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-mobile-profile-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* === Swipe Edge Indicator === */
.nav-drawer-edge {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 100%;
    height: 100dvh;
    z-index: 1998;
    /* Invisible touch target for edge swipe */
}

/* === Dark Mode === */
[data-theme="dark"] .nav-drawer {
    background: var(--ios-bg);
}

[data-theme="dark"] .nav-drawer-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

[data-theme="dark"] .nav-drawer-overlay.visible {
    background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .nav-mobile-search-bar {
    background: rgba(30, 30, 30, 0.95);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* === Mobile: Google Maps style - hide desktop panel, use mobile search bar === */
@media (max-width: 768px) {
    /* CRITICAL: Hide desktop search panel on mobile by default (no JS needed) */
    .nav-search-panel {
        display: none !important;
    }

    /* Mobile search bar visibility */
    .nav-mobile-search-bar {
        transition: opacity 0.2s ease, transform 0.2s ease;
    }

    /* Hide mobile search bar when expanded panel is open */
    body.nav-panel-expanded .nav-mobile-search-bar {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-20px);
    }

    /* Move POI bar below the mobile search bar */
    .nav-poi-bar {
        top: calc(var(--safe-top, 0px) + 70px) !important;
    }

    /* When expanded, show the desktop search panel */
    body.nav-panel-expanded .nav-search-panel {
        display: block !important;
        transform: translateY(0) !important;
        pointer-events: auto;
    }

    body.nav-panel-expanded .nav-search-card {
        transform: translateY(0) !important;
    }
}

/* === Mobile Expanded Search Panel (FROM/TO inline) === */
.nav-mobile-expanded {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    z-index: 2500;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
}

[data-theme="dark"] .nav-mobile-expanded {
    background: #1c1c1e;
}

.nav-mobile-expanded.visible {
    display: flex;
}

.nav-mobile-expanded-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .nav-mobile-expanded-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.nav-mobile-back-btn,
.nav-mobile-help-btn,
.nav-mobile-options-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #007aff;
    -webkit-tap-highlight-color: transparent;
}

.nav-mobile-back-btn:active,
.nav-mobile-help-btn:active,
.nav-mobile-options-btn:active {
    background: rgba(0, 122, 255, 0.1);
}

.nav-mobile-back-btn svg,
.nav-mobile-help-btn svg,
.nav-mobile-options-btn svg {
    width: 24px;
    height: 24px;
}

.nav-mobile-expanded-title {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    text-align: center;
}

[data-theme="dark"] .nav-mobile-expanded-title {
    color: #ffffff;
}

/* ======================================================
   WAYPOINTS — Automotive instrument cluster design
   Clean, precise, generous touch targets (44px min)
   ====================================================== */
.nav-mobile-waypoints {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.nav-mobile-waypoint {
    display: flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border-radius: 0;
    padding: 0;
}

/* --- Route indicator: dot + connecting line --- */
.nav-wp-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 28px;
    flex-shrink: 0;
    align-self: stretch;
}

.nav-wp-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 17px;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}
.nav-mobile-waypoint:focus-within .nav-wp-dot {
    transform: scale(1.15);
}

.nav-mobile-waypoint-from {
    background: #30D158;
    box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.2);
}
.nav-mobile-waypoint-to {
    background: #FF453A;
    box-shadow: 0 0 0 3px rgba(255, 69, 58, 0.2);
}

/* Dashed line connecting FROM → TO */
.nav-wp-line {
    flex: 1;
    width: 2px;
    min-height: 8px;
    background: repeating-linear-gradient(
        to bottom,
        var(--ios-text-secondary, #8e8e93) 0px,
        var(--ios-text-secondary, #8e8e93) 3px,
        transparent 3px,
        transparent 7px
    );
    opacity: 0.35;
}

/* --- Input field with inline clear button --- */
.nav-wp-field {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--ios-bg-tertiary, #f2f2f7);
    border-radius: 12px;
    margin: 4px 0;
    border: 1.5px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.nav-wp-field:focus-within {
    border-color: var(--ios-blue, #007AFF);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}
[data-theme="dark"] .nav-wp-field {
    background: rgba(255, 255, 255, 0.08);
}

.nav-mobile-waypoint-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 16px;
    padding: 13px 4px 13px 14px;
    color: var(--ios-text, #1a1a1a);
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    font-weight: 400;
    letter-spacing: -0.01em;
}
.nav-mobile-waypoint-input::placeholder {
    color: var(--ios-text-secondary, #8e8e93);
    font-weight: 400;
}
[data-theme="dark"] .nav-mobile-waypoint-input {
    color: #ffffff;
}

/* Clear button — visible filled circle-X, generous 36px tap target */
.nav-mobile-clear-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ios-text-secondary, #8e8e93);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, transform 0.1s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    margin-right: 4px;
}
.nav-mobile-clear-btn svg {
    width: 20px;
    height: 20px;
}
.nav-mobile-clear-btn:active {
    transform: scale(0.85);
    color: var(--ios-red, #FF453A);
}
.nav-mobile-waypoint-input:not(:placeholder-shown) ~ .nav-mobile-clear-btn {
    opacity: 1;
}
[data-theme="dark"] .nav-mobile-clear-btn {
    color: rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .nav-mobile-clear-btn:active {
    color: #FF453A;
}

/* --- Action buttons: GPS + Map — pill-shaped, tinted bg --- */
.nav-wp-actions {
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin-left: 6px;
    flex-shrink: 0;
    align-items: center;
}

.nav-wp-action-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}
.nav-wp-action-btn svg {
    width: 16px;
    height: 16px;
}
.nav-wp-action-btn:active {
    transform: scale(0.9);
}

/* GPS / My Location button — blue tint */
.nav-wp-locate {
    background: rgba(0, 122, 255, 0.1);
    color: var(--ios-blue, #007AFF);
}
.nav-wp-locate:active {
    background: rgba(0, 122, 255, 0.22);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.15);
}
.nav-wp-locate.loading {
    pointer-events: none;
}
.nav-wp-locate.loading svg {
    animation: wp-spin 0.8s linear infinite;
}
@keyframes wp-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Select on Map button — green tint */
.nav-wp-map {
    background: rgba(48, 209, 88, 0.1);
    color: #30D158;
}
.nav-wp-map:active {
    background: rgba(48, 209, 88, 0.22);
    box-shadow: 0 0 0 2px rgba(48, 209, 88, 0.15);
}

[data-theme="dark"] .nav-wp-locate {
    background: rgba(0, 122, 255, 0.18);
}
[data-theme="dark"] .nav-wp-map {
    background: rgba(48, 209, 88, 0.18);
}

/* Backward compat: old class aliases still used by JS */
.nav-mobile-location-btn { /* alias for nav-wp-locate */ }
.nav-mobile-map-btn { /* alias for nav-wp-map */ }

/* Help button in mobile header - smaller icon font */
.nav-mobile-help-btn {
    font-size: 18px;
}

/* Toast for mobile map selection mode */
.nav-map-select-toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav-map-select-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nav-map-select-toast i {
    margin-right: 6px;
    color: #007aff;
}

.nav-mobile-clear-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #8e8e93;
    opacity: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.nav-mobile-waypoint-input:not(:placeholder-shown) ~ .nav-mobile-clear-btn {
    opacity: 1;
}

.nav-mobile-clear-btn svg {
    width: 14px;
    height: 14px;
}

[data-theme="dark"] .nav-mobile-clear-btn {
    background: rgba(255, 255, 255, 0.1);
}

/* === Swap + Add Stop Actions Row (between FROM and TO) === */
.nav-mobile-wp-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0 2px 28px; /* Align past indicator dots */
}
.nav-mobile-swap-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--ios-border, #e0e0e0);
    border-radius: 50%;
    background: var(--ios-bg-secondary, #f5f5f5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ios-text-secondary, #8e8e93);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}
.nav-mobile-swap-btn:active {
    background: var(--ios-blue, #007AFF);
    color: #fff;
    border-color: var(--ios-blue, #007AFF);
    transform: rotate(180deg);
}
.nav-mobile-swap-btn svg {
    width: 16px;
    height: 16px;
}
[data-theme="dark"] .nav-mobile-swap-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.nav-mobile-add-stop-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px dashed var(--ios-border, #ccc);
    border-radius: 16px;
    background: transparent;
    font-size: 12px;
    font-family: var(--ios-font);
    color: var(--ios-blue, #007AFF);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.nav-mobile-add-stop-btn:active { background: rgba(0,122,255,0.08); }
.nav-mobile-add-stop-btn svg { width: 12px; height: 12px; }
[data-theme="dark"] .nav-mobile-add-stop-btn {
    border-color: rgba(255, 255, 255, 0.15);
}

/* === Via Waypoints List (including auto-added border crossings) === */
.nav-mobile-via-list {
    padding: 0 0 0 28px;
}
.nav-mobile-via-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--ios-separator, rgba(0,0,0,0.06));
    font-size: 13px;
    font-family: var(--ios-font);
    color: var(--ios-text, #1a1a1a);
}
.nav-mobile-via-item:last-child { border-bottom: none; }
.nav-mobile-via-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ios-text-secondary, #8e8e93);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-mobile-via-border .nav-mobile-via-dot {
    width: auto;
    height: auto;
    background: transparent;
    color: var(--ios-orange, #FF9500);
}
.nav-mobile-via-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-mobile-via-border .nav-mobile-via-name {
    color: var(--ios-orange, #FF9500);
    font-weight: 500;
}
.nav-mobile-via-link {
    color: var(--ios-blue, #007AFF);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.nav-mobile-via-link svg { width: 12px; height: 12px; }
.nav-mobile-via-remove {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--ios-text-secondary, #8e8e93);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}
.nav-mobile-via-remove:active { color: var(--ios-red, #FF3B30); }
[data-theme="dark"] .nav-mobile-via-item {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* Vehicle Selector */
.nav-mobile-vehicle-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 0 16px 16px;
}

.nav-mobile-vehicle-btn {
    flex: 1;
    max-width: 80px;
    height: 48px;
    border: 2px solid transparent;
    background: #f2f2f7;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #8e8e93;
    transition: all 0.2s;
}

.nav-mobile-vehicle-btn svg {
    width: 24px;
    height: 24px;
}

.nav-mobile-vehicle-btn.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: #007aff;
    color: #007aff;
}

[data-theme="dark"] .nav-mobile-vehicle-btn {
    background: #2c2c2e;
}
[data-theme="dark"] .nav-mobile-vehicle-btn.active {
    background: rgba(0, 122, 255, 0.2);
}

/* Suggestions */
.nav-mobile-suggestions {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
}

.nav-mobile-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.nav-mobile-suggestion-item:active {
    background: rgba(0, 0, 0, 0.05);
    margin: 0 -16px;
    padding: 14px 16px;
}

.nav-mobile-suggestion-icon {
    width: 40px;
    height: 40px;
    background: #f2f2f7;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
    flex-shrink: 0;
}

.nav-mobile-suggestion-icon svg {
    width: 20px;
    height: 20px;
}

.nav-mobile-suggestion-text {
    flex: 1;
    min-width: 0;
}

.nav-mobile-suggestion-title {
    font-size: 16px;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-mobile-suggestion-subtitle {
    font-size: 13px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-theme="dark"] .nav-mobile-suggestion-item:active {
    background: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] .nav-mobile-suggestion-icon {
    background: #2c2c2e;
}
[data-theme="dark"] .nav-mobile-suggestion-title {
    color: #ffffff;
}

/* === Recalculate Route Bar === */
.nav-mobile-recalculate-bar {
    display: none;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
}
[data-theme="dark"] .nav-mobile-recalculate-bar {
    border-top-color: rgba(255, 255, 255, 0.1);
    background: #1c1c1e;
}
.nav-mobile-recalculate-bar.visible {
    display: block;
}
.nav-mobile-recalculate-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    background: #007AFF;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.nav-mobile-recalculate-btn:active {
    background: #0056b3;
}
.nav-mobile-recalculate-btn i {
    font-size: 14px;
}
.nav-mobile-clear-route-btn {
    display: none;
    width: 100%;
    padding: 10px 20px;
    margin-top: 8px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #FF3B30;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.nav-mobile-clear-route-btn:active {
    background: rgba(255, 59, 48, 0.1);
}
.nav-mobile-clear-route-btn.visible {
    display: block;
}

/* === Tablet/Desktop: Hide drawer, show sidebar === */
/* min-height: 501px excludes landscape phones (height < 500px) */
@media (min-width: 769px) and (min-height: 501px) {
    .nav-drawer,
    .nav-drawer-overlay,
    .nav-drawer-edge,
    .nav-mobile-search-bar,
    .nav-mobile-expanded {
        display: none !important;
    }
}

/* === Animations === */
@keyframes drawer-item-appear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-drawer.open .nav-drawer-item {
    animation: drawer-item-appear 0.2s ease forwards;
}

.nav-drawer.open .nav-drawer-section:nth-child(1) .nav-drawer-item { animation-delay: 0.05s; }
.nav-drawer.open .nav-drawer-section:nth-child(2) .nav-drawer-item { animation-delay: 0.1s; }
.nav-drawer.open .nav-drawer-section:nth-child(3) .nav-drawer-item { animation-delay: 0.15s; }

/* Force mobile elements visible on .nav-mobile (overrides desktop-hide media query in landscape) */
.nav-mobile .nav-mobile-search-bar {
    display: flex !important;
}
.nav-mobile .nav-mobile-expanded {
    display: none !important;
}
.nav-mobile .nav-mobile-expanded.visible {
    display: flex !important;
}
.nav-mobile .nav-floating-header {
    display: flex;
}
.nav-mobile .nav-floating-tab-bar {
    display: flex;
}
/* Drawer elements: keep available on mobile (desktop hides them) */
.nav-mobile .nav-drawer {
    display: flex !important;
    flex-direction: column !important;
}
.nav-mobile .nav-drawer-overlay {
    display: block !important;
    opacity: 0;
    pointer-events: none;
}
.nav-mobile .nav-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.nav-mobile .nav-drawer-edge {
    display: block !important;
}
/* Landscape: compact mobile search bar */
.nav-mobile.nav-landscape .nav-mobile-search-bar {
    right: auto;
    max-width: 420px;
    padding: 3px;
    min-height: 40px;
    border-radius: 22px;
    gap: 2px;
}

.nav-mobile.nav-landscape .nav-mobile-menu-btn {
    width: 36px;
    height: 36px;
}
.nav-mobile.nav-landscape .nav-mobile-menu-btn svg {
    width: 18px;
    height: 18px;
}

.nav-mobile.nav-landscape .nav-mobile-search-input {
    font-size: 14px;
    padding: 8px 6px;
}

.nav-mobile.nav-landscape .nav-mobile-ai-btn,
.nav-mobile.nav-landscape .nav-mobile-voice-menu-btn,
.nav-mobile.nav-landscape .nav-mobile-profile-btn {
    width: 32px;
    height: 32px;
    border-radius: 16px;
}

.nav-mobile.nav-landscape .nav-mobile-ai-btn .v2-icon {
    width: 14px;
    height: 14px;
}

.nav-mobile.nav-landscape .nav-mobile-profile-btn svg {
    width: 16px;
    height: 16px;
}

.nav-mobile.nav-landscape .nav-mobile-voice-menu-btn {
    margin-right: 2px;
}

.nav-mobile.nav-landscape .nav-mobile-profile-btn {
    margin-right: 2px;
}
/* Hide mobile search bar during navigation */
.nav-mobile .nav-state-navigating .nav-mobile-search-bar {
    display: none !important;
}


/* === Drawer Toggle Switches === */
.nav-drawer-toggle {
    width: 44px;
    height: 26px;
    background: var(--ios-fill-tertiary);
    border-radius: 13px;
    position: relative;
    transition: background 0.3s;
    cursor: pointer;
}

.nav-drawer-toggle::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.nav-drawer-toggle.active {
    background: var(--ios-green);
}

.nav-drawer-toggle.active::after {
    transform: translateX(18px);
}

[data-theme="dark"] .nav-drawer-toggle::after {
    background: var(--ios-bg);
}

/* App Settings section title */
.nav-drawer-section .nav-drawer-section-title {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ios-text-tertiary);
}

/* === Voice Options Panel (slides from left) === */
.nav-voice-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 2999;
    pointer-events: none;
    transition: background 0.3s ease;
}

.nav-voice-panel-overlay.visible {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.nav-voice-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    height: 100dvh;
    background: var(--ios-bg);
    z-index: 3000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    overflow: hidden;
}

.nav-voice-panel.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.nav-voice-panel-header {
    padding: calc(var(--safe-top, 0px) + 16px) 16px 16px;
    background: linear-gradient(135deg, var(--ios-blue) 0%, #5856D6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.nav-voice-panel-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.nav-voice-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-voice-panel-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.nav-voice-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Voice option item */
.nav-voice-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--ios-separator);
}

.nav-voice-option:active {
    background: var(--ios-fill);
}

.nav-voice-option-icon {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--ios-fill);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-text-secondary);
    flex-shrink: 0;
    font-size: 18px;
}

.nav-voice-option.active .nav-voice-option-icon {
    background: var(--ios-blue);
    color: white;
}

.nav-voice-option-text {
    flex: 1;
    min-width: 0;
}

.nav-voice-option-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--ios-text);
    margin-bottom: 2px;
}

.nav-voice-option-desc {
    font-size: 13px;
    color: var(--ios-text-secondary);
    line-height: 1.3;
}

.nav-voice-option-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-blue);
    opacity: 0;
    flex-shrink: 0;
}

.nav-voice-option.active .nav-voice-option-check {
    opacity: 1;
}

/* Voice menu button in search bar */
.nav-mobile-voice-menu-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    background: var(--ios-fill);
    color: var(--ios-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 8px;
    font-size: 16px;
    transition: all 0.15s;
}

.nav-mobile-voice-menu-btn:active {
    transform: scale(0.9);
    background: var(--ios-fill-secondary);
}

/* Dynamic voice icon sizing */
.nav-voice-icon-dynamic {
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-voice-icon-dynamic svg {
    width: 18px;
    height: 18px;
}

/* Muted state — red tint */
.nav-mobile-voice-menu-btn.voice-muted {
    background: rgba(255, 59, 48, 0.12);
    color: #ff3b30;
}
[data-theme="dark"] .nav-mobile-voice-menu-btn.voice-muted {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

/* AI button in search bar */
.nav-mobile-ai-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 16px;
    transition: all 0.15s;
}

.nav-mobile-ai-btn .v2-icon {
    width: 16px;
    height: 16px;
    stroke: #fff;
    fill: rgba(255, 255, 255, 0.2);
}

.nav-mobile-ai-btn:active {
    transform: scale(0.9);
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
}

[data-theme="dark"] .nav-mobile-ai-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
}

/* Voice options in drawer (slide-down panel) */
.nav-voice-drawer-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--ios-bg-secondary);
}

[data-theme="dark"] .nav-voice-drawer-panel {
    background: #1c1c1e;
}

.nav-voice-drawer-body {
    padding: 4px 0;
}

.nav-voice-drawer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-voice-drawer-option:active {
    background: var(--ios-fill);
}

.nav-voice-drawer-option-icon {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: var(--ios-fill);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-text-secondary);
    flex-shrink: 0;
    font-size: 16px;
}

.nav-voice-drawer-option.active .nav-voice-drawer-option-icon {
    background: var(--ios-blue);
    color: white;
}

.nav-voice-drawer-option-text {
    flex: 1;
    min-width: 0;
}

.nav-voice-drawer-option-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--ios-text);
    margin-bottom: 2px;
}

.nav-voice-drawer-option-desc {
    font-size: 12px;
    color: var(--ios-text-secondary);
    line-height: 1.3;
}

.nav-voice-drawer-option-check {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-blue);
    opacity: 0;
    flex-shrink: 0;
}

.nav-voice-drawer-option.active .nav-voice-drawer-option-check {
    opacity: 1;
}

/* Dark mode */
[data-theme="dark"] .nav-voice-panel {
    background: var(--ios-bg);
}

[data-theme="dark"] .nav-voice-panel-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
