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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
}

header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

#routesTableHeader {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}


#controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #2980b9;
}

#locationInfo {
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
}

#map-container {
    position: relative;
    height: 500px;
    margin: 1rem;
}

#map {
    height: 100%;
    border-radius: 8px;
    border: 2px solid #ddd;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: 4px;
    z-index: 1000;
}

.hidden {
    display: none !important;
}

.controls-panel {
    background: #ecf0f1;
    padding: 1.5rem;
    margin: 1rem;
    border-radius: 8px;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    border: 2px solid #bdc3c7;
}

.controls-panel h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    width: 100%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 300px;
}

.control-group label {
    font-weight: bold;
    color: #34495e;
}

input[type="range"] {
    width: 150px;
}

input[type="text"] {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 120px;
}

select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 150px;
}

.tables-container {
    margin: 1rem;
}

.table-section {
    margin-bottom: 2rem;
}

.table-section h3 {
    background: #34495e;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px 4px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #f8f9fa;
    font-weight: bold;
}

tbody tr:hover {
    background: #f8f9fa;
}

.remove-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
    transition: background 0.3s;
}

.remove-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* Leaflet marker styles */
.bus-stop-marker {
    background: #27ae60;
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    text-align: center;
    line-height: 20px;
    width: 24px;
    height: 24px;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.bus-stop-marker.selected {
    background: #f39c12;
}

.bus-stop-marker.auto-selectable {
    background: #f39c12;
}

.center-marker {
    z-index: 1000 !important;
}

.user-location-marker {
    z-index: 999 !important;
}

/* Distance control styles */
.distance-control {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #bdc3c7;
    min-width: 200px;
}

.distance-control-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.distance-control label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
    margin: 0;
}

.distance-control .slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.distance-control input[type="range"] {
    flex: 1;
    margin: 0;
    width: 100%;
}

.distance-control #mapDistanceValue {
    font-weight: bold;
    color: #2c3e50;
    min-width: 40px;
    text-align: right;
}

/* Range circle style */
.leaflet-interactive {
    z-index: 400 !important;
}

.leaflet-overlay-pane {
    z-index: 400;
}

.leaflet-marker-pane {
    z-index: 600;
}

.leaflet-popup-pane {
    z-index: 700;
}

.leaflet-control {
    z-index: 800;
}

/* Hide the original distance slider in controls panel */
.control-group:has(#distanceSlider) {
    display: none;
}




.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    flex-direction: column;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

.body-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
/* start of loading page */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-size: 20px;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 2s linear infinite;
    margin-right: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Prevent scrolling and interaction */
body.no-scroll {
    overflow: hidden;
    touch-action: none;
    pointer-events: none;
}

body.no-scroll .loading-overlay {
    pointer-events: auto; /* Allow clicks on loading screen if needed */
}

/* end of loading page */
/* Responsive design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
    }
    
    #controls {
        justify-content: center;
    }
    
    .controls-panel {
        flex-direction: column;
        gap: 1rem;
    }
    
    .control-group {
        justify-content: flex-start;
    }
    
    .control-group {
        min-width: 100%;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    /* Adjust map control for mobile */
    .distance-control {
        min-width: 180px;
        padding: 8px;
    }
    
    .distance-control label {
        font-size: 12px;
    }
    
    .distance-control input[type="range"] {
        width: 100px;
    }
}