/**
 * PhoneInputWidget — single unified pill shell.
 * One outer border + radius; sharp internal divider only.
 */
.b2b-phone-input {
    --b2b-phone-border: #e1e3ea;
    --b2b-phone-border-focus: var(--primary, #34087a);
    --b2b-phone-bg: #ffffff;
    --b2b-phone-bg-soft: #f5f6f8;
    --b2b-phone-text: var(--foreground, #181c32);
    --b2b-phone-muted: var(--muted-foreground, #a1a5b7);
    --b2b-phone-danger: #e5484d;
    --b2b-phone-radius: 12px;
    --b2b-phone-height: 48px;
    --b2b-phone-gap: 0.5rem;
    --b2b-phone-label-padding-bottom: 0;
    --b2b-phone-input-padding: 0 0.95rem;
    --b2b-phone-local-height: 100%;
    --b2b-phone-local-min-height: 100%;
    --b2b-phone-shell-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
    --b2b-phone-focus-ring: 0 0 0 3px color-mix(in srgb, var(--b2b-phone-border-focus) 14%, transparent);
    --b2b-phone-dropdown-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);

    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--b2b-phone-gap);
    min-width: 0;
}

.b2b-phone-input--fit {
    width: auto;
    max-width: 100%;
}

.b2b-phone-input__label {
    display: block;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--b2b-phone-text);
    padding-bottom: var(--b2b-phone-label-padding-bottom);
}

.b2b-phone-input__req {
    color: var(--b2b-phone-danger);
    font-weight: 700;
    margin-inline-start: 0.15rem;
}

.b2b-phone-input__field {
    width: 100%;
    min-width: 0;
}

/* Unified shell — the only bordered surface */
.b2b-phone-input__control {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    width: 100%;
    min-width: 0;
    height: var(--b2b-phone-height);
    direction: ltr;
    border: 1px solid var(--b2b-phone-border);
    border-radius: var(--b2b-phone-radius);
    background: var(--b2b-phone-bg);
    box-shadow: var(--b2b-phone-shell-shadow);
    /* MUST stay visible — KTSelect dropdown renders inside this shell */
    overflow: visible;
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.b2b-phone-input__control:hover {
    border-color: color-mix(in srgb, var(--b2b-phone-border-focus) 28%, var(--b2b-phone-border));
}

.b2b-phone-input__control:focus-within {
    border-color: var(--b2b-phone-border-focus);
    box-shadow: var(--b2b-phone-shell-shadow), var(--b2b-phone-focus-ring);
}

.b2b-phone-input__control:has(.kt-select-open),
.b2b-phone-input__control:has(.kt-select-wrapper.kt-select-open) {
    z-index: 40;
}

/* ---- Country segment (left) ---- */
.b2b-phone-input__country-wrap {
    position: relative;
    flex: 0 0 auto;
    min-width: 6.75rem;
    max-width: 8.5rem;
    align-self: stretch;
    background: var(--b2b-phone-bg-soft);
    border-right: 1px solid var(--b2b-phone-border);
    border-radius: var(--b2b-phone-radius) 0 0 var(--b2b-phone-radius);
    overflow: visible;
    z-index: 2;
}

.b2b-phone-input__country-wrap:has(.kt-select-open),
.b2b-phone-input__country-wrap:has(.kt-select-wrapper.kt-select-open) {
    z-index: 50;
}

.b2b-phone-input__country-wrap .kt-select,
.b2b-phone-input__country-wrap select.b2b-phone-input__country,
.b2b-phone-input__country-wrap [data-kt-select-wrapper],
.b2b-phone-input__country-wrap .kt-select-wrapper {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
    position: relative !important;
}

.b2b-phone-input__country-wrap .kt-select-display,
.b2b-phone-input__country-wrap .b2b-phone-input__country,
.b2b-phone-input__country-wrap .b2b-phone-input__country-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.45rem !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    padding: 0 0.7rem !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--b2b-phone-text) !important;
    box-shadow: none !important;
    outline: none !important;
    cursor: pointer !important;
}

.b2b-phone-input__country-wrap .kt-select-display:hover,
.b2b-phone-input__country-wrap .kt-select-wrapper.kt-select-open .kt-select-display,
.b2b-phone-input__country-wrap .kt-select-display:focus,
.b2b-phone-input__country-wrap .kt-select-display:focus-visible {
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.b2b-phone-input__display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    min-width: 0;
    direction: ltr;
}

