/* ==========================================================================
   Custom Checkout Styles - Phone Input with Country Flags
   ========================================================================== */

/* Phone input wrapper with flag display */
.phone-input-wrapper {
    position: relative;
    width: 100%;
}

/* Phone input container - relative positioning for absolute children */
.phone-input-container {
    position: relative;
    width: 100%;
    display: block;
}

.phone-input-container .phone-flag-display {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    cursor: pointer;
    z-index: 5;
    width: 20px;
    text-align: center;
    line-height: 1;
}

.phone-input-container .phone-dropdown-arrow {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
    cursor: pointer;
    transition: transform 0.2s;
    line-height: 1;
}

.phone-input-container .phone-dropdown-arrow.open {
    transform: translateY(-50%) rotate(180deg);
}

/* Enhanced phone input field */
.phone-input-wrapper input[type="tel"] {
    padding-left: 50px !important;
    padding-right: 35px !important;
    width: 100%;
    box-sizing: border-box;
}

/* Country dropdown container */
.phone-country-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.phone-country-dropdown.open {
    display: block;
}

.phone-country-dropdown .country-option {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.phone-country-dropdown .country-option:hover,
.phone-country-dropdown .country-option.selected {
    background-color: #f8f9fa;
}

.phone-country-dropdown .country-option:last-child {
    border-bottom: none;
}

.phone-country-dropdown .country-flag {
    font-size: 18px;
    margin-right: 10px;
    width: 25px;
    text-align: center;
}

.phone-country-dropdown .country-code {
    font-weight: bold;
    color: #333;
    margin-right: 10px;
    font-size: 14px;
    min-width: 50px;
}

.phone-country-dropdown .country-name {
    color: #666;
    font-size: 14px;
}

/* Enhanced input focus state */
.phone-input-wrapper input[type="tel"]:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

/* Built-in validation styles */
.phone-validation-error {
    color: #dc3232;
    font-size: 0.9em;
    margin-top: 5px;
    display: block;
}

.phone-input-wrapper .woocommerce-invalid {
    border-color: #dc3232 !important;
    box-shadow: 0 0 0 1px #dc3232 !important;
}

/* Help text styling */
.phone-help-text {
    color: #666;
    font-size: 12px;
    margin-top: 5px;
    display: block;
    transition: color 0.2s;
}

.phone-help-text.updated {
    color: #007cba;
    font-weight: bold;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .phone-input-wrapper .phone-flag-display {
        left: 12px;
        font-size: 16px;
        width: 18px;
    }

    .phone-input-wrapper .phone-dropdown-arrow {
        left: 35px;
    }

    .phone-input-wrapper input[type="tel"] {
        padding-left: 45px !important;
        padding-right: 30px !important;
        font-size: 16px;
    }

    .phone-country-dropdown .country-option {
        padding: 12px 15px;
    }
}

/* Hide shipping methods cleanly */
.shipping-methods-content {
    display: none !important;
}

/* intl-tel-input Flag Sprite System - Using their exact professional flag implementation */
.iti__flag {
    width: 20px;
    height: 15px;
    background-image: url("https://intl-tel-input.com/intl-tel-input/img/flags.webp");
    background-repeat: no-repeat;
    background-color: #DBDBDB;
    background-size: cover;
    display: inline-block;
    box-shadow: 0 0 1px 0 rgba(0,0,0,0.08);
}

/* Country offset variables for flag sprite positioning - EU countries */
.iti__at { --iti-flag-offset: -176px; }
.iti__be { --iti-flag-offset: -208px; }
.iti__cz { --iti-flag-offset: -816px; }
.iti__de { --iti-flag-offset: -784px; }
.iti__dk { --iti-flag-offset: -832px; }
.iti__ee { --iti-flag-offset: -896px; }
.iti__es { --iti-flag-offset: -688px; }
.iti__fi { --iti-flag-offset: -960px; }
.iti__fr { --iti-flag-offset: -992px; }
.iti__gr { --iti-flag-offset: -1120px; }
.iti__hr { --iti-flag-offset: -1184px; }
.iti__hu { --iti-flag-offset: -1200px; }
.iti__ie { --iti-flag-offset: -1264px; }
.iti__it { --iti-flag-offset: -1312px; }
.iti__lu { --iti-flag-offset: -1488px; }
.iti__lv { --iti-flag-offset: -1504px; }
.iti__lt { --iti-flag-offset: -1472px; }
.iti__mt { --iti-flag-offset: -1696px; }
.iti__nl { --iti-flag-offset: -1840px; }
.iti__no { --iti-flag-offset: -1872px; }
.iti__pl { --iti-flag-offset: -1968px; }
.iti__pt { --iti-flag-offset: -544px; }
.iti__ro { --iti-flag-offset: -2048px; }
.iti__se { --iti-flag-offset: -2224px; }
.iti__si { --iti-flag-offset: -2288px; }
.iti__sk { --iti-flag-offset: -2320px; }
.iti__bg { --iti-flag-offset: -240px; }
.iti__cy { --iti-flag-offset: -816px; }

.iti__flag {
    background-position: var(--iti-flag-offset, 0) 0;
}

/* Selected country highlighting */
.country-option.selected .country-flag,
.country-option.selected .country-name {
    font-weight: bold;
}

.country-option.selected .country-code {
    color: #007cba;
}

/* Smooth animation for dropdown */
.phone-country-dropdown {
    animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search functionality for large country lists */
.phone-country-search {
    padding: 8px 15px;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

.phone-country-search input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 5px 8px;
    font-size: 14px;
    outline: none;
}

.phone-country-search input:focus {
    border-color: #007cba;
}
