/* Variables */
:root {
    --tr-blue: #0ca8d0;
    --tr-green: #57933b;
    --tr-yellow: #e8a32e;
    --tr-red: #870119;

    --select: #007bff;
    --not-busy: #66ff66;
    --somewhat: #ffff00;
    --very-busy: #ff8800;
    --no-avail: #cc3333;
    --full: #222222;
    --closed: #888888;
    --past: #eeeeee;

    --block-bg: #f5c6cb;
    --block-bord: #c62828;

    --sb-green: rgba(100, 180, 100, 0.35);
    --sb-greenb: #4caf50;
    --sb-yell: rgba(180, 180, 100, 0.35);
    --sb-yellb: #afac4c;
    --sb-red: rgba(180, 100, 100, 0.35);
    --sb-redb: #af4c4c;
}

/* Default Buttons */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background-color: var(--tr-blue);
    color: white;

    border: 2px solid white;
    border-radius: 9999px;

    padding: 10px 20px;

    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;

    box-sizing: border-box;
    cursor: pointer;

    transition: background-color 0.2s ease;
}

button:hover:not(:disabled),
.button:hover {
    background-color: #087fa0;
}

.button-green {
    background-color: var(--tr-green);
}

.button-green:hover:not(:disabled) {
    background-color: #41702d;
}

.button-red {
    background-color: var(--tr-red);
}

.button-red:hover:not(:disabled) {
    background-color: #650113;
}

button:disabled,
.button:disabled {
    background-color: #cccccc;
    color: #777777;
    opacity: 0.5;
    cursor: not-allowed;
}

button:focus-visible,
.button:focus-visible {
    outline: 3px solid var(--tr-blue);
    outline-offset: 3px;
}

.close-request,
.close-admin-modal {
    background: none;
    color: #444444;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 28px;
    line-height: 1;
}

.close-request:hover:not(:disabled),
.close-admin-modal:hover:not(:disabled) {
    background: none;
    color: #222222;
}

/* Default Form Fields */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    min-height: 40px;
    padding: 10px 15px;

    font-family: Arial, sans-serif;
    font-size: 16px;
    color: #222222;

    background-color: white;
    border: 1px solid #cccccc;
    border-radius: 9999px;

    box-sizing: border-box;
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
select {
    height: 40px;
}

select {
    cursor: pointer;

    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23222222' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;

    padding-right: 45px;
}

textarea {
    border-radius: 20px;
    resize: vertical;
}

/* Admin */
.admin-modal {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
    box-sizing: border-box;

    background-color: rgba(0, 0, 0, 0.5);

    z-index: 1000;
}

.admin-modal-content {
    display: flex;
    flex-direction: column;

    width: 100%;
    max-width: 400px;
    max-height: 90vh;

    background-color: white;
    border-radius: 10px;
    overflow: hidden;
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 20px 30px;
    border-bottom: 1px solid #dddddd;
}

.admin-modal-header h2 {
    margin: 0;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.admin-field label {
    font-weight: bold;
}

.admin-field input,
.submit-admin {
    width: 100%;
}

#admin-login-form {
    padding: 20px 30px 30px;
}

.admin-login-error {
    color: var(--tr-red);
    margin-bottom: 15px;
}

.admin-controls {
    position: absolute;
    top: 15px;
    right: 20px;
}

/* Page */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #ffffff;
    color: #222222;
}

body.modal-open {
    overflow: hidden;
}

