/* ============================================================================
   CEBU JEEPNEY ROUTE MAP â€” DESIGN SYSTEM
   ============================================================================ */

:root {
    /* Colors â€” Sophisticated Dark Theme */
    --c-bg-primary: #0f1117;
    --c-bg-secondary: #161822;
    --c-bg-tertiary: #1c1f2e;
    --c-bg-hover: #242738;
    --c-bg-active: #2a2d44;
    --c-surface: #1e2130;
    --c-surface-elevated: #252840;

    --c-border: rgba(255, 255, 255, 0.06);
    --c-border-subtle: rgba(255, 255, 255, 0.04);
    --c-border-strong: rgba(255, 255, 255, 0.12);

    --c-text-primary: #e8eaed;
    --c-text-secondary: #9aa0b0;
    --c-text-tertiary: #6b7186;
    --c-text-disabled: #4a4f63;

    /* Accent colors for routes */
    --c-accent: #6e8efb;
    --c-accent-hover: #8da4fc;
    --c-accent-soft: rgba(110, 142, 251, 0.12);
    --c-accent-surface: rgba(110, 142, 251, 0.08);

    --c-success: #4ade80;
    --c-warning: #f59e0b;
    --c-error: #f87171;
    --c-info: #38bdf8;

    /* Route colors â€” a curated palette */
    --route-color-1: #6e8efb;
    --route-color-2: #a78bfa;
    --route-color-3: #f472b6;
    --route-color-4: #fb923c;
    --route-color-5: #4ade80;
    --route-color-6: #38bdf8;
    --route-color-7: #facc15;
    --route-color-8: #f87171;
    --route-color-9: #34d399;
    --route-color-10: #e879f9;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fw-light: 300;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;
    --fw-extrabold: 800;

    /* Spacing */
    --space-xxs: 4px;
    --space-xs: 6px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 24px rgba(110, 142, 251, 0.2);

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-normal: 200ms ease;
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-width: 380px;
    --header-height: 60px;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.5;
    color: var(--c-text-primary);
    background: var(--c-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--c-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--c-accent-hover); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height â€” accounts for mobile browser chrome */
    width: 100vw;
    overflow: hidden;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--c-bg-secondary);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    overflow: hidden;
    transition: transform var(--transition-smooth), width var(--transition-smooth);
}

.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    min-width: 0;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--c-accent), #a78bfa);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.brand-text h1 {
    font-size: 15px;
    font-weight: var(--fw-bold);
    color: var(--c-text-primary);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    font-weight: var(--fw-medium);
    color: var(--c-text-tertiary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Search */
.sidebar-search {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--space-md);
    color: var(--c-text-tertiary);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.search-input-wrapper:focus-within .search-icon {
    color: var(--c-accent);
}

#searchInput {
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    padding-left: 38px;
    padding-right: 36px;
    background: var(--c-bg-tertiary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    color: var(--c-text-primary);
    font-size: 13px;
    transition: all var(--transition-normal);
    outline: none;
}

#searchInput::placeholder {
    color: var(--c-text-disabled);
}

#searchInput:focus {
    border-color: var(--c-accent);
    background: var(--c-bg-hover);
    box-shadow: 0 0 0 3px var(--c-accent-soft);
}

.clear-search-btn {
    position: absolute;
    right: var(--space-sm);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--c-text-tertiary);
    transition: all var(--transition-fast);
}
.clear-search-btn:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-primary);
}

/* Filters */
.sidebar-filters {
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.filter-row {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.filter-btn {
    padding: var(--space-xxs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: var(--fw-semibold);
    color: var(--c-text-tertiary);
    background: var(--c-bg-tertiary);
    border: 1px solid var(--c-border);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-secondary);
    border-color: var(--c-border-strong);
}

.filter-btn.active {
    background: var(--c-accent-soft);
    color: var(--c-accent);
    border-color: rgba(110, 142, 251, 0.3);
}

/* Stats */
.sidebar-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-xl);
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.sidebar-stats span {
    font-size: 12px;
    color: var(--c-text-tertiary);
    font-weight: var(--fw-medium);
}

.toggle-sidebar-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--c-text-tertiary);
    transition: all var(--transition-fast);
}
.toggle-sidebar-btn:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-primary);
}

