/* ==========================================================================
   Hibernia Booking Widget — Scoped Styles
   All rules scoped to .hibernia-widget to avoid theme conflicts.
   CSS custom properties at the top for easy theming by Ilona.

   LAYOUT: Three rows.
     Row 1: Trip Type toggle (Return | One Way)
     Row 2: Outward Route | Departure Date | Return Date | Passengers
     Row 3: Book Now button (full width)
   ========================================================================== */

.hibernia-widget {
    /* ---- Themeable Variables ---- */
    --hw-font-family: inherit;
    --hw-color-primary: #1a3c6e;
    --hw-color-primary-hover: #15305a;
    --hw-color-primary-light: #e8eef6;
    --hw-color-accent: #d4a84b;
    --hw-color-text: #1e1e1e;
    --hw-color-text-secondary: #5a6a7a;
    --hw-color-border: #c8d1db;
    --hw-color-bg: #ffffff;
    --hw-color-bg-field: #f7f8fa;
    --hw-color-error: #c0392b;
    --hw-color-error-bg: #fdecea;
    --hw-border-radius: 8px;
    --hw-border-radius-sm: 6px;
    --hw-spacing-xs: 4px;
    --hw-spacing-sm: 8px;
    --hw-spacing-md: 16px;
    --hw-spacing-lg: 24px;
    --hw-spacing-xl: 32px;
    --hw-transition: 0.2s ease;

    /* ---- Base ---- */
    font-family: var(--hw-font-family);
    color: var(--hw-color-text);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: var(--hw-color-bg);
    border-radius: var(--hw-border-radius);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    padding: var(--hw-spacing-lg);
    box-sizing: border-box;
    line-height: 1.5;
}

.hibernia-widget *,
.hibernia-widget *::before,
.hibernia-widget *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   ROW LAYOUT — Flex rows that wrap
   ========================================================================== */

.hibernia-widget__row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hw-spacing-md);
    margin-bottom: var(--hw-spacing-md);
    align-items: flex-end;
}

.hibernia-widget__row:last-of-type {
    margin-bottom: 0;
}

.hibernia-widget__cell {
    flex: 1 1 auto;
    min-width: 0;
}

/* ---- Row 1: Trip Type — centered toggle ---- */
.hibernia-widget__row--trip-type {
    justify-content: flex-start;
}

.hibernia-widget__cell--trip-type {
    flex: 0 1 240px;
    min-width: 200px;
}

/* ---- Row 2: Fields — all side by side ---- */
.hibernia-widget__cell--route {
    flex: 1 1 200px;
    min-width: 160px;
}

.hibernia-widget__cell--date {
    flex: 0 1 150px;
    min-width: 130px;
}

.hibernia-widget__cell--passengers-dropdown {
    flex: 0 1 180px;
    min-width: 140px;
    position: relative;
}

/* ---- Submit cell — sits inline in the fields row ---- */
.hibernia-widget__cell--submit {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
}

/* ---- Return date visibility ---- */
/* Use visibility + height collapse so the cell still occupies space and
   the widget width stays constant when switching between Return / One Way */
.hibernia-widget__cell--return-date.hibernia-widget__cell--hidden {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
    /* On desktop, keep it in the flex flow with its size reserved */
}

/* On desktop, reserve the space using a different technique:
   keep the element in flow but make its contents invisible */
@media (min-width: 601px) {
    .hibernia-widget__cell--return-date.hibernia-widget__cell--hidden {
        height: auto;
        overflow: visible;
        pointer-events: none;
        opacity: 0;
    }
}

/* ==========================================================================
   LABELS
   ========================================================================== */

.hibernia-widget__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--hw-color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--hw-spacing-xs);
    white-space: nowrap;
}

/* ==========================================================================
   TRIP TYPE TOGGLE
   ========================================================================== */

.hibernia-widget__toggle-group {
    display: flex;
    background: var(--hw-color-bg-field);
    border-radius: var(--hw-border-radius-sm);
    padding: 2px;
    border: 1px solid var(--hw-color-border);
}

.hibernia-widget__toggle {
    flex: 1;
    text-align: center;
    cursor: pointer;
    margin: 0;
}

.hibernia-widget__toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.hibernia-widget__toggle-label {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: calc(var(--hw-border-radius-sm) - 1px);
    transition: background var(--hw-transition), color var(--hw-transition), box-shadow var(--hw-transition);
    color: var(--hw-color-text-secondary);
    user-select: none;
    white-space: nowrap;
}

.hibernia-widget__toggle--active .hibernia-widget__toggle-label {
    background: var(--hw-color-primary);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(26, 60, 110, 0.25);
}

/* ==========================================================================
   SELECT (Route)
   ========================================================================== */

