html, body { 
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    }

   /* Loading message style */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Dark background */
    z-index: 2000; /* Highest priority to cover map and navbar */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    backdrop-filter: blur(5px); /* Nice blurry effect */
}

#txt-loading-msg {
    margin-top: 20px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: normal;
    font-size: 18px;
    line-height: 1.5;
    white-space: pre-line;
}

    /* The Loading Spinner style */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3); /* Light grey ring */
    border-radius: 50%;
    border-top: 5px solid #3498db; /* Blue spinner */
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
    
    /* Top fuction bar style */
#navbar {
    height: 50px;
    background-color: #2c3e50;
    display: flex;
    align-items: center;
    padding: 0 20px;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: relative;
    justify-content: space-between; /* Pushes content to edges */
    z-index: 3000;
}
    
.nav-title {
    font-weight: bold;
    font-size: 18px;
}

.nav-buttons {
    display: flex;
    gap: 10px;
}

.lang-btn {
    height: 40px;
    width: 75px;
    background-color: #34495e;
    color: white;
    border: 1px solid #7f8c8d;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.lang-btn:hover { 
    background-color: #1abc9c; 
    border-color: #1abc9c; 
}

    /* Warning button style */
#warning-btn {
    display: none; /* Hidden by default */
    position: absolute;
    top: 65px;  /* Aligned with the Info box */
    left: 365px; /* Top Left side */
    z-index: 1000;
    background-color: #e74c3c;
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 10%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    
    /* Button specific resets (Critical for <button> tags) */
    border: none;         /* Removes the default gray border */
    padding: 0;           /* Removes default padding */
    cursor: pointer;
    
    /* Animation & Centering */
    line-height: 1;
    justify-content: center;
    align-items: center;
    
    
    animation: pulse 2s infinite;
}

    /* A hover effect */
#warning-btn:hover {
    background-color: #c0392b; /* Slightly darker red on hover */
}


    /* Simple flashing animation */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

    /* Map style */
#map { 
    height: calc(100vh - 50px);
    width: 100%;
    z-index: 1;
    }

    /* General Info Widget style */
#info {
    position: absolute;  /* Floats on top of other things */
    top: 65px;           /* Distance from top */
    right: 20px;         /* Distance from right */
    z-index: 1000;       /* Ensures it sits ON TOP of the map layers */
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 220px;
}

 #info h2 {
    margin-top: 0;
    font-size: 16px;
    color: #333;
}

#current-time {
    font-weight: bold;
    color: #0056b3;
}

/* Bus Marker Style */
.bus-marker-container {
    position: relative;
    width: 30px;
    height: 30px;
    
}


.bus-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    background-color: #3498db; 
    border: 2px solid white;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    font-family: 'Segoe UI', sans-serif;
    
    z-index: 10; 
}


.arrow-orbit {
    position: absolute;
    top: 15px; 
    left: 15px;
    
    width: 0;
    height: 0;
    z-index: 5; 
}


.bus-arrow {
    position: absolute;
    
    top: -35px; 
    left: -7px; 
    
    width: 0; 
    height: 0; 
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid #3498db; 
    filter: drop-shadow(0 0 2px white);
}

#locate-btn {
    position: absolute;
    bottom: 30px;
    right: 20px;
    z-index: 1000;
    
    width: 50px;
    height: 50px;
    background-color: white;
    color: #333;
    
    border: none;
    border-radius: 10%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    
    color: #444; 

}

#locate-btn:hover {
    background-color: #f0f0f0;
}

#locate-btn:active {
    background-color: #e0e0e0;
    transform: translateY(1px);
}

/* SEARCH WIDGET (Google Maps Style) */
#search-container {
    position: absolute;
    top: 65px;          /* Below the 50px Navbar + padding */
    left: 55px;
    width: 300px;       /* Good width for desktop and mobile */
    max-width: calc(100vw - 75px); /* Responsive max width */
    z-index: 1500;      /* Above map, below overlay */
    font-family: 'Segoe UI', sans-serif;
}

.search-box {
    background: white;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

.search-icon {
    margin-right: 10px;
    color: #7f8c8d;
}

#route-search {
    border: none;
    outline: none;
    font-size: 16px;
    width: 100%;
    height: 100%;
    color: #333;
    background: transparent; /* Ensures no white background glitch */
    
    margin: 0;
    padding: 0;
}

#clear-search {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
}
#clear-search:hover { color: #333; }

/* The Dropdown List */
#route-list {
    background: white;
    margin-top: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    max-height: 300px;  /* Scroll if too many routes */
    overflow-y: auto;
    display: none;      /* Hidden by default */
    padding: 5px 0;
}

/* When the list is active (added by JS) */
#route-list.active {
    display: block;
}

/* Individual Route Item */
.route-item {
    padding: 12px 15px;      /* Slightly more breathing room */
    display: flex;           /* Flexbox aligns everything in a row */
    align-items: center;     /* Critical: Vertically centers items perfectly */
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #eee;
}