/* Route List */
.route-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-sm) var(--space-md);
    /* Ensure it's always scrollable on mobile */
    -webkit-overflow-scrolling: touch;
    min-height: 0; /* Critical: allows flex child to shrink below content size */
}

.route-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-xxs);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    border: 1px solid transparent;
}

.route-card:hover {
    background: var(--c-bg-hover);
    border-color: var(--c-border);
}

.route-card.active {
    background: var(--c-accent-surface);
    border-color: rgba(110, 142, 251, 0.2);
}

.route-card.active .route-code {
    box-shadow: var(--shadow-glow);
}

.route-code {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: var(--fw-extrabold);
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    transition: box-shadow var(--transition-normal);
}

.route-info {
    flex: 1;
    min-width: 0;
}

.route-name {
    font-size: 13px;
    font-weight: var(--fw-semibold);
    color: var(--c-text-primary);
    margin-bottom: 2px;
    line-height: 1.3;
}

.route-desc {
    font-size: 11px;
    color: var(--c-text-tertiary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.route-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xxs);
}

.route-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: 0.3px;
}

.badge-area {
    background: rgba(110, 142, 251, 0.1);
    color: var(--c-accent);
}

.badge-fare {
    background: rgba(74, 222, 128, 0.1);
    color: var(--c-success);
}

.badge-stops {
    background: rgba(251, 146, 60, 0.1);
    color: var(--c-warning);
}

/* Footer */
.sidebar-footer {
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--c-border);
    flex-shrink: 0;
}

.sidebar-footer span {
    font-size: 10px;
    color: var(--c-text-disabled);
}

/* ============================================================================
   MAP AREA
   ============================================================================ */

.map-area {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Custom map tiles styling */
.leaflet-container {
    background: var(--c-bg-primary) !important;
    font-family: var(--font-family) !important;
}

/* Map overlay controls */
.map-overlay-controls {
    position: absolute;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.map-ctrl-btn {
    width: 40px;
    height: 40px;
    background: var(--c-bg-secondary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-secondary);
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
}

.map-ctrl-btn:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-primary);
    border-color: var(--c-border-strong);
    transform: scale(1.05);
}

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

/* Route Info Panel */
.route-info-panel {
    position: absolute;
    bottom: var(--space-xl);
    left: var(--space-xl);
    right: var(--space-xl);
    max-width: 520px;
    background: var(--c-bg-secondary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    z-index: 1000;
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(12px);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#routeInfoContent {
    max-height: calc(100vh - 120px);
    max-height: calc(100dvh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.info-stops {
    display: block;
    margin-top: var(--space-md);
    overflow-y: auto;
    flex: 1;
    padding-right: 16px;
    margin-right: -16px;
}

.info-stops::-webkit-scrollbar {
    width: 6px;
}
.info-stops::-webkit-scrollbar-track {
    background: transparent;
    margin: var(--space-xl) 0;
}
.info-stops::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}
.info-stops::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.route-info-panel.hidden {
    display: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-info-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--c-text-tertiary);
    transition: all var(--transition-fast);
}
.close-info-btn:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-primary);
}

