/* --- LAYOUT STRUCTURE --- */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    /* Full viewport height */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    /* Prevent body scroll bar */
}

body {
    display: flex;
    /* Enable Flexbox */
    flex-direction: column;
    /* Stack children vertically */
    background-color: #f4f4f4;
}

/* 1. HEADER (Fixed height or auto) */
#navbar {
    flex: 0 0 60px;
    /* Don't grow, don't shrink, 60px height for modern look */
    background: linear-gradient(135deg, #002139 0%, #003355 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 10;
    position: relative;
}

/* 2. INJECTION AREA */
#top-content-area {
    flex: 0 0 auto;
    /* Grows based on content height */
    background: #fff;
    /* If this is empty, it takes 0 height. 
       If you add a banner here, it pushes the map down automatically. */
}

/* Example style if you insert an alert div */
.alert-banner {
    background-color: #ffcc00;
    color: #333;
    padding: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 1px solid #e0b800;
}

/* 3. MAIN (MAP CONTAINER) */
main#map-container {
    flex: 1;
    /* Grow to fill ALL remaining space */
    position: relative;
    /* Context for absolute children (popups) */
    display: flex;
    /* Ensure map fills this container */
    width: 100%;
}

#map {
    width: 100%;
    height: 100%;
    /* Fill the main container */
    z-index: 1;
}

/* --- NAVIGATION STYLES --- */
.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-left {
    flex-shrink: 1;
    min-width: 0;
}

.brand-title {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

@media (max-width: 600px) {
    .brand-title {
        display: none;
    }
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    position: relative;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background-color: rgba(247, 206, 54, 0.3);
    transform: translateY(-1px);
}

.nav-btn.text-btn {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 14px;
}

/* --- SEARCH BAR --- */
.nav-center {
    flex: 1;
    max-width: 500px;
    margin: 0 15px;
    min-width: 0;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

#searchBox {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

#searchBox:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

#searchBox::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#searchClear {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
}

/* Dropdown override */
#results {
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

/* --- MAP OVERLAYS (Buttons, Popups) --- */
.custom-zoom-controls {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.custom-zoom-controls button {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.custom-zoom-controls button:hover {
    background: #f0f0f0;
}

#custom-popup {
    position: fixed;
    z-index: 1;
    display: none;
    transform: translate(-50%, calc(-100% - -110px));
    font-size: 14px;
}

/* --- POPUP CARD STYLES --- */
.bus-info-card .card-header {
    background: #f8f9fa;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bus-info-card .card-body {
    padding: 15px;
}

.bus-info-card h2 {
    margin: 0 0 10px 0;
    font-size: 16px;
    line-height: 1.3;
}

.bus-info-card .status-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 600;
}

.bus-info-card .card-actions {
    padding: 10px 15px;
    border-top: 1px solid #eee;
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 5px;
}

.btn {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #0078d7;
    color: white;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

/* --- FILTER DIALOG --- */
#filter-dialog {
    position: fixed;
    top: 70px;
    left: 20px;
    width: 320px;
    max-height: calc(100vh - 90px);
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    z-index: 6000;
    display: flex;
    flex-direction: column;
}

/* Mobile Filter Responsive */
@media (max-width: 480px) {
    #filter-dialog {
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        max-height: none;
        border-radius: 0;
    }
}


.st-fab {
    position: fixed !important;
    top: calc(50% - 25px) !important;
    left: 5px !important;
    width: 45px;
    height: 45px;
    background: #fff;
    color: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1;
    transition: transform 0.2s;
    scale: 0.8;
}

.filter-header {
    padding: 15px;
    background: linear-gradient(135deg, #002139 0%, #003355 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
}

.filter-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: #f4f4f4;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: #666;
}

.tab-btn.is-active {
    background: white;
    color: #002139;
    border-bottom: 3px solid #002139;
}

.filter-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

#ftr-search-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    height: calc(60vh - 108px - 80px);
}

.agency-item {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.filter-footer {
    padding: 15px;
    border-top: 1px solid #ddd;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.action-btn.primary {
    background: #d9534f;
    color: white;
}

.action-btn.secondary {
    background: #5bc0de;
    color: white;
}

.badge {
    background: #d9534f;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    position: absolute;
    top: 2px;
    right: 2px;
}

/* --- SUMMARY MODAL --- */
#current-filter-modal,
#help-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 7000;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
}

.ftr-summary-item {
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}


/* bus infomation card */
.bus-info-card {
    width: 300px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    border: 1px solid #ddd;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.bus-info-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #f7f7f7;
    border-bottom: 1px solid #eee;
}

