.ff-reservation-widget {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ccc;
    background: #f9f9f9;
}

.ff-res-form-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.ff-res-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.ff-res-form input[type="text"],
.ff-res-form select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 0;
}

/* Time and guest dropdowns, drawn over the hidden selects. The design settings set the variables. */
.ff-res-select {
    position: relative;
}

.ff-reservation-widget .ff-res-select-toggle,
.ff-reservation-widget .ff-res-select-toggle:hover,
.ff-reservation-widget .ff-res-select-toggle:focus {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 8px;
    border: 1px solid var(--ff-res-field-border, #ccc);
    border-radius: 0;
    background: var(--ff-res-field-bg, #fff);
    box-shadow: none;
    color: var(--ff-res-field-text, inherit);
    font: inherit;
    line-height: normal;
    letter-spacing: normal;
    text-align: left;
    text-transform: none;
    cursor: pointer;
}

.ff-reservation-widget .ff-res-select-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.ff-res-select-text,
.ff-res-select-sizer {
    display: grid;
}

.ff-res-select-text {
    flex: 1;
    min-width: 0;
}

.ff-res-select-value,
.ff-res-select-sizer,
.ff-res-select-sizer > span {
    grid-area: 1 / 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ff-res-select-sizer {
    visibility: hidden;
}

.ff-res-select-arrow {
    flex: none;
    transition: transform 0.15s;
}

.ff-res-select-toggle[aria-expanded="true"] .ff-res-select-arrow {
    transform: rotate(180deg);
}

.ff-reservation-widget .ff-res-select-menu {
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    border: 1px solid var(--ff-res-field-border, #ccc);
    background: var(--ff-res-dropdown-bg, #fff);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: var(--ff-res-dropdown-text, inherit);
    list-style: none;
    text-align: left;
}

.ff-res-select.is-above .ff-res-select-menu {
    top: auto;
    bottom: calc(100% + 4px);
}

.ff-reservation-widget .ff-res-select-menu:focus {
    outline: none;
}

.ff-reservation-widget .ff-res-select-option {
    margin: 0;
    padding: 8px 14px;
    white-space: nowrap;
    cursor: pointer;
}

.ff-reservation-widget .ff-res-select-option::before {
    content: none;
}

.ff-reservation-widget .ff-res-select-option.is-active {
    background: rgba(0, 0, 0, 0.06);
    background: color-mix(in srgb, currentColor 12%, transparent);
}

.ff-reservation-widget .ff-res-select-option[aria-selected="true"] {
    font-weight: 600;
}

.ff-reservation-widget .ff-res-select-option[aria-disabled="true"] {
    opacity: 0.4;
    cursor: default;
}

/* Date picker calendar. Hover follows the text color so it stays visible with the dropdown colors. */
.flatpickr-calendar.ff-res-flatpickr .flatpickr-day:not(.selected):not(.flatpickr-disabled):hover,
.flatpickr-calendar.ff-res-flatpickr .flatpickr-day:not(.selected):not(.flatpickr-disabled):focus {
    border-color: transparent;
    background: rgba(0, 0, 0, 0.08);
    background: color-mix(in srgb, currentColor 15%, transparent);
}

.ff-res-form-submit {
    padding: 10px 20px;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
}

.ff-res-form-submit[disabled],
.ff-reservation-btns .button[disabled] {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.ff-res-form-submit.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.ff-res-form-submit .fa-spin {
    display: none;
    margin-left: 10px;
}

.ff-res-form-submit.loading .fa-spin {
    display: inline-block;
}

.ff-checkbox-container {
    margin-top: 10px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.ff-checkbox-container input[type="checkbox"] {
    margin-top: 5px;
    margin-right: 10px;
}

.ff-checkbox-container label {
    margin-bottom: 0;
    line-height: 1.4;
}

.ff-res-errors {
    color: #d63638;
    margin-top: 10px;
    font-weight: bold;
}

.ff-res-first, .ff-res-list {
    margin-top: 20px;
}

.ff-res-other-title {
    margin-top: 30px;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 700;
    text-transform: uppercase;
}


/* Experience Item Grid Layout */
.ff-experience-item {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    padding: 30px 0;
    border-top: 1px solid #eee;
    margin-top: 20px;
    align-items: start;
}

.ff-experience-image img {
    width: 100%;
    height: auto;
    display: block;
}

.ff-experience-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ff-experience-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    text-transform: uppercase;
}

.ff-experience-price {
    font-size: 24px;
    font-weight: 700;
}

.ff-experience-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.ff-experience-body.no-description {
    grid-template-columns: 1fr;
}

/* Date, time and guest fields moved into the main experience card */
.ff-res-controls-pending {
    min-height: 120px;
}

.ff-res-controls-pending .ff-res-controls {
    display: none;
}

.ff-res-controls-in-card .ff-res-first {
    margin-top: 0;
}

.ff-res-controls-in-card .ff-res-first .ff-experience-main {
    border-top: 0;
    margin-top: 0;
    padding: 0;
}

.ff-res-form-slot {
    container-type: inline-size;
    container-name: ffresformslot;
}

.ff-res-form-slot .ff-res-controls {
    margin-bottom: 20px;
}

/* Date fills the row beside time and guests at their natural width; it takes its own row when they don't fit. */
.ff-res-form-slot .ff-res-form-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
}

@container ffresformslot (width < 18em) {
    .ff-res-form-slot .ff-res-form-fields {
        grid-template-columns: 1fr 1fr;
    }

    .ff-res-form-slot .ff-res-form-date {
        grid-column: 1 / -1;
    }
}

.ff-res-form-slot .ff-res-form-submit {
    width: 100%;
}

.ff-reservation-widget .ff-res-form .ff-res-form-submit {
    max-width: 100%;
    padding-left: 0.5em;
    padding-right: 0.5em;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Guest buttons (guests-layout="buttons") and calendar (date-time-layout="calendar"). Themes can override the variables. */
.ff-reservation-widget {
    --ff-res-line: rgba(0, 0, 0, 0.2);
    --ff-res-selected-bg: #111;
    --ff-res-selected-text: #fff;
    --ff-res-closed-bg: rgba(0, 0, 0, 0.06);
}

.ff-reservation-widget [hidden] {
    display: none !important;
}

.ff-reservation-widget .ff-res-label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.ff-reservation-widget .ff-res-choice {
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 3em;
    margin: 0;
    padding: 0 4px;
    border: 1px solid var(--ff-res-line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: inherit;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.ff-reservation-widget .ff-res-choice:hover:not(:disabled) {
    border-color: currentColor;
}

.ff-reservation-widget .ff-res-choice:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.ff-reservation-widget .ff-res-choice.is-selected,
.ff-reservation-widget .ff-res-choice.is-selected:hover {
    border-color: var(--ff-res-selected-bg);
    background: var(--ff-res-selected-bg);
    color: var(--ff-res-selected-text);
    font-weight: 600;
}

.ff-reservation-widget .ff-res-choice:disabled {
    cursor: default;
}

.ff-reservation-widget.ff-res-guests-buttons .ff-res-form-guests {
    grid-column: 1 / -1;
    order: -1;
}

.ff-res-guest-btns {
    display: grid;
    grid-template-columns: repeat(var(--ff-res-guest-columns, 6), minmax(0, 1fr));
    gap: 6px;
}

.ff-reservation-widget.ff-res-layout-calendar .ff-res-form-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ff-res-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.ff-reservation-widget .ff-res-cal-nav {
    flex: none;
    width: 2.75em;
    min-height: 2.75em;
}

.ff-reservation-widget .ff-res-cal-nav:disabled {
    opacity: 0.35;
}

.ff-res-cal-title {
    font-size: 1.6em;
    line-height: 1.2;
    text-align: center;
}

.ff-res-cal-weekdays,
.ff-res-cal-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.ff-res-cal-weekdays {
    margin-bottom: 10px;
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-align: center;
    text-transform: uppercase;
    opacity: 0.75;
}

.ff-reservation-widget .ff-res-cal-day:disabled {
    border-color: transparent;
    opacity: 0.4;
}

.ff-res-date-note {
    margin: 16px 0 0;
    font-size: 0.9em;
}

.ff-reservation-widget.ff-res-layout-calendar .ff-res-form-time {
    padding-top: 20px;
    border-top: 1px solid var(--ff-res-line);
}

.ff-res-time-btns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

@container reswidget (width < 20em) {
    .ff-res-time-btns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ff-reservation-widget .ff-res-time-btn {
    border-color: currentColor;
}

.ff-reservation-widget .ff-res-time-btn.is-closed {
    border-color: transparent;
    background: var(--ff-res-closed-bg);
    text-decoration: line-through;
    opacity: 0.5;
}

.ff-reservation-widget .ff-res-time-btn.is-loading {
    border-color: var(--ff-res-line);
    animation: ff-res-pulse 1.2s ease-in-out infinite;
}

@keyframes ff-res-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.25; }
}

.ff-reservation-widget.ff-res-layout-calendar .ff-checkbox-container {
    justify-content: flex-start;
}

.ff-reservation-widget.ff-res-layout-calendar .ff-res-form-submit {
    width: 100%;
}

.ff-experience-desc {
    font-size: 16px;
    line-height: 1.6;
}

.ff-experience-desc p:first-child {
    margin-top: 0;
}

.ff-experience-desc p:last-child {
    margin-bottom: 0;
}

.ff-closest-times {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 14px;
}

.ff-res-options {
    border: 0;
    padding: 0;
    margin: 0 0 20px;
    min-width: 0;
}

.ff-res-options legend {
    padding: 0;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 14px;
}

.ff-res-options .ff-res-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    font-weight: normal;
    cursor: pointer;
}

.ff-res-options .ff-res-option-qty {
    width: 4.5em;
    min-height: 2.5em;
    margin: 0;
    padding: 0 0.5em;
    border: 1px solid var(--ff-res-field-border, var(--ff-res-line, rgba(0, 0, 0, 0.2)));
    border-radius: 0;
    background: var(--ff-res-field-bg, transparent);
    color: var(--ff-res-field-text, inherit);
    font: inherit;
    text-align: center;
}

.ff-res-options.is-invalid .ff-res-option-qty {
    border-color: #b32d2e;
}

.ff-res-option-price {
    opacity: 0.7;
}

/* While Commerce7 prices the guests' options */
.ff-experience-price.is-quoting {
    opacity: 0.4;
    transition: opacity 0.15s;
}

.ff-experience-price-regular {
    margin-right: 0.25em;
    font-weight: normal;
    opacity: 0.6;
}

.ff-res-options-status {
    margin: 4px 0 0;
    font-size: 0.9em;
    color: #b32d2e;
}

.ff-res-options-status:empty {
    display: none;
}

.ff-res-form-options .ff-res-options {
    margin-top: 24px;
}

.ff-reservation-btns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.ff-experience-times {
    container-type: inline-size;
    container-name: exptimes;
}

@container exptimes (width < 300px) {
    .ff-reservation-btns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ff-reservation-btns .button {
    border: none; 
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ff-reservation-widget .ff-reservation-btns .button {
    min-width: 0;
    max-width: 100%;
    padding-left: 0.5em;
    padding-right: 0.5em;
    white-space: normal;
    overflow-wrap: anywhere;
}

.ff-reservation-btns .button .fa-spin {
    margin-right: 5px;
    display: none;
}

.ff-reservation-btns .button.loading .fa-spin {
    display: inline-block;
}

.ff-experience-item.no-image {
    grid-template-columns: 1fr;
    padding: 20px 0;
}

@media (max-width: 768px) {
    .ff-experience-item {
        grid-template-columns: 1fr;
    }
    
    .ff-experience-body {
        grid-template-columns: 1fr;
    }
}

.loading-times {
    position: relative;
    opacity: 0.6;
}

/* Custom Popup for noTimesPassed */
.ff-reservation-widget {
    position: relative;
    container-type: inline-size;
    container-name: reswidget;
}

.ff-res-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.ff-res-popup-content {
    max-width: 100%;
}

.ff-res-popup-text {
    font-size: 16px;
    margin-bottom: 20px;
    color: #333;
    line-height: 1.5;
}

.ff-res-popup-btns {
    display: flex;
    flex-flow: row wrap;
    gap: 10px;
    justify-content: center;
}

.ff-res-popup-btns .button {
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    text-transform: uppercase;
}

.ff-res-popup-btn-cancel {
    background: #eee;
    color: #333;
}

.ff-res-popup-btn-continue {
    background: #0073aa;
    color: #fff;
}

/* Loading state for the entire widget */
.ff-reservation-widget.ff-loading {
    position: relative;
    pointer-events: none;
}

.ff-reservation-widget.ff-loading::before,
.ff-reservation-widget.ff-loading::after {
    opacity: 1;
}

.ff-reservation-widget::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
}

.ff-reservation-widget::before {
    content: "\f110"; /* fa-spinner / fa-circle-notch fallback */
    font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", sans-serif;
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    font-size: 30px;
    color: #0073aa;
    animation: ff-spin 1s linear infinite;
    pointer-events: none;
    opacity: 0;
}

@keyframes ff-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}
