/* Main Layout */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Road Info */
.road-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #fff;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 300px;
    display: none;
}

/* Route Planning Sidebar */
.route-sidebar {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 350px;
    background-color: #fff;
    border-radius: 4px;
    padding: 15px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
}

.route-input-group {
    margin-bottom: 15px;
}

.route-input-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.route-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.route-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #007bff;
    color: #fff;
    cursor: pointer;
}

.route-actions button:hover {
    background-color: #0069d9;
}

.route-actions #clear-route-btn {
    background-color: #6c757d;
}

.route-actions #clear-route-btn:hover {
    background-color: #5a6268;
}

.route-details {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.route-details .error {
    color: #dc3545;
}

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background-color: #fff;
    border-radius: 4px;
    padding: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.loading-indicator {
    display: none;
    margin-left: 10px;
    font-style: italic;
    color: #6c757d;
}

/* Autocomplete */
.autocomplete-results {
    position: absolute;
    background: white;
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1001;
    display: none;
}

.result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

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

.loading-item, .error-item, .no-results {
    padding: 8px 12px;
    color: #6c757d;
    font-style: italic;
}

.error-item {
    color: #dc3545;
}

/* Booking Section */
.booking-section, .my-bookings-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.bookable-segments, .user-bookings {
    margin-top: 10px;
}

.segment-list, .booking-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.segment-item, .booking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #007bff;
}

.segment-details, .booking-info {
    display: flex;
    flex-direction: column;
}

.segment-details strong, .booking-info strong {
    font-size: 14px;
    margin-bottom: 2px;
}

.segment-details span, .booking-info span {
    font-size: 12px;
    color: #6c757d;
}

.book-segment-btn {
    background-color: #28a745;
    border-color: #28a745;
}

.book-segment-btn:hover {
    background-color: #218838;
    border-color: #1e7e34;
}

.cancel-booking-btn {
    background-color: #dc3545;
    border-color: #dc3545;
}

.cancel-booking-btn:hover {
    background-color: #c82333;
    border-color: #bd2130;
}

.no-segments, .no-bookings, .loading-bookings, .error {
    font-style: italic;
    color: #6c757d;
    text-align: center;
    padding: 10px;
}

.error {
    color: #dc3545;
}

/* Highlight styles */
.highlighted-road {
    stroke-dasharray: 5, 5;
    animation: dash 10s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: 1000;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .route-sidebar {
        width: 90%;
        max-width: 350px;
        max-height: 50vh;
    }

    .road-info {
        max-width: 80%;
    }
}

/* Time slot selection styles */
.date-navigation {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 10px;
}

.slots-scroll-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.slot-buttons {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .slot-buttons {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 576px) {
    .slot-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

.slot-btn {
    font-size: 0.85rem;
    padding: 6px 8px;
    margin-bottom: 5px;
    position: relative;
    z-index: 10; /* Higher than modal backdrop */
    pointer-events: auto; /* Ensure clicks are captured */
}

.slot-btn.selected {
    position: relative;
}

.slot-btn.selected::after {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Booking list styles - improved version */
.booking-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: scroll; /* Changed from auto to scroll to ensure visibility */
    overflow-x: hidden;
    width: 100%;
    scrollbar-width: thin; /* For Firefox */
    scrollbar-color: rgba(0,0,0,0.2) transparent; /* For Firefox */
}

/* WebKit browsers (Chrome, Safari) scrollbar styling */
.booking-list::-webkit-scrollbar {
    width: 6px;
    display: block; /* Ensure the scrollbar is always displayed */
}

.booking-list::-webkit-scrollbar-track {
    background: transparent;
}

.booking-list::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 6px;
}

.booking-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0; /* Prevents flexbox items from expanding beyond container */
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 10px;
    flex-shrink: 0; /* Prevents items from shrinking */
}

.booking-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.booking-date {
    font-size: 0.85rem;
    color: #6c757d;
    font-style: italic;
    white-space: nowrap;
}

.booking-details {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    overflow-x: hidden;
}

@media (max-width: 576px) {
    .booking-details {
        grid-template-columns: 1fr;
    }
}

.booking-details p {
    flex: 1 1 calc(25% - 8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px dotted #eaeaea;
    margin: 0;
    padding: 5px 10px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.booking-details span {
    flex: 1 1 calc(25% - 8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px dotted #eaeaea;
    margin: 0;
    padding: 5px 10px;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.booking-details p:last-child {
    border-bottom: none;
}

.booking-details p strong {
    font-weight: 600;
    color: #495057;
}

.cancel-booking-btn {
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Make the booking modal more stable */
.modal-dialog {
    pointer-events: auto;
}

.time-slots-container {
    position: relative;
    z-index: 5;
}

.my-bookings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.refresh-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.booking-header {
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.booking-header h6 {
    margin: 0;
}

.booking-time {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.booking-date {
    font-size: 0.8rem;
    color: #6c757d;
}
