/**
 * PWL Country Code Phone - Frontend Styles
 */

/* Phone input wrapper styling */
.phone-input-wrapper {
    display: flex !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: 100% !important;
}

.country-code-display {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 12px !important;
    background: #f8f9fa !important;
    border: 1px solid #ddd !important;
    border-right: none !important;
    border-radius: 4px 0 0 4px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    min-width: 70px !important;
    text-align: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

.phone-input-wrapper input[type="tel"],
.phone-input-wrapper input[name*="phone"] {
    flex: 1 !important;
    min-width: 0 !important;
    border-radius: 0 4px 4px 0 !important;
    border-left: none !important;
    margin: 0 !important;
}

.phone-input-wrapper input:focus {
    border-color: #007cba !important;
    box-shadow: 0 0 0 1px #007cba !important;
    outline: none !important;
}

.phone-input-wrapper .country-code-display + input:focus {
    border-left: none !important;
}

/* Country code select dropdown styling */
.phone-field-wrapper {
    display: flex !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: 100% !important;
}

#country-code-select,
#country-code-select-backup {
    padding: 12px !important;
    border: 1px solid hsla(0,0%,7%,.8) !important;
    border-radius: 4px 0 0 4px !important;
    border-right: none !important;
    background: white !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    min-width: 120px !important;
    max-width: 140px !important;
    height: auto !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    vertical-align: top !important;
    display: flex !important;
    align-items: center !important;
}

/* Dropdown options styling */
#country-code-select option,
#country-code-select-backup option {
    padding: 8px 8px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.phone-field-wrapper input[type="tel"],
.phone-field-wrapper input[name*="phone"] {
    border-radius: 0 4px 4px 0 !important;
    border-left: none !important;
    flex: 1 !important;
    margin: 0 !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    vertical-align: top !important;
}

/* WooCommerce blocks compatibility */
.wc-block-components-text-input.has-validation-error .phone-field-wrapper input {
    border-color: #e2401c !important;
}

.wc-block-components-text-input.has-validation-error #country-code-select,
.wc-block-components-text-input.has-validation-error #country-code-select-backup {
    border-color: #e2401c !important;
}

/* Validation styling */
#country-code-select:invalid,
#country-code-select-backup:invalid {
    border-color: #e2401c !important;
    box-shadow: 0 0 0 1px #e2401c !important;
}

#country-code-select:focus:invalid,
#country-code-select-backup:focus:invalid {
    outline-color: #e2401c !important;
}

/* Perfect alignment */
.phone-field-wrapper {
    align-items: center !important;
}

#country-code-select,
#country-code-select-backup,
.phone-field-wrapper input[type="tel"],
.phone-field-wrapper input[name*="phone"] {
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
}

/* Text baseline alignment */
#country-code-select,
#country-code-select-backup {
    justify-content: center !important;
}

/* WooCommerce blocks specific styling */
.wc-block-components-text-input .phone-input-wrapper {
    width: 100% !important;
}

.wc-block-components-text-input .phone-input-wrapper input {
    width: auto !important;
    flex: 1 !important;
}

.wc-block-checkout__billing-fields #billing-phone, 
.wc-block-checkout__shipping-fields #shipping-phone {
    border: 1px solid hsla(0,0%,7%,.8) !important;
    border-radius: 4px !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .country-code-display {
        min-width: 60px !important;
        padding: 0 8px !important;
        font-size: 13px !important;
    }
    
    #country-code-select,
    #country-code-select-backup {
        min-width: 100px !important;
        font-size: 13px !important;
    }
    
    #country-code-select,
    #country-code-select-backup,
    .phone-field-wrapper input[type="tel"],
    .phone-field-wrapper input[name*="phone"] {
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 6px 10px !important;
    }
}

/* Disabled/read-only styling */
#country-code-select:disabled,
#country-code-select-backup:disabled {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    opacity: 0.8 !important;
}

/* Loading state */
.pwl-ccp-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error states */
.pwl-ccp-error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 1px #dc3545 !important;
}

label[for="shipping-phone"],
label[for="billing-phone"] {
    padding-left: 70px;
    display: inline-block !important;
}

.is-active label[for="shipping-phone"],
.is-active label[for="billing-phone"]{
    padding-left: 90px !important;
}

@media (max-width: 768px) {


    label[for="shipping-phone"],
    label[for="billing-phone"] {
        padding-left: 60px !important;
        display: inline-block !important;
    }
    
    .is-active label[for="shipping-phone"],
    .is-active label[for="billing-phone"]{
        padding-left: 80px !important;
    }
}