main {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

.booking-header-image {
    display: block;
    width: 200px;
    max-width: 25%;
    height: auto;
    margin: 0 auto 25px;
}

h1 {
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Facility Selection */
.facility-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.facility-selection label {
    font-weight: bold;
}

/* Monthly Calendar */
.booking-calendar {
    max-width: 800px;
    margin: 40px auto;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header select {
    font-weight: bold;
}

.calendar-header button {
    padding: 0;
    min-width: 40px;
    min-height: 40px;
    font-size: 24px;
}

.month-year-selection {
    display: flex;
    gap: 8px;
}

/* Weekdays */
.weekdays,
.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.weekdays div {
    text-align: center;
    font-weight: bold;
    padding: 10px;
}

.weekday-short {
    display: none;
}

/* Calendar Days */
.calendar-day,
.empty-day {
    min-height: 80px;
    border: 1px solid #dddddd;
    box-sizing: border-box;
    border-radius: 5px;
}

.calendar-day {
    padding: 10px;
    cursor: pointer;
    border: 1px solid white;
    position: relative;
}

.calendar-day.selected {
    border: 3px solid var(--tr-blue);
}

.today-star {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 12px;
}

.empty-day {
    background-color: #f5f5f5;
}

/* Calendar Status Colors */
.not-busy {
    background-color: var(--tr-green);
}

.somewhat-busy {
    background-color: var(--tr-yellow);
}

.very-busy,
.no-availability {
    background-color: var(--tr-red);
    color: white;
}

.full {
    background-color: var(--full);
    color: #ffffff;
}

.closed {
    background-color: var(--closed);
    color: #ffffff;
}

.past {
    background-color: var(--past);
    color: #888888;
}

/* Calendar Legend */
.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-box {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    vertical-align: middle;
    border: 1px solid #999999;
}

/* Daily Availability */
.daily-availability {
    max-width: 800px;
    margin: 40px auto;
}

.daily-availability h2 {
    margin-bottom: 5px;
}

.availability-instructions {
    margin-top: 0;
    color: #666666;
}

/* Time Selection */
.time-selection {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.time-selection-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.time-selection-field label {
    font-weight: bold;
}

.time-selection-field select {
    min-width: 150px;
}

.selected-time-text {
    margin: 10px 0 0;
    color: #555555;
    text-align: center;
}

/* Confirm Button */
.confirm {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
}

.confirm button {
    width: 245px;
}

/* Schedule */
.schedule-container {
    display: flex;
    margin-top: 25px;
    border: 1px solid #cccccc;
    padding: 8px;
    background-color: #ffffff;
    border-radius: 10px;
    overflow: hidden;
}

/* Time Labels */
.time-labels {
    width: 80px;
    flex-shrink: 0;
    background-color: #ffffff;
    overflow: visible;
    border-radius: 5px 0 0 5px;
    position: relative;
}

.time-label {
    height: 60px;
    box-sizing: border-box;
    padding: 0 8px;
    font-size: 13px;
    color: #555555;
    text-align: right;
    line-height: 1;
    position: relative;
    top: -5px;
}

.closing-time-label {
    position: absolute;
    top: auto;
    bottom: 0;
    right: 0;
    width: 100%;
    height: auto;
    padding: 0 8px;
    box-sizing: border-box;
    transform: translateY(50%);
}

/* Schedule Area */
.schedule {
    position: relative;
    flex: 1;
    border: 1px solid #cccccc;
    border-radius: 5px;
    overflow: hidden;
    background-color: #eeeeee;

    background-image:
        /* Hourly lines */
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 58px,
            #bdbdbd 58px,
            #bdbdbd 60px
        ),
        /* 15-minute lines */
        repeating-linear-gradient(
                to bottom,
                transparent 0px,
                transparent 14px,
                #dddddd 14px,
                #dddddd 15px
            );
}

/* Booking Blocks */
.booking {
    position: absolute;
    left: 10px;
    right: 10px;
    box-sizing: border-box;

    border-radius: 5px;

    padding: 8px;

    color: #222222;
    font-size: 14px;
    font-weight: bold;

    overflow: hidden;
}

.booking.requested {
    background-color: #fff3cd;
    border: 1px solid #d6a700;
}

.booking.booked {
    background-color: #f5c6cb;
    border: 1px solid #c62828;
}

.booking-time {
    font-size: 12px;
    font-weight: normal;
    margin-top: 4px;
}

/* Selected Time */
.selected-time {
    position: absolute;
    left: 0;
    right: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.selected-time.available {
    background-color: var(--sb-green);
    border: 2px solid var(--sb-greenb);
}

.selected-time.past-time {
    background-color: var(--sb-yell);
    border: 2px solid var(--sb-yellb);
}

.selected-time.conflicting {
    background-color: var(--sb-red);
    border: 2px solid var(--sb-redb);
}

/* Booking Request Form */
.request-modal {
    position: fixed;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;
    box-sizing: border-box;

    background-color: rgba(0, 0, 0, 0.5);

    overflow: hidden;

    z-index: 1000;
}

.request-modal.hidden {
    display: none;
}

.request-modal-content {
    display: flex;
    flex-direction: column;

    width: 100%;
    max-width: 600px;
    max-height: 90vh;

    background-color: #ffffff;
    border-radius: 10px;

    overflow: hidden;
}

.request-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    flex-shrink: 0;

    padding: 20px 30px;

    border-bottom: 1px solid #dddddd;
}

.request-modal-header h2 {
    margin: 0;
}

.request-modal-body {
    padding: 20px 30px 30px;
    box-sizing: border-box;
    overflow-y: auto;
}

.request-summary {
    margin-bottom: 20px;
    padding: 15px;

    background-color: #f5f5f5;
    border-radius: 6px;
}

.request-summary p {
    margin: 5px 0;
}

.request-field {
    display: flex;
    flex-direction: column;

    gap: 6px;
    margin-bottom: 15px;
}

.request-field label {
    font-weight: bold;
}

.request-field input:not([type="checkbox"]):not([type="radio"]),
.request-field select,
.request-field textarea {
    width: 100%;
}

.submit-request {
    width: 100%;
}

/* Booking Decision Buttons */
.decision-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;

    max-width: 500px;
    margin: 30px auto;
    padding: 0 20px;

    box-sizing: border-box;
}

.decision-buttons button {
    flex: 1;
}

.booking-review > p {
    text-align: center;
    margin-top: 25px;
}

/* Agreement */
.agreement-container input,
.agreement-container textarea {
    width: 100%;
}

.agreement-container[hidden] {
    display: none;
}

.field-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #666;
}

/* Rental Agreement Information Fields */
.agreement-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.agreement-field label {
    font-weight: bold;
}

.agreement-field input,
.agreement-field textarea {
    width: 100%;
}

#agreement-information h2 {
    margin-top: 30px;
    margin-bottom: 20px;
}