.hibernia-widget__select-wrap {
    position: relative;
}

.hibernia-widget__select {
    width: 100%;
    height: 40px;
    padding: 0 32px 0 12px;
    font-size: 14px;
    font-family: var(--hw-font-family);
    border: 1px solid var(--hw-color-border);
    border-radius: var(--hw-border-radius-sm);
    background: var(--hw-color-bg-field);
    color: var(--hw-color-text);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color var(--hw-transition);
}

.hibernia-widget__select:focus {
    outline: none;
    border-color: var(--hw-color-primary);
    box-shadow: 0 0 0 3px rgba(26, 60, 110, 0.12);
}

.hibernia-widget__select-wrap::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--hw-color-text-secondary);
    pointer-events: none;
}

/* ==========================================================================
   DATE INPUTS
   ========================================================================== */

.hibernia-widget__input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-family: var(--hw-font-family);
    border: 1px solid var(--hw-color-border);
    border-radius: var(--hw-border-radius-sm);
    background: var(--hw-color-bg-field);
    color: var(--hw-color-text);
    transition: border-color var(--hw-transition);
}

.hibernia-widget__input:focus {
    outline: none;
    border-color: var(--hw-color-primary);
    box-shadow: 0 0 0 3px rgba(26, 60, 110, 0.12);
}

.hibernia-widget__input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Flatpickr alt-input inherits our field styles */
.hibernia-widget .flatpickr-input[readonly] {
    cursor: pointer;
}

.hibernia-widget input.flatpickr-alt {
    width: 100%;
    height: 40px;
    padding: 0 32px 0 12px;
    font-size: 14px;
    font-family: var(--hw-font-family);
    border: 1px solid var(--hw-color-border);
    border-radius: var(--hw-border-radius-sm);
    background: var(--hw-color-bg-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6a7a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") right 10px center / 16px 16px no-repeat;
    color: var(--hw-color-text);
    transition: border-color var(--hw-transition);
    cursor: pointer;
    box-sizing: border-box;
}

.hibernia-widget input.flatpickr-alt:focus {
    outline: none;
    border-color: var(--hw-color-primary);
    box-shadow: 0 0 0 3px rgba(26, 60, 110, 0.12);
}

/* Hide the original input when Flatpickr creates the alt input */
.hibernia-widget .flatpickr-mobile,
.hibernia-widget .hibernia-widget__input[type="text"].flatpickr-input {
    position: absolute !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
}

/* ==========================================================================
   PASSENGERS DROPDOWN
   ========================================================================== */

/* Trigger — matches select/input fields exactly */
.hibernia-widget__pax-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-family: var(--hw-font-family);
    color: var(--hw-color-text);
    background: var(--hw-color-bg-field);
    border: 1px solid var(--hw-color-border);
    border-radius: var(--hw-border-radius-sm);
    cursor: pointer;
    transition: border-color var(--hw-transition);
    text-align: left;
}

.hibernia-widget__pax-trigger:hover,
.hibernia-widget__pax-trigger:focus,
.hibernia-widget__pax-trigger[aria-expanded="true"] {
    outline: none;
    border-color: var(--hw-color-primary);
    box-shadow: 0 0 0 3px rgba(26, 60, 110, 0.12);
}

.hibernia-widget__pax-summary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.hibernia-widget__pax-chevron {
    flex-shrink: 0;
    margin-left: 8px;
    color: var(--hw-color-text-secondary);
    transition: transform var(--hw-transition);
}

.hibernia-widget__pax-trigger[aria-expanded="true"] .hibernia-widget__pax-chevron {
    transform: rotate(180deg);
}

/* Popover panel */
.hibernia-widget__pax-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 300px;
    margin-top: 4px;
    padding: 16px 20px;
    background: var(--hw-color-bg);
    border: 1px solid var(--hw-color-border);
    border-radius: var(--hw-border-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1000;
}

.hibernia-widget__pax-panel--open {
    display: block;
}

/* Individual passenger row inside panel */
.hibernia-widget__pax-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.hibernia-widget__pax-row + .hibernia-widget__pax-row {
    border-top: 1px solid var(--hw-color-border);
}

.hibernia-widget__passenger-info {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 12px;
}

.hibernia-widget__passenger-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--hw-color-text);
    line-height: 1.3;
}

.hibernia-widget__passenger-age {
    font-size: 12px;
    color: var(--hw-color-text-secondary);
    line-height: 1.3;
    margin-top: 1px;
}

/* Confirm button inside popover */
.hibernia-widget__pax-confirm {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--hw-font-family);
    color: var(--hw-color-text);
    background: var(--hw-color-bg-field);
    border: 1px solid var(--hw-color-border);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color var(--hw-transition), background var(--hw-transition);
    text-align: center;
}