.bus-info-card .bus-id {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.bus-info-card .bus-number {
    font-size: 24px;
    font-weight: bold;
    color: #002139;
}

.bus-info-card .fleet-number {
    font-size: 16px;
    color: #777;
}

.bus-info-card .header-icons {
    display: flex;
    gap: 15px;
    font-size: 16px;
    color: #666;
}

.bus-info-card .header-icons .favorite-star,
.bus-info-card .card-body .favorite-star {
    cursor: pointer;
    color: #a0a0a0;
    /* Default color for non-favorite */
}

.bus-info-card .header-icons .favorite-star.is-favorite,
.bus-info-card .card-body .favorite-star.is-favorite {
    color: #f39c12;
    /* Gold color for favorite */
}

.bus-info-card .card-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bus-info-card .card-body h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.4;
    color: #1a202c;
    letter-spacing: -0.01em;
}

.bus-info-card .status-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bus-info-card .on-time-status {
    font-size: 14px;
    font-weight: bold;
    color: #e67e22;
    /* Default color, can be changed by JS */
}

.bus-info-card .speed {
    font-size: 12px;
    color: #555;
    padding-left: 10px;
    border-left: 1px solid #ccc;
}

.bus-info-card .details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: #333;
}

.bus-info-card .details-list .detail-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bus-info-card .details-list .detail-item i {
    width: 16px;
    text-align: center;
    color: #555;
}

.bus-info-card .last-updated {
    font-size: 13px;
    color: #777;
    margin-top: 5px;
}

.bus-info-card .card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-top: 1px solid #eee;
    background-color: #fdfdfd;
}

.bus-info-card .action-buttons {
    display: flex;
    gap: 8px;
}

.bus-info-card .btn {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    border: 1px solid transparent;
    line-height: 1.2;
}

.bus-info-card .btn-primary {
    background-color: #002139;
    color: white;
}

.bus-info-card .btn-secondary {
    background-color: #a85c00;
    color: white;
}

.bus-info-card .btn-icon {
    background-color: #fff;
    color: #d32f2f;
    font-size: 16px;
    cursor: pointer;
    border: 1px solid #ddd;
    padding: 1px 2px;
    border-radius: 6px;
}

.controls-container {
    position: absolute;
    left: 65px;
    /* top: 80px; */
    display: flex;
    /* flex-direction: column; */
    gap: 8px;
    z-index: 4;
    pointer-events: auto;
    /* width: 90vw; */
    flex-wrap: wrap;
    padding: 15px;
}

#topborder {
    /* position: fixed; */
    top: 81px;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #0f172a 0%, #656c69 200%);
    color: white;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    /* opacity: 0.95; */
    padding: 8px 3px;
    /* background-image: linear-gradient(to bottom, #002139, #003d5c); */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    height: 20px;
}

#filter-count {
    font-weight: 700;
    position: absolute;
    top: 0px;
    right: 0px;
    background-color: #ff1a1a;
    padding: 2px 4px;
    border-radius: 6px;
    font-size: 11px;
    font-family: sans-serif;
    display: none;
    pointer-events: none;
    z-index: 10;
    line-height: 1;
}

/* === ACTION RAIL (From Railview2026) === */
.action-rail {
    top: 55px;
    left: 0;
    right: 0;
    width: 100%;
    height: 50px;
    display: flex;
    flex-direction: row;
    gap: 0;
    border-radius: 0;
    padding: 0;
    z-index: 2;
    background: #0f172a;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    justify-content: center;
}

.rail-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    height: 100%;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    padding: 0 15px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.rail-btn:last-child {
    border-right: none;
}

.rail-btn i {
    font-size: 1.2rem;
}

.rail-label {
    font-size: 0.75rem;
    font-weight: 500;
}

.rail-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.rail-btn.active {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 -3px 0 #f7ce36;
}


/* Hamburger Menu Button */
#siderbar-checkbox {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

#siderbar-checkbox:hover {
    background-color: rgba(247, 206, 54, 0.3);
    transform: translateY(-1px);
}

/* KO Menu Styles */
#ko-menu-trigger {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2000;
    background: #002139;
    color: white;
    border: none;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
}

.ko-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .5);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease
}

.ko-menu-overlay.active {
    opacity: 1;
    visibility: visible
}

.ko-menu-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 80vw;
    height: 100%;
    background: #002139;
    color: white;
    z-index: 2002;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, .3);
    font-family: 'Inter', sans-serif
}

.ko-menu-container.active {
    transform: translateX(0)
}

.ko-menu-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    background: #001a2d
}

.ko-menu-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: #f7ce36
}

.ko-menu-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1
}

.ko-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0
}

.ko-menu-list,
.ko-menu-submenu {
    list-style: none;
    padding: 0;
    margin: 0
}

