.country-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.country-popup-content {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.country-popup-header h3 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 24px;
}

.country-popup-header p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 16px;
}

.country-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    margin-bottom: 20px;
    background-color: white;
}

.country-select:focus {
    border-color: #007cba;
    outline: none;
}

.btn-confirm {
    background-color: #007cba;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-confirm:hover:not(:disabled) {
    background-color: #005a87;
}

.btn-confirm:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.country-popup-actions {
    margin-top: 20px;
}

/* Country Flags Grid */
.country-flags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.country-flag-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.country-flag-item:hover {
    border-color: #007cba;
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
}

.country-flag-item:active {
    transform: translateY(0);
}

.flag-icon {
    width: 40px;
    height: 30px;
    border-radius: 4px;
    margin-bottom: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid #ddd;
}

.country-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.tax_label {
    display: none;
}

/* Flag backgrounds using PNG images - Official ASEAN country flags */
/* Brunei Darussalam */
.flag-bn {
    background-image: url("../flags/BN.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Cambodia */
.flag-kh {
    background-image: url("../flags/KH.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Indonesia */
.flag-id {
    background-image: url("../flags/ID.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Laos */
.flag-la {
    background-image: url("../flags/LA.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Malaysia */
.flag-my {
    background-image: url("../flags/MY.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Myanmar */
.flag-mm {
    background-image: url("../flags/MM.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Philippines */
.flag-ph {
    background-image: url("../flags/PH.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Singapore */
.flag-sg {
    background-image: url("../flags/SG.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Thailand */
.flag-th {
    background-image: url("../flags/TH.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Vietnam */
.flag-vn {
    background-image: url("../flags/VN.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Loading state for flag items */
.country-flag-item.loading {
    opacity: 0.7;
    pointer-events: none;
}

.country-flag-item.loading .flag-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Country Switcher Widget Styles */
#country-switcher-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.country-switcher-box {
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.country-switcher-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.country-switcher-dropdown {
    position: relative;
}

.country-switcher-selected {
    font-size: 12px;
    padding: 8px 30px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    min-width: 180px;
    transition: border-color 0.2s;
}

.country-switcher-selected:hover {
    border-color: #007cba;
}

.country-switcher-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
}

.country-switcher-dropdown.open .country-switcher-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.country-switcher-options {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
    max-height: 250px;
    overflow-y: auto;
    display: none;
    margin-bottom: 5px;
}

.country-switcher-dropdown.open .country-switcher-options {
    display: block;
}

.country-switcher-option {
    padding: 10px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.country-switcher-option:last-child {
    border-bottom: none;
}

.country-switcher-option:hover {
    background: #f5f5f5;
}

.country-switcher-option.selected {
    background: #e8f4fc;
    color: #007cba;
    font-weight: 500;
}

/* Responsive adjustments for flags */
@media (max-width: 768px) {
    .country-flags-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .country-flag-item {
        padding: 12px 8px;
    }
    
    .flag-icon {
        width: 35px;
        height: 26px;
    }
    
    .country-name {
        font-size: 11px;
    }
    
    /* Move country switcher widget above mobile navigation bar */
    #country-switcher-widget {
        bottom: 80px !important;
    }
    
    /* Move country switcher widget even higher on configurator page (double nav bar) */
    #country-switcher-widget.configurator-page {
        bottom: 120px !important;
    }
}

/* Hide validation errors during country update (page will reload anyway) */
form.checkout.fl-updating-country .woocommerce-invalid,
form.checkout.fl-updating-country .form-row.woocommerce-invalid input,
form.checkout.fl-updating-country .form-row.woocommerce-invalid select {
    border-color: #ddd !important;
    box-shadow: none !important;
}
