/*
 * searchable-select.css
 * Styles for the progressive-enhancement combobox built by
 * public/js/searchable-select.js. The component wraps a native <select>
 * with a filterable text input so long option lists (e.g. the 33-barangay
 * list) become searchable without touching the existing PHP backend.
 */

/* Hide the underlying <select> once the combobox is mounted. We keep it
   focus-unreachable and visually gone, but it stays in the DOM so the form
   still submits its value under the original name. */
.ks-combo > .ks-combo__native {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    overflow: hidden !important;
    pointer-events: none !important;
}

.ks-combo {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

/* The input inherits the original select's class list (form-input,
   dashboard-select, form-select, etc.) so it reuses existing field styling.
   We only add a right-side affordance for the chevron icon. */
.ks-combo__input {
    width: 100%;
    padding-right: 36px;
    cursor: text;
    background-image: none;
}

/* Original native selects with .select-with-icon paint a barangay icon via
   background-image on the <select> tag. CSS rules that use `select.` as a
   prefix don't apply to our <input>, so re-paint the same icon here to keep
   the auth / profiling fields visually consistent with their old look. */
.ks-combo__input.select-with-icon {
    padding-left: var(--space-550, 44px);
    background-image: url("../assets/icons/barangay.svg");
    background-repeat: no-repeat;
    background-position: left var(--space-200, 16px) center;
    background-size: 20px 20px;
}

.ks-combo__input::placeholder {
    color: var(--dashboard-placeholder, var(--color-neutral-500));
}

.ks-combo__input[aria-invalid="true"] {
    border-color: var(--color-border-input-error);
}

.ks-combo--disabled {
    opacity: 0.65;
    pointer-events: none;
}

.ks-combo--disabled .ks-combo__input {
    background-color: var(--color-neutral-100, #f8fbfe);
    cursor: not-allowed;
}

.ks-combo__chevron {
    position: absolute;
    top: 50%;
    right: 12px;
    width: 10px;
    height: 10px;
    margin-top: -7px;
    pointer-events: auto;
    cursor: pointer;
    display: inline-block;
    border-right: 2px solid var(--color-neutral-700);
    border-bottom: 2px solid var(--color-neutral-700);
    transform: rotate(45deg);
    transition: transform var(--motion-duration-fast, 0.18s) ease;
}

.ks-combo--open .ks-combo__chevron {
    transform: rotate(-135deg);
    margin-top: -3px;
}

.ks-combo__list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: var(--z-dropdown, 20);
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--color-background-surface, #fff);
    border: var(--border-width-thin, 1px) solid var(--color-border-default, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    box-shadow: var(--shadow-surface-overlay, 0 24px 60px rgba(15, 23, 42, 0.16));
}

.ks-combo__list[hidden] {
    display: none;
}

.ks-combo__option {
    padding: 9px 12px;
    font-size: var(--font-size-sm, 14px);
    line-height: 1.35;
    color: var(--color-text-primary, #111827);
    cursor: pointer;
    border-radius: 8px;
    user-select: none;
}

.ks-combo__option + .ks-combo__option {
    margin-top: 2px;
}

.ks-combo__option:hover,
.ks-combo__option.is-active {
    background: var(--color-brand-100, #eef5ff);
    color: var(--color-text-brand, #003e6b);
}

.ks-combo__option.is-selected {
    font-weight: var(--font-weight-semibold, 600);
}

.ks-combo__option.is-placeholder-option {
    display: none;
}

.ks-combo__empty {
    padding: 10px 12px;
    font-size: var(--font-size-sm, 14px);
    color: var(--color-text-tertiary, #6b7280);
    text-align: center;
    list-style: none;
}

.ks-combo__empty[hidden] {
    display: none;
}

/* On small screens, where the auth.js mobile picker already provides a
   fullscreen tap-to-pick experience, hide the combobox UI and let the
   existing trigger button do the work. The mobile picker writes the
   selected value back into the native <select>, and our `change` listener
   keeps the (hidden) input in sync for when the user returns to desktop. */
@media (max-width: 768px) {
    [data-mobile-picker] .ks-combo__input,
    [data-mobile-picker] .ks-combo__chevron,
    [data-mobile-picker] .ks-combo__list {
        display: none !important;
    }
}

/* List mode (data-searchable-select="list"): same field and panel, no search.
   The read-only input behaves like a button that opens the list. */
.ks-combo--list .ks-combo__input {
    cursor: pointer;
    caret-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
