/* Wilayah autocomplete widget.
 *
 * The input itself carries `.form-control` (admin Bootstrap) and
 * `.mb-form-input` (member layout) — inherits font, height, border, padding,
 * and focus styles from whichever host context it sits in. We only override
 * cosmetics that the host classes don't define (results dropdown, selected
 * label/path layout, clear button).
 */

.wilayah-ac-host {
    position: relative;
    width: 100%;
}

.wilayah-ac-search {
    position: relative;
}

/* Loading spinner — sits inside the input on the right while AJAX is in flight.
 * The input gets right-padding via :has() in modern browsers; older browsers
 * just get the spinner overlapping a bit, which is fine for an indicator. */
.wilayah-ac-spinner {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-top-color: #d71149;
    border-radius: 50%;
    animation: wilayah-spin 0.7s linear infinite;
    pointer-events: none;
    z-index: 2;
}

@keyframes wilayah-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

.wilayah-ac-search:has(.wilayah-ac-spinner:not([style*="display:none"])) .wilayah-ac-input,
.wilayah-ac-search:has(.wilayah-ac-spinner:not([style*="display: none"])) .wilayah-ac-input {
    padding-right: 32px;
}

/* Results dropdown — always our own styling since it doesn't exist in host CSS */
.wilayah-ac-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.wilayah-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
}

.wilayah-ac-item:last-child {
    border-bottom: none;
}

.wilayah-ac-item:hover {
    background: #f9fafb;
}

.wilayah-ac-item-label {
    font-weight: 600;
    color: #111827;
    font-size: inherit;
}

.wilayah-ac-item-path {
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 2px;
}

.wilayah-ac-empty {
    padding: 12px;
    color: #9ca3af;
    text-align: center;
    font-size: 0.9em;
}

/* Selected view — inherits .form-control / .mb-form-input height/border/etc.
 * We turn it into a flex row so label + path + × button sit on one line.
 * height:auto override allows the path to wrap if it's long. */
.wilayah-ac-selected {
    display: flex;
    align-items: center;
    gap: 10px;
    height: auto !important;
    flex-wrap: wrap;
}

.wilayah-ac-label {
    font-weight: 600;
    color: inherit;
    flex-shrink: 0;
}

.wilayah-ac-path {
    color: #6b7280;
    font-size: 0.9em;
    flex: 1;
    min-width: 0;
}

.wilayah-ac-clear {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    margin-left: auto;
}

.wilayah-ac-clear:hover {
    color: #ef4444;
}