.info-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.info-code {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: var(--fw-extrabold);
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.info-title h2 {
    font-size: 18px;
    font-weight: var(--fw-bold);
    color: var(--c-text-primary);
    margin-bottom: 2px;
}

.info-title p {
    font-size: 12px;
    color: var(--c-text-tertiary);
}

.info-badges {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-xxs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: var(--fw-semibold);
}


.info-stop {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 12px;
    color: var(--c-text-secondary);
}

.info-stop::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.info-stop-divider {
    color: var(--c-text-disabled);
    font-size: 10px;
}

/* Mobile sidebar toggle */
.mobile-sidebar-toggle {
    position: absolute;
    top: var(--space-xl);
    left: var(--space-xl);
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--c-bg-secondary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--c-text-secondary);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.mobile-sidebar-toggle:hover {
    background: var(--c-bg-hover);
    color: var(--c-text-primary);
}

.floating-restore-btn {
    position: absolute;
    bottom: var(--space-xl);
    left: var(--space-xl);
    z-index: 1000;
    height: 48px;
    padding: 0 var(--space-xl);
    background: var(--c-accent);
    border: none;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg), 0 0 0 4px rgba(110, 142, 251, 0.2);
    transition: all var(--transition-smooth);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.floating-restore-btn:hover {
    background: var(--c-accent-hover);
    transform: translateY(-2px) scale(1.05);
    animation: none;
}

.floating-restore-btn.hidden {
    display: none;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    background: var(--c-bg-secondary) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    color: var(--c-text-primary) !important;
    font-family: var(--font-family) !important;
    font-size: 12px !important;
    line-height: 1.5 !important;
}

.leaflet-popup-tip {
    background: var(--c-bg-secondary) !important;
    border: 1px solid var(--c-border) !important;
    box-shadow: none !important;
}

.leaflet-popup-close-button {
    color: var(--c-text-tertiary) !important;
    font-size: 18px !important;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.leaflet-popup-close-button:hover {
    color: var(--c-text-primary) !important;
}

.popup-content {
    padding: var(--space-md) var(--space-lg);
}

.popup-content h3 {
    font-size: 14px;
    font-weight: var(--fw-bold);
    color: var(--c-text-primary);
    margin-bottom: 2px;
}

.popup-content p {
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin: 0;
}

.map-stop-tooltip {
    background: rgba(22, 24, 34, 0.85) !important;
    border: 1px solid var(--c-border) !important;
    color: var(--c-text-primary) !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    padding: 2px 6px !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-sm) !important;
    backdrop-filter: blur(4px);
}
.leaflet-tooltip.map-stop-tooltip::before {
    display: none;
}

body.hide-tooltips .map-stop-tooltip {
    display: none !important;
}

/* Leaflet zoom control */
.leaflet-control-zoom {
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--c-bg-secondary) !important;
    color: var(--c-text-secondary) !important;
    border-color: var(--c-border) !important;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 16px !important;
    transition: all var(--transition-fast);
}

.leaflet-control-zoom a:hover {
    background: var(--c-bg-hover) !important;
    color: var(--c-text-primary) !important;
}

/* Attribution */
.leaflet-control-attribution {
    background: rgba(15, 17, 23, 0.7) !important;
    color: var(--c-text-disabled) !important;
    font-size: 10px !important;
    border-radius: var(--radius-sm) !important;
    padding: 2px 6px !important;
    backdrop-filter: blur(4px);
}

.leaflet-control-attribution a {
    color: var(--c-text-tertiary) !important;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    color: var(--c-text-disabled);
    text-align: center;
}

.empty-state svg {
    margin-bottom: var(--space-lg);
    opacity: 0.4;
}

.empty-state p {
    font-size: 13px;
    font-weight: var(--fw-medium);
}

/* Toast */
.toast-notification {
    position: fixed;
    bottom: var(--space-2xl);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--c-surface-elevated);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-xl);
    color: var(--c-text-primary);
    font-size: 13px;
    font-weight: var(--fw-medium);
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    backdrop-filter: blur(12px);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        z-index: 2000;
        overflow: hidden;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .mobile-sidebar-toggle {
        display: flex;
    }

    .route-info-panel {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
    }

    .map-overlay-controls {
        top: var(--space-xl);
        right: var(--space-md);
    }

    .toggle-sidebar-btn {
        display: none;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --sidebar-width: 320px;
    }
}

/* ============================================================================
   TABS
   ============================================================================ */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    padding: var(--space-md);
    font-size: 12px;
    font-weight: var(--fw-semibold);
    color: var(--c-text-tertiary);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tab-btn:hover { color: var(--c-text-secondary); background: var(--c-bg-hover); }
.tab-btn.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }
.tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
.tab-content.active { display: flex; min-height: 0; }

/* ============================================================================
   EDITOR
   ============================================================================ */
