/* ============================================
   COUNTRY SELECTOR CONTAINER
   ============================================ */
.kbl-country-selector {
    position: relative;
    width: 100%;
    font-family: inherit;
    z-index: 1000;
    /* Establish high stacking context */
}

/* ============================================
   SELECTED DISPLAY - Squared, Compact
   ============================================ */
.kbl-country-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 42px;
    padding: 0 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.kbl-country-selected:hover {
    border-color: #1e3a5f;
}

.kbl-country-selected:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.kbl-country-flag {
    font-size: 1.1rem;
    /* Smaller flags */
    line-height: 1;
    flex-shrink: 0;
}

.kbl-country-name {
    flex: 1;
    font-size: 0.875rem;
    color: #1e3a5f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kbl-country-arrow {
    flex-shrink: 0;
    color: #9ca3af;
    transition: transform 0.2s ease;
}

.kbl-country-dropdown.open~.kbl-country-selected .kbl-country-arrow {
    transform: rotate(180deg);
}

/* ============================================
   DROPDOWN - Modern & Inside Viewport
   ============================================ */
.kbl-country-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.kbl-country-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ============================================
   SEARCH INPUT
   ============================================ */
.kbl-country-search {
    padding: 8px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
}

.kbl-country-search-input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-family: inherit;
    color: #1e3a5f;
    background: #ffffff;
    box-sizing: border-box;
}

.kbl-country-search-input:focus {
    outline: none;
    border-color: #1e3a5f;
}

/* ============================================
   COUNTRY LIST
   ============================================ */
.kbl-country-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.kbl-country-list::-webkit-scrollbar {
    width: 5px;
}

.kbl-country-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ============================================
   COUNTRY OPTION
   ============================================ */
.kbl-country-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
}

.kbl-country-option:hover,
.kbl-country-option.highlighted {
    background-color: #f3f4f6;
}

.kbl-country-option.selected {
    background-color: #eff6ff;
    color: #1e3a5f;
}

.kbl-option-flag {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.kbl-option-name {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
}

.kbl-option-prefix {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================
   PHONE INPUT WITH PREFIX - Unified look
   ============================================ */
.kbl-phone-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #ffffff;
    overflow: hidden;
    transition: all 0.15s ease;
}

.kbl-phone-wrapper:focus-within {
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.kbl-phone-prefix {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 10px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    white-space: nowrap;
    user-select: none;
    min-width: 45px;
}

.kbl-phone-input {
    flex: 1;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 0.875rem !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 0.875rem !important;
}

/* ============================================
   RESPONSIVE & MOBILE FIXES
   ============================================ */
@media (max-width: 640px) {
    .kbl-country-dropdown {
        position: fixed;
        /* Stick to bottom or smarter position for mobile */
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
        box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
    }

    .kbl-country-dropdown.open {
        transform: translateY(0);
    }

    .kbl-country-list {
        max-height: 50vh;
        /* Better for mobile viewing */
    }

    .kbl-country-search {
        padding: 12px;
    }
}