.ko-menu-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    color: #e0e0e0;
    text-decoration: none;
    font-size: .95rem;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    transition: background .2s
}

.ko-menu-list li a:hover {
    background: rgba(255, 255, 255, .05);
    color: white
}

.ko-menu-submenu {
    background: rgba(0, 0, 0, .2);
    display: none
}

.ko-menu-submenu.open {
    display: block
}

.ko-menu-submenu li a {
    padding-left: 35px;
    font-size: .9rem;
    color: #ccc
}

.ko-menu-submenu .ko-menu-submenu li a {
    padding-left: 50px
}

.ko-menu-arrow {
    font-size: .8em;
    transition: transform .3s
}

.ko-menu-item-has-children>a[aria-expanded="true"] .ko-menu-arrow {
    transform: rotate(180deg)
}


.app-logo {
    z-index: 15;
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
    color: white;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    transition: opacity 0.2s;
}

.app-logo:hover {
    opacity: 0.9;
}

.app-logo span {
    color: #f7ce36;
    font-weight: 800;
}

/* Hide logo text on very small screens */
@media (max-width: 640px) {
    .app-logo {
        display: none;
    }

    .nav-left {
        gap: 5px;
        flex-shrink: 1;
    }

    .nav-right {
        gap: 5px;
        flex-shrink: 0;
    }

    .nav-btn {
        padding: 6px 8px;
        font-size: 1.1rem;
    }

    #navbar {
        padding: 0 8px;
    }

    .nav-center {
        margin: 0 6px;
        max-width: calc(100% - 120px);
        flex-shrink: 1;
    }

    #searchBox {
        padding: 8px 0px;
        font-size: 13px;
    }
}

/* Even smaller screens - further compact */
@media (max-width: 480px) {
    .nav-left {
        gap: 2px;
    }

    .nav-right {
        gap: 2px;
    }


    #navbar {
        padding: 0 15px;
    }

    .nav-center {
        margin: 0 4px;
        max-width: calc(100% - 140px);
    }

    #searchBox {
        padding: 0px 0px;
        font-size: 1.7em;
    }
}

/* === ACTION RAIL MOBILE RESPONSIVE === */
/* Action rail is already horizontal, no mobile overrides needed */

@media (min-width: 768px) {
    .app-logo {
        display: flex;
    }
}


#siderbar-checkbox {

    background-color: #1a3c54;
    color: #ffffff;
    border: 0px;
    /* width: 15px; */


}


/* GPS Button */
.gps-fab {
    position: fixed !important;
    top: calc(50% + 125px) !important;
    left: 5px !important;
    width: 45px;
    height: 45px;
    background: #fff;
    color: #333;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 1;
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
    scale: 0.8;
}

.gps-fab:hover {
    background-color: #f0f0f0;
}

.gps-fab.active {
    color: #0078d7;
    /* Active color */
}

/* Professional GPS Marker */
.gps-marker-container {
    background: transparent;
    border: none;
}

.gps-marker-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 40px;
    height: 40px;
}

.gps-core {
    width: 18px;
    /* Slightly larger for visibility */
    height: 18px;
    background-color: #2979FF;
    /* Vibrant Google-like Blue */
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.gps-pulse {
    position: absolute;
    width: 50px;
    /* Larger pulse area */
    height: 50px;
    background-color: rgba(41, 121, 255, 0.4);
    border-radius: 50%;
    z-index: 1;
    animation: gps-pulse 2s infinite ease-out;
}

@keyframes gps-pulse {
    0% {
        transform: scale(0.4);
        opacity: 0.7;
    }

    70% {
        opacity: 0.1;
    }

    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

/* --- OFF-SCREEN VEHICLE TRACKING INDICATOR --- */
#offscreen-indicator {
    position: fixed;
    z-index: 10000;
    cursor: pointer;
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 6px;
}

.offscreen-arrow {
    background: rgba(0, 33, 57, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.offscreen-arrow:hover {
    background: rgba(0, 33, 57, 1);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.offscreen-arrow .arrow-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.offscreen-arrow .arrow-icon {
    font-size: 18px;
    font-weight: bold;
}

.offscreen-arrow .vehicle-info {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 600;
}


/* Add this to your CSS file or <style> block */
.trip-time-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.trip-time-tooltip::before {
    display: none !important; /* Hides the default tooltip arrow */
}

/* Optional: Ensure the text inside looks like your old labels */
.time-label-content {
    font-size: 11px;
    color: #ffffff;
    padding: 1px 1px;
    border-radius: 4px;
    white-space: nowrap;
    border: 2px solid; 
    text-align: center;
    font-weight: bold;
    text-shadow: 0px 0px 2px #000;
}