.hibernia-widget__pax-confirm:hover:not(:disabled) {
    border-color: var(--hw-color-primary);
    background: var(--hw-color-primary-light);
}

.hibernia-widget__pax-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Validation message inside popover */
.hibernia-widget__pax-message {
    display: none;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--hw-color-error);
    background: var(--hw-color-error-bg);
    border-radius: 4px;
}

.hibernia-widget__pax-message--visible {
    display: block;
}

/* Disabled stepper buttons */
.hibernia-widget__stepper-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ---- Stepper ---- */
.hibernia-widget__stepper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 12px;
}

.hibernia-widget__stepper-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--hw-color-border);
    background: var(--hw-color-bg);
    color: var(--hw-color-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--hw-transition), border-color var(--hw-transition);
    padding: 0;
    user-select: none;
}

.hibernia-widget__stepper-btn:hover {
    border-color: var(--hw-color-primary);
    background: var(--hw-color-primary-light);
}

.hibernia-widget__stepper-btn:active {
    background: var(--hw-color-primary);
    color: #ffffff;
}

.hibernia-widget__stepper-input {
    width: 32px;
    height: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--hw-font-family);
    border: 1px solid var(--hw-color-border);
    border-radius: 4px;
    padding: 0;
    background: var(--hw-color-bg);
    color: var(--hw-color-text);
    -moz-appearance: textfield;
}

.hibernia-widget__stepper-input::-webkit-inner-spin-button,
.hibernia-widget__stepper-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==========================================================================
   ERROR MESSAGE
   ========================================================================== */

.hibernia-widget__error {
    display: none;
    padding: 10px var(--hw-spacing-md);
    background: var(--hw-color-error-bg);
    color: var(--hw-color-error);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--hw-border-radius-sm);
    margin-top: var(--hw-spacing-md);
    border-left: 3px solid var(--hw-color-error);
}

.hibernia-widget__error--visible {
    display: block;
}

/* ==========================================================================
   SUBMIT BUTTON
   ========================================================================== */

.hibernia-widget__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    width: 200px; /* default — overridden by Elementor control */
    height: 44px;
    padding: 0 var(--hw-spacing-xl);
    font-size: 15px;
    font-weight: 700;
    font-family: var(--hw-font-family);
    letter-spacing: 0.5px;
    color: #ffffff;
    background: var(--hw-color-primary);
    border: none;
    border-radius: var(--hw-border-radius);
    cursor: pointer;
    transition: background var(--hw-transition), box-shadow var(--hw-transition);
    text-transform: uppercase;
}

.hibernia-widget__submit:hover {
    background: var(--hw-color-primary-hover);
    box-shadow: 0 4px 12px rgba(26, 60, 110, 0.3);
}

.hibernia-widget__submit:active {
    transform: translateY(1px);
}

/* ==========================================================================
   RESPONSIVE — wrap gracefully on smaller screens
   ========================================================================== */

/* Tablet — fields row wraps naturally via flex-wrap */
/* Tablet-ish: at narrower widths, let the route take the full row first
   so the date + passenger fields stay side-by-side below it. */
@media (max-width: 740px) {
    .hibernia-widget__cell--route {
        flex: 1 1 100%;
    }
}

/* Mobile — full stack, full width */
@media (max-width: 600px) {
    .hibernia-widget {
        padding: var(--hw-spacing-md);
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
    }

    .hibernia-widget__form {
        width: 100%;
        max-width: 100%;
    }

    .hibernia-widget__row {
        flex-direction: column;
        gap: var(--hw-spacing-sm);
        width: 100%;
        max-width: 100%;
    }

    .hibernia-widget__cell,
    .hibernia-widget__cell--trip-type,
    .hibernia-widget__cell--route,
    .hibernia-widget__cell--date,
    .hibernia-widget__cell--passengers-dropdown,
    .hibernia-widget__cell--submit {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* On mobile, hide the return date fully (no space reservation needed) */
    .hibernia-widget__cell--return-date.hibernia-widget__cell--hidden {
        display: none !important;
        visibility: visible;
        height: auto;
        overflow: visible;
        opacity: 1;
        pointer-events: auto;
    }

    .hibernia-widget__toggle-group {
        width: 100%;
    }

    .hibernia-widget__select,
    .hibernia-widget__input,
    .hibernia-widget__pax-trigger {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Button full width on mobile regardless of desktop setting */
    .hibernia-widget__submit {
        width: 100% !important;
        max-width: 100% !important;
    }

    .hibernia-widget__pax-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        border-radius: var(--hw-border-radius) var(--hw-border-radius) 0 0;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
        max-height: 80vh;
        overflow-y: auto;
        min-width: 0;
    }
}