.b2b-phone-input__flag-wrap {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 1.65rem !important;
    height: 1.2rem !important;
    overflow: hidden !important;
    border-radius: 2px !important;
    background: transparent !important;
    box-shadow: none !important;
    line-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.b2b-phone-input__flag,
.b2b-phone-input__display img,
.b2b-phone-input__option img,
.b2b-phone-input__dropdown img,
.kt-select-dropdown.b2b-phone-input__dropdown img,
.b2b-phone-input__country-wrap .kt-select-display img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
    border: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.b2b-phone-input__option .b2b-phone-input__flag-wrap,
.b2b-phone-input__dropdown .b2b-phone-input__flag-wrap,
.kt-select-dropdown.b2b-phone-input__dropdown .b2b-phone-input__flag-wrap {
    width: 2rem !important;
    height: 1.4rem !important;
}

.b2b-phone-input__dial {
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: var(--b2b-phone-text);
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: isolate;
}

/* Chevron: always ki-down; rotate when dropdown is open (aria-expanded). */
.b2b-phone-input__chevron {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-inline-start: 0.15rem;
    line-height: 1 !important;
    font-size: 0.85rem !important;
    color: var(--b2b-phone-muted) !important;
    opacity: 0.85;
    transition: transform 0.15s ease;
}

.b2b-phone-input__country-wrap .kt-select-display[aria-expanded="true"] .b2b-phone-input__chevron,
.b2b-phone-input__country-btn[aria-expanded="true"] .b2b-phone-input__chevron {
    transform: rotate(180deg);
}

/* ---- Local number segment (right) ---- */
.b2b-phone-input__local,
.b2b-phone-input input.b2b-phone-input__local,
.b2b-phone-input .b2b-phone-input__local.kt-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    height: var(--b2b-phone-local-height) !important;
    min-height: var(--b2b-phone-local-min-height) !important;
    max-height: none !important;
    padding: var(--b2b-phone-input-padding) !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 var(--b2b-phone-radius) var(--b2b-phone-radius) 0 !important;
    background: var(--b2b-phone-bg) !important;
    color: var(--b2b-phone-text) !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    line-height: 1.25 !important;
    box-shadow: none !important;
    outline: none !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: isolate;
    appearance: none !important;
    -webkit-appearance: none !important;
    position: relative;
    z-index: 1;
}

.b2b-phone-input__local::placeholder {
    color: var(--b2b-phone-muted) !important;
    opacity: 1 !important;
    font-weight: 400 !important;
    text-align: inherit !important;
}

/*
 * RTL: placeholder and typed digits sit on the right (visual start).
 * Digits stay LTR via unicode-bidi so +/number order is preserved.
 */
html[lang="ar"] .b2b-phone-input__local:placeholder-shown,
html[dir="rtl"] .b2b-phone-input__local:placeholder-shown,
[dir="rtl"] .b2b-phone-input__local:placeholder-shown {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: plaintext;
}

html[lang="ar"] .b2b-phone-input__local:not(:placeholder-shown),
html[dir="rtl"] .b2b-phone-input__local:not(:placeholder-shown),
[dir="rtl"] .b2b-phone-input__local:not(:placeholder-shown) {
    direction: ltr !important;
    text-align: right !important;
    unicode-bidi: isolate;
}

.b2b-phone-input__local:hover,
.b2b-phone-input__local:focus,
.b2b-phone-input__local:focus-visible {
    border: 0 !important;
    outline: none !important;
    box-shadow: none !important;
    background: var(--b2b-phone-bg) !important;
}

.b2b-phone-input__local:disabled,
.b2b-phone-input__country-wrap .kt-select-wrapper.is-disabled .kt-select-display {
    opacity: 0.65 !important;
    cursor: not-allowed !important;
}

/* ---- Dropdown ---- */
.b2b-phone-input__dropdown,
.kt-select-dropdown.b2b-phone-input__dropdown {
    z-index: 3000 !important;
    min-width: 17.5rem !important;
    width: max(17.5rem, 100%) !important;
    max-width: min(22rem, calc(100vw - 2rem)) !important;
    padding: 0.35rem !important;
    border: 1px solid var(--b2b-phone-border) !important;
    border-radius: 12px !important;
    background: #fff !important;
    box-shadow: var(--b2b-phone-dropdown-shadow) !important;
    overflow: hidden !important; /* clip radius only — do NOT scroll here */
    max-height: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.b2b-phone-input__dropdown .kt-select-options,
.kt-select-dropdown.b2b-phone-input__dropdown .kt-select-options {
    max-height: 240px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important; /* single scrollbar lives here */
    padding: 0 !important;
    margin: 0 !important;
}

.b2b-phone-input__dropdown .kt-select-option,
.kt-select-dropdown.b2b-phone-input__dropdown .kt-select-option {
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 0.55rem 0.65rem !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--b2b-phone-text) !important;
    cursor: pointer !important;
}

