$choices-bg-color: white;

@use "choices.js/src/styles/choices" as choices;
$choices-selector: choices.$choices-selector;

span+.#{$choices-selector} {
    @apply mt-1;
}

fieldset:disabled .#{$choices-selector} {
    @apply opacity-50;

    .#{$choices-selector}__button:hover {
        @apply opacity-25;
    }
}

.#{$choices-selector} {
    @apply shadow-sm;

    .#{$choices-selector}__inner {
        @apply block rounded-md border-base-300 w-full py-2 shadow-sm;
        min-height: 42px; /* Explicitly set min-height */
    }

    &.is-focused {
        .#{$choices-selector}__inner {
            @apply border-primary ring-2 ring-primary ring-opacity-20;
        }
    }

    .#{$choices-selector}__inner {
        @apply px-3 text-base bg-no-repeat;

        .#{$choices-selector}__input {
            &:focus {
                box-shadow: none;
            }
        }

        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 0.5rem center;
        background-size: 1.5em 1.5em;
        background-repeat: no-repeat;
    }

    &[data-type*="select-one"] {
        .#{$choices-selector}__inner {
            @apply py-2;
            padding-top: 0.5rem;    /* Explicit padding */
            padding-bottom: 0.5rem; /* Explicit padding */
        }

        .#{$choices-selector}__input {
            @apply px-4 text-base;
            box-shadow: none;
            height: 2.5rem; /* Explicit height */

            &::placeholder {
                @apply text-base-content/70;
            }
        }

        &::after {
            @apply hidden;
        }

        &.is-disabled {
            .#{$choices-selector}__button {
                @apply hidden;
            }
        }
    }

    .#{$choices-selector}__list {
        @apply py-0 pl-0;
    }

    .#{$choices-selector}__list--dropdown {
        @apply mt-1 shadow-lg rounded-md border-base-300 bg-base-100;

        .#{$choices-selector}__item.#{$choices-selector}__placeholder {
            @apply hidden;
        }

        .#{$choices-selector}__item--selectable {
            @apply text-base-content text-base px-4;
            padding-top: 0.5rem;    /* Explicit padding */
            padding-bottom: 0.5rem; /* Explicit padding */

            &.is-highlighted {
                @apply bg-primary text-primary-content;
            }
        }
    }

    .#{$choices-selector}__list--multiple {
        @apply mb-0;

        .#{$choices-selector}__item {
            @apply bg-primary border-primary rounded-md font-medium py-1 text-sm mb-0 text-primary-content;

            &:hover {
                @apply bg-primary/80 border-primary/80;
            }

            line-height: 1;
        }
    }

    &[data-type*="select-multiple"] {
        .#{$choices-selector}__inner {
            @apply pr-8 py-2;
            min-height: 42px; /* Explicit min-height */

            &[data-has-selection="true"] {
                @apply pt-1.5 pb-2;
            }
        }

        .#{$choices-selector}__button {
            @apply border-none px-3 mx-0;
        }

        .#{$choices-selector}__input {
            @apply m-0 py-px pl-0 text-base min-w-0 leading-none;
        }
    }
}

.#{$choices-selector}__placeholder {
    @apply opacity-100 text-base-content/50;
}
