/*
 * Unlimited Sourcing - Province / City picker.
 * Uses the UI kit tokens when rendered inside `.us-ui`; selectors carry
 * `:not(#_)` so theme / Elementor button and input styles cannot leak in.
 */

.us-location-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

@media (max-width: 480px) {
    .us-location-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.us-location-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.us-required {
    color: var(--us-danger-text, #c01111);
    margin-inline-start: 2px;
}

/* Native select kept for form submission / validation, visually hidden. */
select.us-lp__native:not(#_),
.us-ui:not(#_) select.us-lp__native.us-lp__native {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
    opacity: 0;
}

.us-lp:not(#_) {
    --_h: var(--us-control-h, 40px);
    --_r: var(--us-r-sm, 8px);
    --_text: var(--us-text, #212121);
    --_muted: var(--us-hint, #8f8f8f);
    --_primary: var(--us-primary-text, #0f3bd1);
    --_soft: var(--us-primary-50, rgba(15, 59, 209, 0.08));
    position: relative;
    direction: rtl;
    font-family: inherit;
}

.us-lp:not(#_) .us-lp__toggle {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: var(--_h);
    padding: 0 12px;
    border: 0;
    border-radius: var(--_r);
    background: var(--us-field, rgba(0, 0, 0, 0.04));
    color: var(--_muted);
    font: inherit;
    font-size: var(--us-fs-md, 14px);
    line-height: 1.5;
    cursor: pointer;
    text-align: right;
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.us-lp:not(#_) .us-lp__toggle:hover {
    background: var(--us-field-h, rgba(0, 0, 0, 0.08));
}

.us-lp:not(#_).has-value .us-lp__toggle {
    color: var(--_text);
    font-weight: 400;
}

.us-lp:not(#_) .us-lp__toggle:focus-visible,
.us-lp:not(#_).is-open .us-lp__toggle {
    box-shadow: var(--us-ring, 0 0 0 2px #fff, 0 0 0 4px #0f3bd1);
}

.us-lp:not(#_).is-invalid .us-lp__toggle,
.has-error .us-lp:not(#_) .us-lp__toggle {
    box-shadow: var(--us-ring-danger, 0 0 0 2px #fff, 0 0 0 4px #ec1313);
}

.us-lp:not(#_).is-disabled .us-lp__toggle {
    cursor: not-allowed;
    opacity: 0.6;
    background: var(--us-field, rgba(0, 0, 0, 0.04));
}

.us-lp:not(#_) .us-lp__value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.us-lp:not(#_) .us-lp__chevron {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    color: var(--us-gray-500, #707070);
    transition: transform 0.2s ease;
}

.us-lp:not(#_).is-open .us-lp__chevron {
    transform: rotate(180deg);
}

.us-lp:not(#_) .us-lp__panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 6px);
    z-index: 100050;
    display: flex;
    flex-direction: column;
    max-height: 320px;
    background: var(--us-surface, #fff);
    border-radius: var(--us-r-lg, 12px);
    box-shadow: var(--us-shadow-lg, 0 12px 16px rgba(0, 0, 0, 0.12));
    overflow: hidden;
    animation: us-lp-in 0.16s ease-out;
}

.us-lp:not(#_) .us-lp__panel[hidden] {
    display: none;
}

.us-lp:not(#_) .us-lp__head {
    padding: 8px;
    border-bottom: 1px solid var(--us-divider, rgba(0, 0, 0, 0.08));
}

.us-lp:not(#_) .us-lp__search {
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    border-radius: var(--us-r-sm, 8px);
    background: var(--us-field, rgba(0, 0, 0, 0.04));
    color: var(--_text);
    font: inherit;
    font-size: var(--us-fs-base, 14px);
    outline: 0;
    box-shadow: none;
    transform: none;
}

.us-lp:not(#_) .us-lp__search:focus {
    background: var(--us-field-h, rgba(0, 0, 0, 0.08));
    box-shadow: var(--us-ring, 0 0 0 2px #fff, 0 0 0 4px #0f3bd1);
}

.us-lp:not(#_) .us-lp__list {
    list-style: none;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.us-lp:not(#_) .us-lp__option {
    margin: 0;
    padding: 10px 12px;
    min-height: 40px;
    border-radius: var(--us-r-sm, 8px);
    color: var(--_text);
    font-size: var(--us-fs-base, 14px);
    line-height: 1.5;
    cursor: pointer;
}

.us-lp:not(#_) .us-lp__option:hover {
    background: var(--us-hover, rgba(0, 0, 0, 0.04));
}

.us-lp:not(#_) .us-lp__option.is-active {
    background: var(--_soft);
    color: var(--_primary);
}

.us-lp:not(#_) .us-lp__option[aria-selected="true"] {
    font-weight: 500;
}

.us-lp:not(#_) .us-lp__option[aria-selected="true"]::after {
    content: "✓";
    float: left;
    color: var(--_primary);
}

.us-lp:not(#_) .us-lp__empty {
    padding: 18px 12px;
    color: var(--_muted);
    text-align: center;
    font-size: var(--us-fs-base, 14px);
}

@keyframes us-lp-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* Bottom sheet on phones: thumb friendly and never clipped by the viewport. */
@media (max-width: 640px) {
    .us-lp:not(#_).is-open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 100049;
        background: rgba(0, 0, 0, 0.45);
        animation: us-lp-fade 0.2s ease-out;
    }

    .us-lp:not(#_) .us-lp__panel {
        position: fixed;
        inset: auto 0 0 0;
        top: auto;
        max-height: min(72vh, 540px);
        border-radius: var(--us-r-xl, 16px) var(--us-r-xl, 16px) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
        animation: us-lp-up 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .us-lp:not(#_) .us-lp__head {
        padding: 14px 12px 10px;
    }

    .us-lp:not(#_) .us-lp__head::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        margin: -4px auto 10px;
        border-radius: var(--us-r-pill, 1024px);
        background: var(--us-gray-300, #c4c4c4);
    }

    .us-lp:not(#_) .us-lp__option {
        padding: 13px 14px;
        font-size: var(--us-fs-lg, 16px);
    }
}

@keyframes us-lp-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes us-lp-fade {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .us-lp:not(#_) .us-lp__panel,
    .us-lp:not(#_) .us-lp__chevron {
        animation: none;
        transition: none;
    }
}