.editor-panel {
    padding: var(--space-lg) var(--space-xl);
    overflow-y: auto;
    flex: 1;
}
.editor-panel h3 {
    font-size: 15px;
    font-weight: var(--fw-bold);
    margin-bottom: var(--space-sm);
    color: var(--c-text-primary);
}
.editor-hint {
    font-size: 11px;
    color: var(--c-text-tertiary);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}
.form-group {
    margin-bottom: var(--space-md);
}
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    color: var(--c-text-tertiary);
    margin-bottom: var(--space-xxs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.input-field {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--c-bg-tertiary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    color: var(--c-text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-normal);
}
.input-field:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-soft);
}
select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239aa0b0' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}
.btn {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: var(--fw-semibold);
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}
.btn-accent {
    background: var(--c-accent);
    color: white;
}
.btn-accent:hover { background: var(--c-accent-hover); }
.btn-success {
    background: var(--c-success);
    color: #111;
}
.btn-success:hover { filter: brightness(1.1); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-text-secondary);
}
.btn-outline:hover { background: var(--c-bg-hover); border-color: var(--c-border-strong); }
.btn-danger { border-color: rgba(248,113,113,0.3); color: var(--c-error); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.btn-full { width: 100%; }
.btn-small { padding: var(--space-xxs) var(--space-sm); font-size: 11px; }

.editor-stop-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    background: var(--c-bg-tertiary);
}
.editor-stop-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    font-size: 11px;
    color: var(--c-text-secondary);
    border-bottom: 1px solid var(--c-border-subtle);
}
.editor-stop-item:last-child { border-bottom: none; }
.editor-stop-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--c-accent-soft);
    color: var(--c-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: var(--fw-bold);
    flex-shrink: 0;
}
.editor-stop-name {
    flex: 1;
    min-width: 0;
}
.editor-stop-name input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--c-text-primary);
    font-size: 11px;
    font-family: inherit;
    outline: none;
    padding: 2px 0;
}
.editor-stop-name input:focus {
    border-bottom: 1px solid var(--c-accent);
}
.editor-stop-coords {
    font-size: 9px;
    color: var(--c-text-disabled);
    font-family: monospace;
}
.editor-stop-remove {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-disabled);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}
.editor-stop-remove:hover {
    background: rgba(248,113,113,0.2);
    color: var(--c-error);
}

/* Edit mode indicator */
.edit-mode-indicator {
    position: absolute;
    top: var(--space-xl);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--c-accent);
    color: white;
    padding: var(--space-sm) var(--space-xl);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: var(--fw-semibold);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow-lg);
    animation: pulse-glow 2s ease-in-out infinite;
}
.edit-mode-indicator.hidden { display: none; }
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(110,142,251,0.4); }
    50% { box-shadow: 0 0 20px rgba(110,142,251,0.7); }
}


/* ============================================================================
   MOBILE RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100vh;
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        width: 100%;
        max-width: 320px;
    }
    .mobile-sidebar-toggle {
        display: flex;
    }
    .route-info-panel {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
        top: 60px;            /* leave room for map toggle button */
        max-width: none;
        padding: var(--space-md);
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    #routeInfoContent {
        max-height: none;     /* panel itself handles the scroll */
        overflow: visible;
    }
    .map-overlay-controls {
        top: var(--space-md);
        right: var(--space-md);
    }
    .mobile-sidebar-toggle {
        top: var(--space-md);
        left: var(--space-md);
    }
    .floating-restore-btn {
        bottom: var(--space-md);
        left: 50%;
        transform: translateX(-50%);
    }
    .floating-restore-btn:hover {
        transform: translateX(-50%) translateY(-2px) scale(1.05);
    }
}

/* ============================================================================
   NEAR ME FEATURE
   ============================================================================ */

.sidebar-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-xl);
    font-size: 11px;
    color: var(--c-text-tertiary);
}

.near-me-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--c-accent-soft);
    border: 1px solid var(--c-accent);
    border-radius: var(--radius-full);
    color: var(--c-accent);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}
.near-me-btn:hover { background: var(--c-accent); color: white; }
.near-me-btn.loading { opacity: 0.6; pointer-events: none; }

