/* Reuse the rounded Hugeicons chevron from the site's icon set. */
html[data-theme] body[data-controller~="pets"] {
    --pets-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M18 9s-4.419 6-6 6-6-6-6-6' stroke='%23667085' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

html[data-theme="dark"] body[data-controller~="pets"] {
    --pets-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M18 9s-4.419 6-6 6-6-6-6-6' stroke='%23b8c0d1' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Keep dropdown indicators visible when form and theme styles replace backgrounds. */
html[data-theme] body[data-controller~="pets"] select:where(:not([multiple], [size]:not([size="1"]), .theme-preference-control select)) {
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 44px;
    background-image: var(--pets-select-chevron);
    background-position: right 10px center;
    background-size: 24px 24px;
    background-repeat: no-repeat;
    cursor: pointer;
}

html[data-theme] body[data-controller~="pets"] select:disabled {
    cursor: not-allowed;
}

html[data-theme] body[data-controller~="pets"] select:dir(rtl) {
    background-position: left 10px center;
}

@media (forced-colors: active) {
    html[data-theme] body[data-controller~="pets"] select {
        appearance: auto;
        -webkit-appearance: auto;
        background-image: none;
    }
}

html[data-theme] body[data-controller~="pets"] .pets-select {
    position: relative;
    min-width: 0;
    width: 100%;
}

html[data-theme] body[data-controller~="pets"] .pets-select > select.pets-select-native {
    position: absolute;
    inset: 0 auto auto 0;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    clip-path: inset(50%);
    pointer-events: none;
}

html[data-theme] body[data-controller~="pets"] .pets-select > .pets-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--smplsColorInputBorder, var(--line));
    border-radius: var(--smplsRadiusInput, 10px);
    background: var(--smplsColorInput, var(--surface));
    color: var(--smplsColorInputText, var(--dark));
    box-shadow: none;
    font: inherit;
    font-size: var(--pets-control-font-size, 15px);
    line-height: 1.4;
    letter-spacing: normal;
    text-align: start;
    text-transform: none;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

html[data-theme="dark"] body[data-controller~="pets"] .pets-select > .pets-select-trigger {
    background: var(--smplsColorInputDark, var(--surface));
    color: var(--smplsColorInputTextDark, var(--dark));
    border-color: var(--smplsColorInputBorderDark, var(--line));
}

html[data-theme] body[data-controller~="pets"] .pets-select-trigger:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
}

html[data-theme] body[data-controller~="pets"] .pets-select-trigger:is(:focus-visible, [aria-expanded="true"]) {
    border-color: var(--blue);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 12%, transparent);
}

html[data-theme] body[data-controller~="pets"] .pets-select > .pets-select-trigger[aria-invalid="true"] {
    border-color: var(--smplsColorDanger, #b42318);
}

.pets-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pets-select-trigger > .icon {
    flex: none;
    width: 22px;
    height: 22px;
    color: var(--muted);
    transition: transform .18s;
}

.pets-select-trigger[aria-expanded="true"] > .icon {
    transform: rotate(180deg);
    color: var(--blue);
}

html[data-theme] body[data-controller~="pets"] .pets-select-popup {
    position: fixed;
    inset: auto;
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 6px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--dark);
    box-shadow: 0 14px 40px color-mix(in srgb, var(--dark) 13%, transparent), 0 2px 6px #00000008;
    font: inherit;
    font-size: var(--pets-control-font-size, 15px);
    line-height: 1.4;
    text-align: start;
    scrollbar-width: thin;
}

.pets-select-popup[hidden], .pets-select-error[hidden] {
    display: none !important;
}

.pets-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 42px;
    padding: 10px 12px;
    box-sizing: border-box;
    border-radius: 9px;
    cursor: pointer;
}

.pets-select-option + .pets-select-option {
    margin-top: 2px;
}

.pets-select-option > .icon {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--blue);
    visibility: hidden;
}

.pets-select-option[aria-selected="true"] {
    color: var(--blue);
    background: color-mix(in srgb, var(--blue) 8%, var(--surface));
    font-weight: 600;
}

.pets-select-option[aria-selected="true"] > .icon {
    visibility: visible;
}

.pets-select-option:is(.is-active, :hover):not([aria-disabled="true"]) {
    background: color-mix(in srgb, var(--blue) 12%, var(--surface));
}

.pets-select-option[aria-disabled="true"], .pets-select-trigger:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.pets-select-group {
    padding: 12px 12px 6px;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
}

.pets-select-error {
    display: block;
    margin-top: 6px;
    color: var(--smplsColorDanger, #b42318);
    font-size: .8rem;
}

.theme-preference-control:has(.pets-select)::after {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .pets-select-trigger, .pets-select-trigger > .icon {
        transition: none !important;
    }
}