.route-info {
    display: flex;
    flex-direction: column; /* Stack number and name */
    margin-left: 10px;
}

.route-number {
    font-size: 16px;
    color: #333;
}

.route-desc {
    font-size: 12px;
    color: #666; /* Grey text for the name */
}

.route-item:hover {
    background-color: #f5f5f5;
}

.route-item:last-child {
    border-bottom: none;
}

.route-checkbox {
    /* Alignment & Spacing */
    margin: 0 15px 0 0;      /* Reset browser default margins, add space to right */
    
    /* Size: Force it to be bigger to match the star */
    width: 20px;             
    height: 20px;            
    
    cursor: pointer;
    accent-color: #3498db;   /* Blue checkmark color */
    
    flex-shrink: 0;          /* Prevents checkbox from squishing */
}

.route-name {
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

/* Star (Favorite) Button */
.star-btn {
    font-size: 26px;         /* Big and visible */
    color: #ccc;
    cursor: pointer;
    
    /* Alignment Fixes */
    margin-right: 12px;
    margin-bottom: 3px;    /* Slight nudge down for optical centering */      
    line-height: 1;          /* Removes extra vertical space around the character */
    display: flex;           /* Helps center the character inside its own box */
    align-items: center;     /* Vertically center the star icon */
    flex-shrink: 0;          /* Prevents star from squishing on small screens */
    
    transition: transform 0.1s ease-in-out;
    user-select: none;
}

/* When active (favorited) */
.star-btn.active {
    color: #f1c40f;        /* Gold color */
}

/* Little pop animation on click */
.star-btn:active {
    transform: scale(1.2) translateY(1px); /* Keep the nudge during animation */
}

/* =========================================
   MOBILE RESPONSIVE MODE (Phones & Tablets)
   ========================================= */
@media (max-width: 768px) {

    /* 1. NAVBAR: Squeeze content to fit */
    #navbar {
        padding: 0 10px; /* Less padding on edges */
    }
    .nav-title {
        font-size: 15px; /* Slightly smaller title */
    }
    .nav-buttons {
        gap: 5px; /* Tighter gap between buttons */
    }
    .lang-btn {
        width: 50px;       /* Let width adjust to text (EN/FR/中文) */
        font-size: 14px;

        display: inline-flex;
        justify-content: center;
        align-items: center;
    }

    /* 2. SEARCH BAR: Fluid Width (Critical Fix) */
    /* On mobile, 300px is too wide. We make it fill the available space. */
    #search-container {
        left: 55px;                /* Keep space for Zoom (+/-) buttons */
        width: calc(100% - 75px);  /* Fill screen width minus margins */
        max-width: none;           /* Remove desktop width limit */
    }

    /* 3. LOCATE BUTTON: Bigger Thumb Target */
    #locate-btn {
        width: 60px;
        height: 60px;
        bottom: 25px;
        right: 15px;
    }

    /* 4. WARNING BUTTON: The "Stack" Strategy */
    /* On desktop, this is top-left. On mobile, that's crowded. */
    /* We move it to Bottom Right, floating ABOVE the Locate button. */
    #warning-btn {
        top: auto;       /* Reset Top */
        left: auto;      /* Reset Left */
        
        right: 15px;     /* Align with Locate Button */
        bottom: 95px;    /* 25px (bottom) + 60px (locate btn) + 10px (gap) */
        
        width: 60px;     /* Bigger touch target */
        height: 60px;
    }

    /* 5. INFO WIDGET: Move to Bottom Left */
    /* Top-Right is too crowded on mobile. We move it to bottom-left. */
    #info {
        top: auto;      /* Reset Top */
        right: auto;    /* Reset Right */
        
        bottom: 25px;   /* Align with other buttons */
        left: 15px;     /* Bottom Left Corner */
        
        width: auto;    /* Shrink to fit content */
        max-width: 140px; /* Prevent it from hitting the Locate button */
        padding: 10px;
        text-align: left;
    }

    /* Hide the "Welcome" text to save precious screen space */
    #txt-welcome {
        display: none;
    }

    /* Make the time label smaller and cleaner */
    #info p {
        margin: 0;
        line-height: 1.2;
        font-size: 13px;
    }
    
    #current-time {
        display: block; /* Force time to new line */
        font-size: 16px; /* Keep the time readable */
        margin-top: 2px;
    }

    /* --- PERFORMANCE BOOSTERS --- */
    
    /* 1. Kill the shadows (Expensive to render) */
    .bus-box {
        box-shadow: none !important;
    }
    
    /* 2. Kill the arrow filter (VERY Expensive) */
    .bus-arrow {
        filter: none !important; 
    }

    /* 3. Hardware Acceleration Hint */
    /* This tells the phone's Graphics Card (GPU) to handle the map movement */
    .leaflet-marker-icon, 
    .leaflet-marker-shadow, 
    .leaflet-pane, 
    .leaflet-tile-container {
        will-change: transform;
    }
}
