:root {
    --primary-color: #007bff;
    --primary-hover: #0069d9;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --dark-text: #212529;
    --light-text: #ffffff;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --panel-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.container-fluid {
    height: 100vh;
    padding: 0;
}

/* Control bar styling */
.control-bar {
    background-color: var(--light-bg);
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
    text-align: center;
}

/* Search input enhancements */
.search-feedback {
    position: relative;
}

.search-feedback .form-control {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.search-feedback .form-control.searching {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.search-feedback .form-control.found {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.search-feedback .form-control.not-found {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Note: Multi-vehicle navigator now integrated into vehicle details panel */

@keyframes slide-down {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Desktop-specific layout adjustments */
@media (min-width: 951px), (pointer: fine) {
    /* Control bar stays at top on desktop */
    .control-bar {
        position: relative !important;
        bottom: auto !important;
        top: auto !important;
        border-top: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        box-shadow: none !important;
    }
    
    /* Note: Multi-vehicle navigation now integrated into vehicle details panel */
    
    /* Ensure map container uses full height on desktop */
    .map-container {
        height: calc(100vh - 60px) !important; /* Desktop control bar height */
    }
}

/* Mobile-specific layout adjustments */
@media (max-width: 950px) and (pointer: coarse) {
    /* Move control bar to bottom on mobile */
    .control-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-bottom: none;
        border-top: 1px solid var(--border-color);
        background-color: var(--panel-bg);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
        padding: 10px;
        z-index: 1100;
    }

    /* When navigator is present, create seamless connection */
    .control-bar.has-navigator {
        border-top: none;
        box-shadow: none;
    }

    .control-bar .row {
        row-gap: 10px;
    }

    .control-bar .row > div {
        margin-bottom: 8px;
    }

    /* Adjust button sizes on mobile */
    .control-bar .btn {
        font-size: 0.9rem;
        padding: 0.4rem 0.75rem;
    }

    /* Note: Multi-vehicle navigation now integrated into vehicle details panel */

    /* Adjust map container for bottom control bar and potential navigator */
    .map-container {
        height: calc(100vh - 120px); /* Account for bottom control bar */
    }
    
    /* Note: Navigator now integrated, no need for special map height */

    /* Responsive layout adjustments */
    .row {
        flex-direction: column;
    }
    
    .col-md-9, .col-md-3, .col-md-4, .col-lg-3 {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }

    .detail-row {
        margin-bottom: 3px;
    }

    .ol-viewport {
        font-size: 90%;
    }

    /* Vehicle details panel mobile styles */
    .vehicle-details-panel {
        font-size: 0.85rem;
        padding: 12px 15px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
        z-index: 1200; /* Ensure it appears above the bottom control bar */
    }

    /* High-resolution mobile devices adjustments */
    @media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 3dppx) {
        .vehicle-details-panel {
            max-width: 280px;
            font-size: 0.85rem;
        }
    }

    /* Loading indicator mobile adjustments */
    .loading-indicator.reconnecting {
        top: auto;
        bottom: 130px; /* Position above the bottom control bar */
        padding: 10px 12px;
        font-size: 0.85em;
        z-index: 1200; /* Ensure it appears above the control bar */
    }
    
    .loading-indicator.reconnecting .loading-spinner {
        width: 20px;
        height: 20px;
    }
}

/* Vehicle details panel - redesigned as a bubble popup */
.vehicle-details-panel {
    position: absolute;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: none;
    text-align: left;
    font-size: 0.9rem;
    height: auto;
    min-width: 200px;
    max-width: 300px;
    padding: 10px 15px;
    animation: bubble-pop 0.3s ease-out;
}

/* Add arrow/pointer to connect bubble to vehicle on desktop */
.vehicle-details-panel::after {
    content: '';
    position: absolute;
    bottom: -10px; /* Position arrow at bottom */
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0; /* Arrow shape */
    border-style: solid;
    border-color: var(--panel-bg) transparent transparent; /* Arrow color matches panel */
    /* Ensure arrow aligns with panel border */
    filter: drop-shadow(0 1px 0 var(--border-color));
}

/* Special mobile panel style that uses absolute positioning relative to vehicle */
.vehicle-details-panel.mobile-panel {
    position: absolute;
    max-width: 90%; /* Maximum width as percentage of screen */
    width: auto;
    z-index: 1200; /* Higher than control bar (1100) to appear on top */
    animation: slide-up 0.3s ease-out;
}

/* Remove arrow for mobile fixed panel */
.vehicle-details-panel.mobile-panel::after {
    display: none;
}

/* Animation for mobile panel appearing above vehicle */
@keyframes slide-up {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Show vehicle details when active */
.vehicle-details-panel.active {
    display: block;
}

/* Integrated navigation styles within vehicle details panel */
.vehicle-nav-header {
    background-color: var(--primary-color);
    color: var(--light-text);
    padding: 8px 12px;
    margin: -10px -15px 10px -15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-controls .btn {
    padding: 2px 6px;
    font-size: 0.9rem;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--light-text);
}

.nav-controls .btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--light-text);
}

.nav-info {
    font-weight: 500;
    margin: 0 8px;
    white-space: nowrap;
}

@keyframes bubble-pop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Desktop specific styles */
@media (min-width: 769px) {
    .vehicle-details-panel {
        min-width: 220px;
        max-width: 400px;
        padding: 10px 15px;
    }
}



/* Details content styling for both mobile and desktop */
.details-content {
    width: 100%;
}

.detail-row {
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-row:last-child {
    margin-bottom: 0;
}

/* Map container */
.map-container {
    height: calc(100vh - 60px); /* Adjust based on control bar height only */
    width: 100%;
}

.row {
    height: 100%;
    margin: 0;
}



/* Vehicle and Route dropdowns */
.vehicle-dropdown .dropdown-menu,
.route-dropdown .dropdown-menu {
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: var(--light-text);
}

/* Route dropdown specific styling */
.route-dropdown .btn {
    background-color: #28a745;
    border-color: #28a745;
}

.route-dropdown .btn:hover,
.route-dropdown .btn:focus,
.route-dropdown .btn:active {
    background-color: #218838;
    border-color: #1e7e34;
}

.route-item {
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.route-item:hover {
    background-color: var(--light-bg);
}

.route-item.active {
    background-color: #28a745;
    color: var(--light-text);
}

/* Show vehicle details when active */
.vehicle-details-panel.active {
    display: block !important;
}

.kml-upload {
    width: 100%;
}

.kml-upload form {
    width: 100%;
}

/* Add loading indicator styles */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    text-align: center;
    min-width: 220px;
}

.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    width: 36px;
    height: 36px;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-weight: 500;
    color: var(--dark-text);
}

.loading-progress {
    font-weight: bold;
    color: var(--primary-color);
}

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

/* Add styles for reconnection state */
.loading-indicator.reconnecting {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 12px 16px;
    top: 70px;  /* Position below control bar instead of center */
    left: 50%;
    transform: translateX(-50%);
    border-radius: 4px;
    min-width: unset;
    width: auto;
    max-width: 80%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    z-index: 500;
}

.loading-indicator.reconnecting .loading-spinner {
    width: 24px;
    height: 24px;
    margin: 0 8px 0 0;
    display: inline-block;
    vertical-align: middle;
}

.loading-indicator.reconnecting .loading-text {
    display: inline-block;
    vertical-align: middle;
    margin: 0;
    font-size: 0.85em;
}





