:root {
    --primary-color: #b91c1c;
    /* Fire Engine Red */
    --secondary-color: #1f2937;
    /* Dark Slate */
    --accent-color: #fca5a5;
    /* Light Red */
    --background-color: #f3f4f6;
    --text-color: #111827;
    --white: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
}

header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    background: var(--white);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.date-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

button {
    background-color: var(--secondary-color);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

button:hover {
    opacity: 0.9;
}

button.primary {
    background-color: var(--primary-color);
}

.btn-large {
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(185, 28, 28, 0.4);
}

/* Calendar Table Structure */
.calendar-container {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: auto;
    /* Handles both x and y scroll if needed */
    max-height: 85vh;
}

.calendar-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
    /* Ensure table doesn't scrunch up on standard screens */
}

.calendar-table th,
.calendar-table td {
    padding: 0.25rem;
    border: 1px solid #e5e7eb;
    vertical-align: top;
    position: relative;
    font-size: 0.85rem;
}

/* Sticky Header Row */
.calendar-table thead th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    background: #f9fafb;
    z-index: 40;
    border-bottom: 2px solid #e5e7eb;
    padding: 0.5rem 0.25rem;
}

/* Sticky First Column (Date) */
.sticky-col,
.sticky-corner {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    background-color: #ffffff;
    /* Must have a solid background */
    z-index: 50;
    border-right: 2px solid #e5e7eb;
    min-width: 120px;
    width: 120px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

/* Corner needs higher z-index to stay on top of both scroll directions */
.sticky-corner {
    background-color: #f9fafb;
    z-index: 60;
    top: 0;
    left: 0;
}

.calendar-table tbody tr:nth-child(even) {
    background-color: var(--white);
}

.calendar-table tbody tr:nth-child(odd) {
    background-color: #fcfcfc;
}

.vehicle-header {
    min-width: 120px;
    text-align: center;
}

.vehicle-img {
    width: 80px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    margin: 0.25rem auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.vehicle-meta {
    font-size: 0.7rem;
    color: #6b7280;
    font-weight: normal;
}

.date-cell {
    text-align: center;
}

.today-row td {
    background-color: #fff1f2 !important;
}

.today-row .sticky-col {
    background-color: #fff1f2 !important;
    /* Ensure sticky col matches row color */
}

/* Bookings */
.booking-cell {
    min-width: 120px;
    padding: 0.1rem;
}

.booking-block {
    background-color: var(--primary-color);
    color: var(--white);
    border-radius: 3px;
    font-size: 0.7rem;
    padding: 2px 4px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.booking-block:hover {
    background-color: #991b1b;
    z-index: 30;
    position: relative;
    /* Break out of overflow if needed, though hidden on cell */
    width: auto;
    min-width: 100%;
}

/* Modal */
body.modal-open {
    overflow: hidden;
}


.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    /* Toggled via JS */
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Vehicle Selection Styling */
.vehicle-select-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    border-radius: 4px;
    background: #f9fafb;
}

.vehicle-select-item {
    display: flex;
}

.vehicle-select-item label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    background: white;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    margin-bottom: 0;
    width: 100%;
    transition: all 0.2s;
}

.vehicle-select-item label:hover {
    border-color: var(--primary-color);
    background-color: #fff1f2;
}

.vehicle-select-item input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .controls {
        flex-direction: column;
        gap: 1rem;
    }

    .controls button {
        width: 100%;
        margin-bottom: 0.75rem;
    }

    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .calendar-table {
        min-width: auto;
        /* Let it flow */
    }

    .calendar-table th,
    .calendar-table td {
        padding: 0.25rem;
        font-size: 0.8rem;
    }

    .sticky-col,
    .sticky-corner {
        min-width: 50px;
        width: 50px;
    }

    .vehicle-header,
    .booking-cell {
        min-width: 90px;
    }

    .vehicle-img {
        width: 60px;
        height: 40px;
        margin: 0.25rem auto;
    }
}