/* Shared single-select styling; listboxes and multiple selects keep their native UI. */
:where(select:not([multiple]):not([size]), select:not([multiple])[size="1"]) {
    max-inline-size: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #fff;
    color: #1e293b;
    font: inherit;
    cursor: pointer;
}

:where(select:not([multiple]):not([size]), select:not([multiple])[size="1"]):focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

:where(select:not([multiple]):not([size]), select:not([multiple])[size="1"]):disabled {
    cursor: not-allowed;
    color: #64748b;
    background-color: #f8fafc;
}

/* Progressive enhancement preserves native keyboard, form and change-event behavior. */
@supports (appearance: base-select) and selector(::picker(select)) {
    select:not([multiple]):not([size]),
    select:not([multiple])[size="1"] {
        appearance: base-select;
        display: inline-flex;
        align-items: center;
        justify-content: space-between;
        vertical-align: middle;
        background-image: none;
        padding-inline-end: 12px;
        gap: 12px;

        &::picker(select) {
            appearance: base-select;
            min-inline-size: anchor-size(width);
            max-inline-size: calc(100vw - 24px);
            max-block-size: min(320px, 65dvh);
            margin-block: 6px;
            padding: 6px;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            background: #fff;
            color: #1e293b;
            font: inherit;
            font-size: 14px;
            color-scheme: light;
            box-shadow: 0 6px 18px rgb(15 23 42 / 8%);
            overflow-y: auto;
            overscroll-behavior: contain;
            scrollbar-width: thin;
            scrollbar-color: #cbd5e1 transparent;
        }

        &::picker-icon {
            flex-shrink: 0;
            margin-inline-start: auto;
            color: #64748b;
        }

        &:open { border-color: #4f46e5; }
        &:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }

        option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 6px;
            background: #fff;
            color: #1e293b;
            line-height: 1.5;
            white-space: normal;
            overflow-wrap: anywhere;
            cursor: pointer;
        }

        option:checked {
            background: #f1f5f9;
            color: #1e293b;
            font-weight: 500;
        }

        option:not(:disabled):hover { background: #f1f5f9; }
        option:not(:disabled):focus-visible { outline: 1px solid #4f46e5; outline-offset: -1px; }
        option:disabled { color: #64748b; cursor: not-allowed; }
        option::checkmark { display: none; }
        optgroup { padding-block: 6px; font-weight: 600; }
    }
}


input.flatpickr-input:not([type="hidden"]) {
    padding-inline-end: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='1.6'%3E%3Crect x='4' y='5' width='16' height='16' rx='2'/%3E%3Cpath d='M8 3v4m8-4v4M4 10h16'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 15px;
    background-position: right 10px center;
}
.flatpickr-calendar.vx-calendar { width: 308px; max-width: calc(100vw - 24px); padding: 8px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; color: #1e293b; font-family: inherit; box-shadow: 0 6px 18px rgb(15 23 42 / 8%); z-index: 1100; }
.flatpickr-calendar.vx-calendar::before, .flatpickr-calendar.vx-calendar::after { display: none; }
.vx-calendar .flatpickr-rContainer, .vx-calendar .flatpickr-days, .vx-calendar .dayContainer { width: 100%; min-width: 0; max-width: none; }
.vx-calendar .flatpickr-months { margin-bottom: 8px; }
.vx-calendar .flatpickr-months .flatpickr-month { color: #1e293b; }
.vx-calendar .flatpickr-current-month { font-size: 15px; font-weight: 600; }
.vx-calendar .flatpickr-current-month .cur-month { font-weight: 600; }
.vx-calendar .flatpickr-current-month input.cur-year { font-weight: 500; }
.vx-calendar .flatpickr-weekday { color: #64748b; font-size: 12px; font-weight: 500; }
.vx-calendar .flatpickr-day { color: #1e293b; border-radius: 7px; font-size: 13px; }
.vx-calendar .flatpickr-day:hover, .vx-calendar .flatpickr-day:focus { background: #f1f5f9; border-color: #f1f5f9; }
.vx-calendar .flatpickr-day.today { border-color: #cbd5e1; }
.vx-calendar .flatpickr-day.selected, .vx-calendar .flatpickr-day.selected:hover, .vx-calendar .flatpickr-day.selected:focus { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.vx-calendar .flatpickr-day.prevMonthDay, .vx-calendar .flatpickr-day.nextMonthDay, .vx-calendar .flatpickr-day.flatpickr-disabled { color: #94a3b8; }
.vx-calendar .flatpickr-day:focus-visible { outline: 2px solid #4338ca; outline-offset: 1px; }