.b2b-phone-input__dropdown .kt-select-option:hover,
.b2b-phone-input__dropdown .kt-select-option:focus,
.kt-select-dropdown.b2b-phone-input__dropdown .kt-select-option:hover {
    background: var(--b2b-phone-bg-soft) !important;
}

.b2b-phone-input__dropdown .kt-select-option.selected,
.b2b-phone-input__dropdown .kt-select-option[aria-selected="true"],
.kt-select-dropdown.b2b-phone-input__dropdown .kt-select-option.selected {
    background: #eef0f4 !important;
}

.b2b-phone-input__option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
    direction: ltr;
}

.b2b-phone-input__option-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--b2b-phone-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: start;
}

.b2b-phone-input__option-dial {
    flex: 0 0 auto;
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--b2b-phone-muted);
    direction: ltr;
    unicode-bidi: isolate;
}

.b2b-phone-input__option-check {
    width: 0.9rem;
    height: 0.9rem;
    flex-shrink: 0;
    margin-inline-start: 0.15rem;
    color: var(--b2b-phone-border-focus);
}

.b2b-phone-input__dropdown .kt-select-option.selected .b2b-phone-input__option-check,
.b2b-phone-input__dropdown .kt-select-option[aria-selected="true"] .b2b-phone-input__option-check,
.kt-select-dropdown.b2b-phone-input__dropdown .kt-select-option.selected .b2b-phone-input__option-check,
.b2b-phone-input__dropdown .kt-select-option.selected .b2b-phone-input__option-check.hidden,
.kt-select-option-selected .b2b-phone-input__option-check {
    display: block !important;
}

/* ---- Errors ---- */
.b2b-phone-input__errors {
    min-height: 0;
}

.b2b-phone-input__error,
.b2b-phone-input .help-block-error {
    margin: 0.15rem 0 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--b2b-phone-danger) !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
}

.field.invalid .b2b-phone-input__control,
.has-error .b2b-phone-input__control,
.b2b-phone-input.has-error .b2b-phone-input__control {
    border-color: var(--b2b-phone-danger) !important;
    box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.12) !important;
}

/* Kill landing page field rules fighting the shell */
.field .b2b-phone-input input.b2b-phone-input__local,
.contact-form .b2b-phone-input input.b2b-phone-input__local {
    width: auto !important;
    padding: var(--b2b-phone-input-padding, 0 0.95rem) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.field .b2b-phone-input .kt-select-display,
.contact-form .b2b-phone-input .kt-select-display {
    min-height: 100% !important;
    height: 100% !important;
    padding: 0 0.7rem !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.field.invalid .b2b-phone-input .kt-select-display,
.field.invalid .b2b-phone-input input.b2b-phone-input__local {
    border: 0 !important;
    box-shadow: none !important;
}

/* Flat chrome when shellShadow="none" is passed from the widget */
.b2b-phone-input[data-b2b-phone-flat] .b2b-phone-input__control:hover {
    border-color: var(--b2b-phone-border);
}

.b2b-phone-input[data-b2b-phone-flat] .b2b-phone-input__control:focus-within {
    box-shadow: var(--b2b-phone-focus-ring);
}

/* height="auto" — grow from input padding (landing-style) */
.b2b-phone-input[data-b2b-phone-auto-height] .b2b-phone-input__control {
    height: auto;
    min-height: 0;
    align-items: stretch;
}

.b2b-phone-input[data-b2b-phone-auto-height] input.b2b-phone-input__local {
    font: inherit !important;
    font-size: inherit !important;
    font-weight: 400 !important;
    line-height: 1.7 !important;
    color: var(--ink, var(--b2b-phone-text)) !important;
}

.b2b-phone-input[data-b2b-phone-auto-height] .b2b-phone-input__country-wrap .kt-select-display,
.b2b-phone-input[data-b2b-phone-auto-height] .b2b-phone-input__country-wrap .b2b-phone-input__country {
    height: 100% !important;
    min-height: 100% !important;
    padding: 0 0.7rem !important;
}

@media (max-width: 480px) {
    .b2b-phone-input__country-wrap {
        min-width: 6.25rem;
        max-width: 7.5rem;
    }

    .b2b-phone-input__dial {
        font-size: 0.8125rem;
    }
}
