:root {
    --bg-dark: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --accent-blue: #0ea5e9;
    --accent-glow: #38bdf8;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Glassmorphism Effect */
.glass {
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    z-index: 1000;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: var(--glass-shadow);
    margin-left: 0;
}

.sidebar.collapsed {
    margin-left: -380px;
}

.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: -32px;
    transform: translateY(-50%);
    width: 32px;
    height: 72px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-left: none;
    border-radius: 0 14px 14px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
    box-shadow: 4px 0 12px rgba(0,0,0,0.15);
}

.sidebar-toggle:hover {
    color: var(--accent-glow);
    background: rgba(30, 41, 59, 1);
}

.sidebar-toggle .icon {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
}

.sidebar.collapsed .sidebar-toggle .icon {
    transform: rotate(180deg);
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    color: var(--accent-blue);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Filter Section */
.filter-section {
    margin-bottom: 2rem;
}

.filter-section label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.select-wrapper {
    position: relative;
}

select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.85rem 2.5rem 0.85rem 1rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

select:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(30, 41, 59, 0.8);
}

/* Timeline Container */
.timeline-container h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.stop-timeline {
    list-style: none;
    padding-left: 1.5rem;
    position: relative;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) transparent;
}

.stop-timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.stop-timeline li {
    position: relative;
    padding-bottom: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.stop-timeline li:hover {
    transform: translateX(5px);
}

.stop-timeline li::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 4px;
    width: 10px;
    height: 10px;
    background: var(--bg-dark);
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
    z-index: 2;
    transition: all 0.2s ease;
}

.stop-timeline li.active::before {
    background: var(--accent-blue);
    border-color: var(--accent-glow);
    box-shadow: 0 0 10px var(--accent-glow);
}

.stop-name {
    font-size: 0.95rem;
    font-weight: 500;
}

.stop-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Main Content & Map */
.main-content {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Map Custom Styling */
.leaflet-container {
    background: #0f172a !important;
}

/* Analytics Overlay */
.analytics-overlay {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.25rem 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    z-index: 1001;
}

.stat-card {
    display: flex;
    flex-direction: column;
}

.stat-card .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.stat-card .value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.stat-separator {
    width: 1px;
    height: 30px;
    background: var(--glass-border);
}

.active-route .value {
    color: var(--accent-glow);
}

/* ── Route Chips ──────────────────────────────── */
.route-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    max-width: 320px;
}

.route-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.route-chip:hover {
    transform: translateY(-1px);
    filter: brightness(1.15);
}

.route-chip .chip-icon {
    font-size: 0.8rem;
}

.route-chip .chip-label {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip-empty {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
    border-color: rgba(100, 116, 139, 0.3);
}

.route-chip-arrow {
    color: var(--text-secondary);
    font-size: 0.65rem;
    opacity: 0.6;
}


/* ── Mode Tabs ─────────────────────────────────── */
.mode-tabs {
    display: flex;
    gap: 4px;
    padding: 0 1.5rem;
    margin-bottom: 1rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 2rem 0;
    max-height: calc(100vh - 160px);
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.3);
    border-radius: 4px;
}

.mode-tab {
    flex: 1;
    padding: 0.6rem 0.5rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.mode-tab:hover {
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-primary);
}

.mode-tab.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-glow);
    color: var(--accent-glow);
}

/* ── Navigation Inputs ─────────────────────────── */
.nav-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 6px;
}

.nav-input:focus {
    outline: none;
    border-color: var(--accent-glow);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.nav-input.set {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.input-with-btn {
    display: flex;
    gap: 6px;
    align-items: stretch;
    margin-top: 6px;
}

.input-with-btn .nav-input {
    margin-top: 0;
    flex: 1;
}

.btn-gps {
    width: 44px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-gps:hover {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
}

.btn-gps.loading {
    animation: pulse-gps 1s ease-in-out infinite;
}

@keyframes pulse-gps {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.nav-hint {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.5;
    opacity: 0.7;
}

/* ── Navigation Buttons ────────────────────────── */
.nav-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn-primary {
    flex: 1;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: rgba(248, 113, 113, 0.5);
    color: #f87171;
}

/* ── Navigation Results (Collapsible) ──────────── */
.nav-results {
    padding: 0 0 1rem 0;
}

.nav-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 1.5rem;
    cursor: pointer;
    border-radius: 10px;
    margin: 0 0.5rem 4px;
    transition: background 0.2s ease;
    user-select: none;
}

.nav-results-header:hover {
    background: rgba(56, 189, 248, 0.08);
}

.nav-results-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
}

.nav-mini-summary {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent-glow);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.nav-mini-summary:empty {
    display: none;
}

.nav-collapse-icon {
    font-size: 1rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.nav-results.collapsed .nav-collapse-icon {
    transform: rotate(-90deg);
}

.nav-results-body {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.35s ease, opacity 0.25s ease;
    opacity: 1;
}

.nav-results.collapsed .nav-results-body {
    max-height: 0;
    opacity: 0;
}

.nav-summary {
    margin: 0 1.5rem 16px;
    padding: 12px 16px;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.nav-summary .sum-item {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.nav-summary .sum-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 1.5rem;
    margin-bottom: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.toggle-row:hover {
    color: var(--text-primary);
}

.toggle-row input[type="checkbox"] {
    accent-color: #38bdf8;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.nav-steps {
    list-style: none;
    padding: 0 1.5rem;
    margin: 0;
}

.nav-steps li {
    position: relative;
    padding: 10px 0 10px 32px;
    border-left: 2px solid rgba(56, 189, 248, 0.2);
    margin-left: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.nav-steps li::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 2px solid var(--accent-glow);
}

.nav-steps li.step-walk::before {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
}

.nav-steps li.step-ride::before {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.2);
}

.nav-steps li.step-transfer::before {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.2);
}

.nav-steps li .step-action {
    font-weight: 600;
    color: var(--text-primary);
}

.nav-steps li .step-detail {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* ── Navigation Markers ────────────────────────── */
.origin-marker {
    background: #22c55e;
    border: 3px solid #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}

.dest-marker {
    background: #ef4444;
    border: 3px solid #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 300px; }
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -100%;
    }
}
