/* ... keep existing code (CSS variables and reset styles) */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ... keep existing code (navbar styles) */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 1050;
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 600;
    color: var(--text-primary) !important;
    text-decoration: none;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.brand-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1;
}

.navbar-toggler {
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    margin: 0 4px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
}

.nav-btn.logout-btn {
    background: var(--danger-color);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.08);
}

.nav-btn.logout-btn:hover {
    background: #b91c1c;
    color: white;
    transform: translateY(-1px) scale(1.04);
}

/* ... keep existing code (main container and mobile nav) */
.main-container {
    padding-top: 80px;
    height: 100vh;
    overflow: hidden;
}

.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 8px;
    display: flex;
    justify-content: space-around;
    z-index: 1040;
    box-shadow: var(--shadow-lg);
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 60px;
}

.mobile-nav-btn i {
    font-size: 16px;
}

.mobile-nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-nav-btn.active {
    color: var(--primary-color);
}

.app-layout {
    display: flex;
    height: calc(100vh - 80px);
}

/* ... keep existing code (sidebar and card styles) */
.sidebar-panel {
    width: 380px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1030;
}

.sidebar-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: 20px;
}

/* ... keep existing code (search and filter styles) */
.search-header, .route-header, .filter-header, .buildings-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 16px;
}

.search-header i, .route-header i, .filter-header i, .buildings-header i {
    color: var(--primary-color);
    font-size: 18px;
}

.search-input-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Building Items - Updated Layout */
.building-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.building-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.building-item.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
}

.building-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.building-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.building-info {
    flex: 1;
    min-width: 0;
}

.building-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.2;
    margin-bottom: 2px;
}

.building-type {
    padding: 2px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.building-description {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
    margin-left: 44px;
}

/* ... keep existing code (route planning styles) */
.route-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.input-icon {
    font-size: 14px;
    width: 16px;
}

.from-icon {
    color: var(--success-color);
}

.to-icon {
    color: var(--danger-color);
}

.route-select {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
}

.route-select:focus {
    outline: none;
}

.route-buttons {
    display: flex;
    gap: 8px;
}

.btn-primary {
    flex: 1;
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--secondary-color);
    color: white;
}

/* ... keep existing code (filter styles) */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.filter-option:hover {
    background: var(--bg-tertiary);
}

.filter-option.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-option input {
    display: none;
}

.filter-text {
    font-size: 14px;
    font-weight: 500;
}

/* ... keep existing code (buildings list) */
.buildings-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 400px;
    overflow-y: auto;
}

/* ... keep existing code (map and controls) */
.map-container {
    flex: 1;
    position: relative;
    background: var(--bg-tertiary);
}

.campus-map {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.map-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.map-control-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Route Info Panel - Enhanced */
.route-info-panel {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 1000;
}

.route-info-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.route-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-primary);
}

.route-info-header i {
    color: var(--primary-color);
}

.close-btn {
    margin-left: auto;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--danger-color);
    color: white;
}

.route-details {
    padding: 20px;
}

.route-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.route-path {
    font-size: 16px;
    color: var(--text-primary);
}

.route-stats {
    display: flex;
    gap: 16px;
    align-items: center;
}

.distance, .time {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

/* Modal Enhancements */
.modal {
    z-index: 1060;
}

.modal-backdrop {
    z-index: 1055;
    background-color: rgba(0, 0, 0, 0.5);
}

.building-modal .modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.building-modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 24px;
}

.modal-title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.favorite-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 12px;
}

.favorite-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.favorite-btn.active {
    background: var(--danger-color);
}

.favorite-btn.active i {
    color: white;
}

.building-modal-body {
    padding: 24px;
}

