.phone-field {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.phone-field__toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 1px solid #ced4da;
    border-right: 0;
    border-radius: 6px 0 0 6px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #212529;
}

.phone-field__toggle:hover {
    background: #eef0f2;
}

.phone-field.is-invalid .phone-field__toggle {
    border-color: #dc3545;
}

.phone-field__flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.phone-field__dial {
    white-space: nowrap;
}

.phone-field__caret {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    transition: transform .15s ease;
}

.phone-field.is-open .phone-field__caret {
    transform: rotate(180deg);
}

.phone-field__number-input {
    flex: 1 1 auto;
    min-width: 0;
    border-radius: 0 6px 6px 0 !important;
}

.phone-field__panel {
    position: absolute;
    z-index: 1050;
    top: calc(100% + 4px);
    left: 0;
    width: 280px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    overflow: hidden;
}

/* Flips the panel above the toggle when there isn't enough room below it (e.g. a footer field) */
.phone-field.drop-up .phone-field__panel {
    top: auto;
    bottom: calc(100% + 4px);
}

.phone-field:not(.is-open) .phone-field__panel {
    display: none;
}

.phone-field__search {
    width: 100%;
    box-sizing: border-box;
    border: 0;
    border-bottom: 1px solid #dee2e6;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
}

.phone-field__list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
}

.phone-field__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    color: #212529;
}

.phone-field__option:hover,
.phone-field__option.is-active {
    background: #f1f3f5;
}

.phone-field__option img {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

.phone-field__option-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.phone-field__option-dial {
    color: #6c757d;
    flex-shrink: 0;
}

.phone-field__empty {
    padding: 10px;
    font-size: 13px;
    color: #6c757d;
    text-align: center;
}

/* Backend (Tailwind) look: this block only intensifies contrast for elements already under .phone-field--tw, doesn't depend on Tailwind classes being present */
.phone-field--tw .phone-field__toggle {
    background: #f9fafb;
    border-color: #d1d5db;
}

.phone-field--tw .phone-field__number-input {
    border-radius: 0 4px 4px 0 !important;
}