.nearby-panel {
    margin: 0 var(--space-md) var(--space-sm);
    background: rgba(110, 142, 251, 0.08);
    border: 1px solid rgba(110, 142, 251, 0.25);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 40vh;   /* never takes more than 40% of screen */
    flex-shrink: 0;
}
.nearby-panel #nearbyList {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}
.nearby-panel.hidden { display: none; }

.nearby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    color: var(--c-accent);
    border-bottom: 1px solid rgba(110, 142, 251, 0.2);
}

.nearby-clear-btn {
    background: none;
    border: none;
    color: var(--c-text-tertiary);
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.nearby-clear-btn:hover { color: var(--c-error); background: rgba(248,113,113,0.1); }

.nearby-route-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background var(--transition-fast);
}
.nearby-route-item:last-child { border-bottom: none; }
.nearby-route-item:hover { background: rgba(255,255,255,0.04); }

.nearby-code {
    font-size: 11px;
    font-weight: 700;
    color: white;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
}

.nearby-info { flex: 1; min-width: 0; }
.nearby-name { font-size: 12px; font-weight: 600; color: var(--c-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby-dist { font-size: 10px; color: var(--c-accent); margin-top: 1px; }
.nearby-stop { font-size: 10px; color: var(--c-text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-location-pulse {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid white;
    box-shadow: 0 0 0 6px rgba(59,130,246,0.3);
    animation: location-pulse 2s ease-in-out infinite;
}

@keyframes location-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(59,130,246,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(59,130,246,0.1); }
}

/* Google Maps-style location pin */
.gmap-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    filter: drop-shadow(0 4px 8px rgba(59,130,246,0.5));
    animation: pin-drop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pin-drop {
    from { transform: translateY(-20px) scale(0.8); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

.gmap-pin-shadow {
    width: 10px;
    height: 4px;
    background: rgba(0,0,0,0.25);
    border-radius: 50%;
    margin-top: 2px;
    filter: blur(2px);
}

/* Fix Leaflet layer control z-index and styling */
.leaflet-control-layers {
    background: var(--c-bg-secondary) !important;
    border: 1px solid var(--c-border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--c-text-primary) !important;
}
.leaflet-control-layers-toggle {
    background-color: var(--c-bg-secondary) !important;
}
.leaflet-control-layers label {
    color: var(--c-text-primary) !important;
    font-size: 12px !important;
    font-family: inherit !important;
}

/* Trip Planner Suggestions */
.trip-suggestions {
    position: relative;
    z-index: 1001;
    background: var(--c-bg-secondary);
    border: 1px solid var(--c-border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin-top: -1px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
}
.trip-suggestion-item {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--c-text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--c-border-subtle);
}
.trip-suggestion-item:last-child { border-bottom: none; }
.trip-suggestion-item:hover { background: var(--c-bg-hover); }

/* Trip Results */
.trip-result-card {
    background: var(--c-bg-tertiary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}
.trip-result-card:hover { transform: translateY(-2px); border-color: var(--c-accent); }
.trip-result-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.trip-result-code { font-size: 11px; font-weight: 800; color: white; padding: 2px 8px; border-radius: 4px; }
.trip-result-fare { font-size: 12px; font-weight: 700; color: var(--c-success); margin-left: auto; }
.trip-result-details { font-size: 11px; color: var(--c-text-tertiary); line-height: 1.4; }

/* Arrow Toggle Active State */
.map-ctrl-btn.active {
    background: var(--c-accent-soft);
    color: var(--c-accent);
    border-color: var(--c-accent);
}

/* Responsive 2-column stops */
@media (max-width: 480px) {
    .info-stops > div {
        flex-direction: column !important;
        gap: 20px !important;
    }
}

/* Vehicle Type Select — Global */
.vehicle-type-select {
    width: 100%;
    background: var(--c-bg-tertiary);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    color: var(--c-text-primary);
    font-size: 12px;
    padding: 10px 12px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.vehicle-type-select:hover {
    background-color: var(--c-bg-hover);
    border-color: var(--c-border-strong);
}

.vehicle-type-select:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-soft);
}

.vehicle-type-select option {
    background: var(--c-bg-secondary);
    color: var(--c-text-primary);
    padding: 10px;
}