.building-modal-footer {
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.btn-close {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    opacity: 1;
    filter: none;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ... keep existing code (building modal content, favorites, help, leaflet styles, etc.) */
.building-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.building-image:hover {
    transform: scale(1.02);
}

/* Modal image container for better responsiveness */
.modal-body .row .col-12 {
    overflow: hidden;
    border-radius: var(--radius-md);
}

.building-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.detail-group h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-group h6 i {
    color: var(--primary-color);
}

.detail-group p {
    color: var(--text-secondary);
    margin: 0;
}

.amenities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.amenity-item {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.favorites-grid {
    display: grid;
    gap: 16px;
}

.favorite-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.favorite-item:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
}

.favorite-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.favorite-info {
    flex: 1;
}

.favorite-info h6 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-weight: 600;
}

.favorite-info p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.remove-favorite {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.remove-favorite:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.help-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.help-section h6 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-section h6 i {
    color: var(--primary-color);
}

.help-section p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

/* ... keep existing code (leaflet styles, custom markers, responsive design, etc.) */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.leaflet-popup-content {
    margin: 16px;
    line-height: 1.5;
}

.popup-content h6 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-weight: 600;
}

.popup-content p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.popup-content button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.popup-content button:hover {
    background: var(--primary-dark);
}

.custom-marker { 
    position: absolute; 
    transform: translate(-50%, -100%); 
    text-align: center; 
    cursor: pointer; 
    z-index: 1000;
}

.custom-marker .marker-icon {
    width: 50px; 
    height: 50px; 
    border-radius: 50%;
    background: #ffffff; 
    border: 2px solid #0d6efd;
    display: flex; 
    align-items: center; 
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    overflow: hidden;
}

.custom-marker .marker-icon img { 
    width: 40px; 
    height: 40px; 
    object-fit: contain; 
    border-radius: 50%;
}

.custom-marker .marker-icon .fallback { 
    font-weight: 600; 
    color: #0d6efd; 
    font-size: 14px; 
}

.custom-marker .marker-name {
    margin-top: 4px; 
    padding: 2px 6px; 
    background: rgba(255,255,255,0.95);
    border: 1px solid #e5e5e5; 
    border-radius: 4px; 
    color: #202124; 
    font-size: 12px; 
    white-space: nowrap;
    font-weight: 500;
}

.custom-marker:hover .marker-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.custom-marker.selected .marker-icon {
    background: #0d6efd;
    border-color: #0d6efd;
    transform: scale(1.2);
}

.custom-marker.selected .marker-icon .fallback {
    color: white;
}

@keyframes marker-pop { 
    0%{ transform: scale(1);} 
    40%{ transform: scale(1.25);} 
    100%{ transform: scale(1);} 
}

.custom-marker .marker-icon.bounce { 
    animation: marker-pop 0.6s ease; 
}

/* Search highlight animation */
@keyframes search-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}

.custom-marker.search-highlight .marker-icon {
    animation: search-pulse 1s ease-in-out infinite;
    border-color: #ffc107;
    background: #fff3cd;
    z-index: 1001;
}

.custom-marker.search-highlight .marker-name {
    background: rgba(255, 193, 7, 0.95);
    color: #856404;
    border-color: #ffc107;
    font-weight: 600;
    z-index: 1001;
}

.user-location-marker {
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(37, 99, 235, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* ... keep existing code (responsive design and utility classes) */
@media (max-width: 991.98px) {
    .main-container {
        padding-bottom: 70px;
    }
    
    .sidebar-panel {
        position: fixed;
        top: 80px;
        left: -100%;
        width: 100%;
        max-width: 380px;
        height: calc(100vh - 80px);
        z-index: 1040;
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar-panel.show {
        left: 0;
    }
    
    .app-layout {
        height: calc(100vh - 150px);
    }
    
    .route-info-panel {
        bottom: 80px;
    }
}

@media (max-width: 575.98px) {
    .sidebar-content {
        padding: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .building-details {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .amenities-grid {
        grid-template-columns: 1fr;
    }
    
    .route-buttons {
        flex-direction: column;
    }
    
    .map-controls {
        top: 12px;
        right: 12px;
    }
    
    .route-info-panel {
        left: 12px;
        right: 12px;
        bottom: 80px;
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }

.sidebar-content::-webkit-scrollbar,
.buildings-list::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.buildings-list::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb,
.buildings-list::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.buildings-list::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
