/* --- GLOBAL & BASE --- */
html, body { 
    height: 100%; 
    margin: 0; 
    font-family: 'Poppins', sans-serif; 
    overflow: hidden;
}

#container { display: flex; height: 100vh; width: 100%; }

/* --- SIDEBAR (DESKTOP DEFAULT) --- */
#sidebar {
    width: 340px; 
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    transition: width 0.3s, transform 0.3s;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
#sidebar.collapsed { width: 0; overflow: hidden; }

/* Header */
.sidebar-header {
    padding: 20px 15px;
    background-color: #fff;
    border-bottom: 1px solid #f0f0f0;
}
.header-left{ display: flex; align-items: center; gap: 12px; }
.logo{ width: 40px; height: auto; }
.title h5{ margin: 0; font-size: 18px; font-weight: 700; color: #333; letter-spacing: -0.5px; }
.title small{ display: block; font-size: 11px; color: #888; font-weight: 400; margin-top: 2px; }

/* Location Navigation */
.location-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 12px;
    gap: 8px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.location-btn {
    flex: 1 1 45%;
    padding: 10px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    color: #555;
}
.location-btn:hover { background: #f5f5f5; border-color: #ccc; }
.location-btn.active {
    background: #1f2f98;
    color: white;
    border-color: #1f2f98;
    box-shadow: 0 2px 5px rgba(13, 110, 253, 0.2);
}

/* Content Area */
.sidebar-content { flex: 1; overflow-y: auto; padding-bottom: 50px; }

/* Route Section */
.route-section { border-bottom: 1px solid #f0f0f0; overflow: hidden; }
.route-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: #fff;
    transition: background 0.2s;
}
.route-header:hover { background: #f9f9f9; }
.route-info { display: flex; align-items: center; }
.route-indicator { width: 10px; height: 10px; border-radius: 50%; margin-right: 12px; }
.route-name { font-weight: 600; font-size: 14px; color: #333; }
.route-chevron { color: #ccc; transition: transform 0.3s ease; }
.route-section.active .route-chevron { transform: rotate(180deg); }

/* Timeline */
.route-timeline-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #fdfdfd;
    padding: 0 20px; 
}
.route-section.active .route-timeline-container {
    max-height: 1000px;
    padding: 5px 20px 15px 20px;
    border-top: 1px solid #f0f0f0;
}
.timeline {
    position: relative;
    padding-left: 20px;
    list-style: none;
    margin: 0;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: #e9ecef;
}
.timeline-item {
    position: relative;
    padding-bottom: 12px;
    font-size: 13px;
    color: #666;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -17px;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ccc;
    z-index: 1;
    transition: all 0.2s;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item.passed { color: #198754; font-weight: 500; }
.timeline-item.passed::before { background-color: #198754; border-color: #198754; }
.timeline-item.active { color: #000; font-weight: 600; }
.timeline-item.active::before {
    background-color: #0d6efd;
    border-color: #0d6efd;
    width: 12px;
    height: 12px;
    left: -18px;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

/* No Route */
.no-route-msg {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}
.no-route-msg i { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }

/* Map */
#map { flex: 1; height: 100%; z-index: 1; }

/* Toggle Button (Desktop) */
#toggleSidebar {
    position: absolute; top: 10px; left: 350px; z-index: 1001; 
    background: #fff; border: 1px solid #ddd; padding: 8px 12px; cursor: pointer;
    transition: left 0.3s;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: none; 
}
#toggleSidebar.collapsed { left: 10px; }

/* Bus Tooltip */
.bus-tooltip {
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    padding: 10px !important;
    font-family: 'Poppins', sans-serif !important;
    opacity: 1 !important;
    color: #333 !important;
    z-index: 1000 !important; 
}
.bus-tooltip::before { border: none !important; }
.leaflet-tooltip-left.bus-tooltip { margin-left: -10px; }
.leaflet-tooltip-right.bus-tooltip { margin-left: 10px; }

/* --- MOBILE TOP BAR (Hidden on Desktop) --- */
#mobile-top-bar {
    display: none; 
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    background: white;
    border-radius: 12px;
    padding: 12px; /* Adjusted padding */
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* NEW: Mobile Header Styles */
.mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px; /* Space between header and buttons */
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-logo {
    width: 32px; /* Slightly smaller for mobile */
    height: auto;
}

.mobile-title-text h5 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.mobile-title-text small {
    display: block;
    font-size: 10px;
    color: #888;
    font-weight: 400;
}

#mobile-location-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
}

#mobile-location-nav::-webkit-scrollbar { display: none; }
#mobile-location-nav { -ms-overflow-style: none; scrollbar-width: none; }

#mobile-location-nav .location-btn {
    flex: 0 0 auto;
    padding: 6px 12px;
    font-size: 11px;
}

/* --- MOBILE BOTTOM SHEET (Hidden on Desktop) --- */
#mobile-bottom-sheet {
    display: none; 
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 45vh; 
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    transform: translateY(calc(100% - 80px)); 
    transition: transform 0.3s ease-out;
}

#mobile-bottom-sheet.expanded {
    transform: translateY(0); 
}

.sheet-header {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    z-index: 10;
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background: #ddd;
    border-radius: 3px;
    margin: 0 auto 8px auto;
}

.sheet-title {
    font-weight: 600;
    text-align: center;
    font-size: 14px;
    color: #333;
}

.sheet-content {
    overflow-y: auto;
    height: calc(100% - 60px);
    padding-bottom: 20px;
}

/* --- RESPONSIVE BREAKPOINT --- */
@media (max-width: 768px) {
    #sidebar { display: none !important; }
    #toggleSidebar { display: none !important; }
    #mobile-top-bar { display: block; }
    #mobile-bottom-sheet { display: block; }
    .leaflet-control-zoom { margin-bottom: 100px !important; }
    
    /* IMPORTANT: Increased padding-top to account for the new header height */
    #map { padding-top: 110px; box-sizing: border-box; }
}

@media (min-width: 769px) {
    #toggleSidebar { display: block; }
}