/**
 * Thai Address Picker — chained <select> styles
 *
 * Targets the <select> elements that the JS injects in place of the
 * 4 free-text inputs (billing/shipping/popup × city/district/state).
 * Uses the same brand color (#325D53) and field metrics (52px tall,
 * 8px radius, 2px border) as the rest of the checkout form.
 */

/* Identify the converted selects via [data-ba-thai-bound="1"] so we
   only target what we actually replaced — not random theme selects. */
select[data-ba-thai-bound="1"] {
    width: 100%;
    height: 52px;
    padding: 14px 45px 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: 'Prompt', 'Inter', -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1C2029;
    background-color: #ffffff;
    /* Custom chevron in brand color (replaces native arrow) */
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23325D53" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 20px;
    transition: border-color 200ms cubic-bezier(.2,0,.2,1),
                box-shadow   200ms cubic-bezier(.2,0,.2,1);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

select[data-ba-thai-bound="1"]:hover:not(:disabled) {
    border-color: #C9CED6;
}

select[data-ba-thai-bound="1"]:focus {
    border-color: #325D53;
    box-shadow: 0 0 0 3px rgba(50, 93, 83, 0.18),
                0 2px 8px rgba(50, 93, 83, 0.08);
}

select[data-ba-thai-bound="1"]:disabled {
    background-color: #F7F8FA;
    color: #9BA2AE;
    cursor: not-allowed;
    /* Greyed-out chevron when disabled */
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%239BA2AE" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
}

/* Postcode input becomes readonly, auto-filled from the picked tambon.
   Style it slightly differently so user knows not to type. */
input[data-ba-thai-bound="1"][readonly] {
    background-color: #F7F8FA;
    color: #325D53;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: default;
}

input[data-ba-thai-bound="1"][readonly]:focus {
    /* Don't show a hard focus ring on a readonly field — too noisy */
    border-color: #e0e0e0;
    box-shadow: none;
}

/* Style the placeholder option (— เลือก... —) so it reads as a hint */
select[data-ba-thai-bound="1"] option[value=""] {
    color: #9BA2AE;
}

select[data-ba-thai-bound="1"]:invalid {
    color: #9BA2AE;
}
select[data-ba-thai-bound="1"] option {
    color: #1C2029;
}

/* Mobile popup variants — popup uses smaller form fields with no labels.
   Keep the same metrics so the popup grid still aligns. */
.address-popup select[data-ba-thai-bound="1"],
.popup-form-row select[data-ba-thai-bound="1"] {
    height: 48px;
    padding: 12px 42px 12px 16px;
    font-size: 14px;
}

.address-popup input[data-ba-thai-bound="1"][readonly],
.popup-form-row input[data-ba-thai-bound="1"][readonly] {
    height: 48px;
    padding: 12px 16px;
    font-size: 14px;
}

/* When a parent form-row was originally form-row-half, native <select>
   inherits the half-width via the parent — no extra CSS needed.
   But ensure long Thai option labels truncate nicely on small phones. */
@media (max-width: 480px) {
    select[data-ba-thai-bound="1"] {
        font-size: 14px;
        padding-right: 38px;
        background-position: right 10px center;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    select[data-ba-thai-bound="1"] {
        transition: none;
    }
}
