/* ===================================
   PHONE INPUT COMPONENT

   Styles pour le composant phone-input géré par Stimulus
   Intégration avec Basecoat CSS et design system
   ================================== */

/* International Telephone Input - Custom Country Dropdown */

.intl-tel-input {
    position: relative;
    display: flex;
    width: 100%;
}

.intl-tel-input * {
    box-sizing: border-box;
}

/* Flag Container */
.flag-container {
    position: relative;
}

.selected-flag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d1d5db;
    border-right: none;
    border-radius: 0.375rem 0 0 0.375rem;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 80px;
}

.selected-flag:hover {
    background: #f3f4f6;
}

.selected-flag:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Arrow Icon */
.iti-arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #6b7280;
    transition: transform 0.2s ease;
}

.iti-arrow.arrow-up {
    transform: rotate(180deg);
}

/* Country Flag - Base styles */
.flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
    position: relative;
}

/* Country List Dropdown */
.country-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 1000;
    width: 320px;
    max-height: 280px;
    overflow-y: auto;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.country-list.dropup {
    bottom: calc(100% + 4px);
    top: auto;
}

.country-list.hidden {
    display: none;
}

/* Search Box inside Dropdown */
.country-search {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.75rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

.country-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    outline: none;
}

.country-search input:focus {
    border-color: #3b82f6;
    ring: 2px;
    ring-color: rgba(59, 130, 246, 0.5);
}

/* Country List Items */
.country-list-items {
    padding: 0.5rem 0;
}

.country {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.country:hover {
    background-color: #f3f4f6;
}

.country.preferred {
    background-color: #f9fafb;
}

.country .flag-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.country .country-name {
    flex: 1;
    font-size: 0.875rem;
    color: #1f2937;
}

.country .country-native-name {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #6b7280;
    font-style: italic;
}

.country .dial-code {
    flex-shrink: 0;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.country-list .divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.5rem 0;
    list-style: none;
}

/* Phone Number Input */
.intl-tel-input input[type="tel"] {
    flex: 1;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0 0.375rem 0.375rem 0;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.intl-tel-input input[type="tel"]:focus {
    border-color: #3b82f6;
    ring: 2px;
    ring-color: rgba(59, 130, 246, 0.5);
}

/* Scrollbar styling for country list */
.country-list::-webkit-scrollbar {
    width: 8px;
}

.country-list::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 0 0.5rem 0.5rem 0;
}

.country-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.country-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .country-list {
        width: 100%;
        min-width: 250px;
        max-width: calc(100vw - 2rem);
    }
}
