/* Truck Map Viewer CSS - Matching Property Map Aesthetic */

/* Base Styles */
body {
    margin: 0;
    padding: 0;
}

.truck-map-container {
    font-family: 'Trebuchet MS', 'Helvetica', 'Arial', sans-serif;
    background: #eee;
    color: #333;
    margin: 0;
    padding: 0;
    height: 100%;
}

/* Grid Layout for Map + List View */
.map-view-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    grid-template-rows: 40px 1fr;
    grid-template-areas:
        "header header"
        "stops-list map-area";
    height: 100vh;
    overflow: hidden;
}

/* Header Bar */
.map-header {
    grid-area: header;
    background: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid #ccc;
    padding: 6px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.map-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.date-display {
    font-size: 14px;
    color: #666;
}

/* Stop Filter Toggle */
.stop-filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 28px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f0f0f0;
    border-radius: 14px;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #ddd;
}

.toggle-icon {
    width: 18px;
    height: 18px;
    transition: opacity 0.3s;
}

.toggle-icons {
    display: flex;
    align-items: center;
    gap: -4px;
    opacity: 0;
    transition: opacity 0.3s;
}

.toggle-icon-red {
    width: 16px;
    height: 16px;
    z-index: 2;
}

.toggle-icon-green {
    width: 16px;
    height: 16px;
    margin-left: -6px;
}

.unauthorized-only {
    opacity: 1;
}

/* When checked (showing all stops) */
.toggle-label input:checked + .toggle-slider {
    background-color: #e8f5e9;
}

.toggle-label input:checked + .toggle-slider .unauthorized-only {
    opacity: 0;
}

.toggle-label input:checked + .toggle-slider .all-stops {
    opacity: 1;
}

/* Stops List */
.stops-list {
    grid-area: stops-list;
    background: #f4f4f4;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 0;
}

#unauthorizedStopsList {
    width: 100%;
}

/* Stop List Table */
.stopsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.stopsTable thead {
    background: #333;
    color: white;
    position: sticky;
    top: 0;
    z-index: 999;
}

.stopsTable th {
    padding: 8px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

.stopsTable th:first-child {
    padding-left: 12px; /* Match the td padding */
}

.stopsTable td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

.stopsTable td:first-child {
    padding-left: 12px; /* Space for the 8px colored bar + 4px gap */
}

.stopsTable tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.stopsTable tbody tr td:first-child {
    position: relative;
}

.stopsTable tbody tr td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: -1px;
    bottom: -1px;
    width: 8px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.stopsTable tbody tr.unauthorized td:first-child::before {
    background-color: #f44336;
}

.stopsTable tbody tr.authorized td:first-child::before {
    background-color: #4CAF50;
}

.stopsTable tbody tr:hover {
    background: linear-gradient(90deg, #e8f5e9 0%, #e8f5e9 25%, white 25%);
    transform: translateX(2px);
}

.stopsTable tbody tr.selected.authorized {
    background-color: #2aad49 !important;
    color: white;
}

.stopsTable tbody tr.selected.unauthorized {
    background-color: #d32f2f !important;
    color: white;
}

.stopsTable tbody tr.selected:hover {
    background-image: none !important;
    transform: translateX(2px);
}

.stopsTable tbody tr.selected td {
    color: white;
}

.stopsTable tbody tr.highlighted-stop {
    background-color: #fff3cd;
    border-left: 3px solid #ffc107;
}

/* Duration Color Bands - full width subtle backgrounds */
.stopsTable tbody tr.duration-band-1 {
    background-color: rgba(76, 175, 80, 0.05);
}

.stopsTable tbody tr.duration-band-2 {
    background-color: rgba(255, 193, 7, 0.08);
}

.stopsTable tbody tr.duration-band-3 {
    background-color: rgba(255, 152, 0, 0.1);
}

.stopsTable tbody tr.duration-band-4 {
    background-color: rgba(244, 67, 54, 0.1);
}

/* Maintain hover state for duration bands (but not selected rows) */
.stopsTable tbody tr.duration-band-1:not(.selected):hover,
.stopsTable tbody tr.duration-band-2:not(.selected):hover,
.stopsTable tbody tr.duration-band-3:not(.selected):hover,
.stopsTable tbody tr.duration-band-4:not(.selected):hover {
    background: linear-gradient(90deg, #e8f5e9 0%, #e8f5e9 35%, transparent 35%);
}

/* Map Area */
#mapContainer {
    grid-area: map-area;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Custom Zoom Control */
.custom-zoom-out {
    background-color: white;
    border: none;
    border-radius: 2px;
    box-shadow: 0 1px 4px -1px rgba(0,0,0,.3);
    cursor: pointer;
    margin: 10px;
    text-align: center;
    padding: 8px 12px;
    color: #666;
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.custom-zoom-out:hover {
    background-color: #f5f5f5;
    box-shadow: 0 1px 4px rgba(0,0,0,.5);
    color: #333;
}

/* Truck Markers */
.truck-marker {
    position: relative;
    cursor: pointer;
    z-index: 2000 !important;
}

.truck-icon {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.2s ease;
}

.truck-marker:hover .truck-icon {
    transform: scale(1.1);
}

.marker-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff5252;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.marker-badge.authorized {
    background: #4CAF50;
}

/* Stop Popup Styles */
.stop-popup {
    min-width: 200px;
    max-width: 300px;
    font-size: 13px;
}

/* Hide Google Maps InfoWindow close button */
.gm-style-iw-c button,
.gm-style-iw-t button,
.gm-ui-hover-effect[aria-label="Close"] {
    display: none !important;
}

/* Ensure truck info windows are above property info windows */
.gm-style-iw {
    z-index: 2001 !important;
}

.stop-popup h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 15px;
    font-weight: 600;
}

.stop-time {
    color: #666;
    font-size: 12px;
    margin-bottom: 6px;
}

.stop-duration {
    font-weight: 600;
    margin-bottom: 8px;
}

.stop-duration.auth {
    color: #4CAF50;
}

.stop-duration.unauth {
    color: #f44336;
}

.stop-property {
    color: #555;
    font-size: 12px;
    margin-top: 6px;
    font-style: italic;
}

.stop-address {
    color: #777;
    font-size: 11px;
    margin-top: 4px;
}

/* Geofence Styles */
.property-geofence {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.property-geofence:hover {
    opacity: 0.8;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* No Data States */
.no-data {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.error {
    padding: 20px;
    background: #ffebee;
    color: #c62828;
    text-align: center;
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .map-view-container {
        grid-template-columns: 1fr;
        grid-template-rows: 50px 200px 1fr;
        grid-template-areas:
            "header"
            "stops-list"
            "map-area";
    }
    
    .stops-list {
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
}

/* Print Styles */
@media print {
    .map-header,
    .custom-zoom-out {
        display: none;
    }
    
    .map-view-container {
        grid-template-columns: 1fr;
        grid-template-areas: "stops-list";
    }
    
    #mapContainer {
        display: none;
    }
}