.agreement-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    cursor: pointer;
}

.agreement-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin: 0;
}

/* Digital Signature */
.agreement-signature {
    margin-top: 30px;
}

.signature-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

.signature-methods label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.signature-methods input[type="radio"] {
    width: auto;
    margin: 0;
}

.signature-option {
    margin: 20px 0;
}

.signature-option[hidden] {
    display: none;
}

/* Draw Signature */
#signature-pad {
    display: block;
    width: 100%;
    max-width: 600px;
    height: 200px;
    background: white;
    border: 2px solid #ccc;
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
    box-sizing: border-box;
}

#clear-signature {
    margin-top: 10px;
}

/* Type Signature */
#typed-signature {
    display: block;
    width: 100%;
    max-width: 600px;
    margin-top: 10px;
}

#typed-signature-preview {
    margin-top: 15px;
    padding: 20px;
    min-height: 80px;
    max-width: 600px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: cursive;
    font-size: 32px;
    font-style: italic;
    color: black;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}

/* Upload Signature */
#uploaded-signature {
    display: block;
    margin-top: 10px;
    max-width: 100%;
}

#uploaded-signature-preview {
    display: block;
    margin-top: 15px;
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

#uploaded-signature-preview[hidden] {
    display: none;
}

/* Wider Layout for Rental Agreement Review */
main:has(#agreement-review:not([hidden])) {
    max-width: none;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
}

/* Rental Agreement PDF Review */
#agreement-review {
    width: 90vw;
    max-width: none;
    margin: 0 auto;
    box-sizing: border-box;
}

.agreement-pdf-preview {
    width: 100%;
    margin: 0 auto;
}

#agreement-pdf,
#final-agreement-pdf {
    display: block;
    width: 100%;
    height: 85vh;
    margin: 0 auto;
    border: none;
}

.agreement-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Administrator Logout Actions */
.admin-logout-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px;
}

#admin-logout-modal p {
    text-align: center;
}

/* Administrator Booking Edit Button */
.admin-edit-booking {
    position: absolute;
    top: 4px;
    right: 4px;

    padding: 2px 6px;
    border: none;
    border-radius: 4px;

    background: transparent;
    color: #222222;
    font-size: 18px;
}

.admin-edit-booking:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.1);
}

#admin-booking-details {
    padding: 20px 30px 30px;
    overflow-y: auto;
    min-height: 0;
}

/* Checkbox Fields */
.admin-checkbox-field label,
#admin-full-day-field label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-checkbox-field input[type="checkbox"],
#admin-full-day-field input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.admin-booking-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px 30px;
    border-top: 1px solid #dddddd;
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 600px) {
    .weekday-full {
        display: none;
    }

    .weekday-short {
        display: inline;
    }

    .calendar-day,
    .empty-day {
        min-height: 0;
        aspect-ratio: 1/1;
    }

    .calendar-day {
        padding: 5px;
        font-size: 14px;
    }

    .today-star {
        font-size: 9px;
        top: 2px;
        right: 3px;
    }

    .time-selection {
        flex-direction: column;
        gap: 12px;
    }

    .time-selection-field select {
        width: 100%;
    }

    .decision-buttons {
        flex-direction: column;
    }

    .decision-buttons button {
        width: 100%;
    }
}
