/**
 * WooCommerce Equipment Rental - Product Page Styles
 */

:root {
    --wcrent-accent: #96588a; /* WooCommerce purple; override in theme via :root { --wcrent-accent: ... } */
}

/* -----------------------------------------------------------------------
   Wrapper around the date picker section
----------------------------------------------------------------------- */
.wcrent-date-picker-wrapper {
    margin: 1.25em 0;
    padding: 1em 1.25em 1.25em;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

/* -----------------------------------------------------------------------
   Label
----------------------------------------------------------------------- */
.wcrent-label {
    display: block;
    margin-bottom: 0.4em;
    font-weight: 600;
    font-size: 0.95em;
    color: #333;
}

/* -----------------------------------------------------------------------
   Date range input (the alt-input rendered by Flatpickr)
----------------------------------------------------------------------- */
.wcrent-date-input,
.wcrent-date-input.flatpickr-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6em 0.75em;
    font-size: 1em;
    line-height: 1.5;
    color: #333;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 3px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
}

.wcrent-date-input:focus,
input.flatpickr-alt-input:focus {
    outline: 2px solid var(--wcrent-accent);
    outline-offset: 2px;
    border-color: var(--wcrent-accent);
    box-shadow: none;
}

/* -----------------------------------------------------------------------
   Hourly time picker
----------------------------------------------------------------------- */
.wcrent-time-picker-wrapper {
    margin-top: 0.75em;
    padding: 0.75em 0;
    border-top: 1px solid #e0e0e0;
}

.wcrent-time-row {
    display: flex;
    align-items: center;
    gap: 0.75em;
    margin-bottom: 0.5em;
}

.wcrent-time-row:last-child {
    margin-bottom: 0;
}

.wcrent-time-label {
    min-width: 6em;
    margin-bottom: 0;
}

.wcrent-time-input {
    padding: 0.45em 0.6em;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    color: #333;
    transition: border-color 0.15s ease;
}

.wcrent-time-input:focus {
    outline: 2px solid var(--wcrent-accent);
    outline-offset: 2px;
    border-color: var(--wcrent-accent);
}

@media (max-width: 480px) {
    .wcrent-time-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3em;
    }

    .wcrent-time-input {
        width: 100%;
    }
}

/* -----------------------------------------------------------------------
   Availability note
----------------------------------------------------------------------- */
.wcrent-availability-note {
    margin-top: 0.4em;
    font-size: 0.8em;
    color: #6b6b6b;
    font-style: italic;
}

/* -----------------------------------------------------------------------
   Rental summary box
----------------------------------------------------------------------- */
.wcrent-rental-summary {
    margin-top: 1em;
    padding: 0.75em 1em;
    background: #f0f7ee;
    border: 1px solid #c3e0bb;
    border-radius: 3px;
    font-size: 0.95em;
    color: #2c5f2e;
    line-height: 1.6;
}

.wcrent-rental-summary .wcrent-summary-text {
    display: block;
}

/* -----------------------------------------------------------------------
   Total price highlight
----------------------------------------------------------------------- */
.wcrent-total-price {
    font-weight: 700;
    color: #333;
}

/* -----------------------------------------------------------------------
   Error message
   The element uses aria-live="assertive" and is never display:none so it
   remains registered as a live region from page load. When empty it is
   visually hidden (but still in the accessibility tree); when text is
   injected the browser both shows it and triggers an AT announcement.
----------------------------------------------------------------------- */
.wcrent-error:empty {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.wcrent-error:not(:empty) {
    display: block;
    margin-top: 0.6em;
    padding: 0.6em 0.85em;
    background: #fdecea;
    border: 1px solid #f5c6c2;
    border-radius: 3px;
    color: #a93226; /* ~5.1:1 on #fdecea — passes WCAG AA for small text */
    font-size: 0.9em;
    line-height: 1.5;
}

/* -----------------------------------------------------------------------
   Flatpickr calendar overrides - match WooCommerce palette
----------------------------------------------------------------------- */
.flatpickr-calendar {
    font-family: inherit;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange {
    background: var(--wcrent-accent);
    border-color: var(--wcrent-accent);
}

.flatpickr-day.inRange {
    background: #e8d5e5;
    border-color: #e8d5e5;
    box-shadow: -5px 0 0 #e8d5e5, 5px 0 0 #e8d5e5;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: #7a4470;
    border-color: #7a4470;
}

.flatpickr-day.today {
    border-color: var(--wcrent-accent);
}

.flatpickr-day.today:not(.selected):hover {
    background: #f4eaf3;
    color: #7a4470; /* 5.83:1 on #f4eaf3 */
}

/* Disabled (booked) dates */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    background: #f5f5f5;
    color: #bbb;
    text-decoration: line-through;
    cursor: not-allowed;
}

/* -----------------------------------------------------------------------
   Per-day price label (output by PHP via woocommerce_get_price_html)
----------------------------------------------------------------------- */
.wcrent-per-day {
    font-size: 0.85em;
    color: #767676;
    font-weight: normal;
}

/* WCAG 2.5.5: 44×44px minimum touch target for all day cells */
.flatpickr-day {
    height: 44px;
    max-width: 44px;
    min-height: 44px;
    line-height: 44px;
}

@media (max-width: 480px) {
    .wcrent-date-picker-wrapper {
        padding: 0.75em 0.875em 1em;
    }

    .flatpickr-calendar {
        width: calc(100vw - 2rem) !important;
        left: 1rem !important;
    }
}

/* -----------------------------------------------------------------------
   Visually hidden utility (screen-reader only)
----------------------------------------------------------------------- */
.wcrent-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect( 0, 0, 0, 0 );
    white-space: nowrap;
    border: 0;
}

/* .wcrent-rental-summary uses .wcrent-visually-hidden (defined above) to hide until dates are selected. */
/* The class toggle preserves the aria-live region's registration in the accessibility tree. */

/* -----------------------------------------------------------------------
   Print styles
----------------------------------------------------------------------- */
@media print {
    .wcrent-rental-summary,
    .wcrent-rental-summary.wcrent-visually-hidden {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip: auto;
        white-space: normal;
        border: 1px solid #000;
        padding: 8px;
        color: #000;
        background: none;
    }

    .wcrent-date-picker-wrapper {
        display: none;
    }
}
