/* Besked for WP - Checkout Styles */

/* =====================================================
   Enhanced Phone Field with Country Prefix Selector
   ===================================================== */
.besked-phone-container {
    display: flex !important;
    align-items: stretch;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}

.besked-phone-container:focus-within {
    border-color: #38BDF8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

/* Prefix selector */
.besked-phone-prefix-select {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
    min-width: 90px;
    font-size: 14px;
    position: relative;
    flex-shrink: 0;
}

.besked-phone-prefix-select:hover {
    background: #f3f4f6;
}

.besked-phone-prefix-flag {
    font-size: 20px;
    line-height: 1;
}

.besked-phone-prefix-code {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    white-space: nowrap;
}

.besked-phone-prefix-arrow {
    margin-left: 2px;
    color: #9ca3af;
    font-size: 10px;
    transition: transform 0.2s;
}

.besked-phone-prefix-select.open .besked-phone-prefix-arrow {
    transform: rotate(180deg);
}

/* Hidden native select for form submission */
.besked-phone-prefix-hidden {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Phone input */
.besked-phone-container input.besked-phone-input,
.besked-phone-container input[data-besked-phone] {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 10px 14px;
    font-size: 15px;
    letter-spacing: 0.5px;
    background: transparent;
    min-width: 0;
    -moz-appearance: textfield;
    display: block;
    width: auto;
    height: auto;
}

.besked-phone-container input.besked-phone-input:focus,
.besked-phone-container input[data-besked-phone]:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Remove WooCommerce default styling on the wrapped input */
.besked-phone-container input::-webkit-outer-spin-button,
.besked-phone-container input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Country dropdown */
.besked-phone-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 99999;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 320px;
    margin-top: 4px;
    display: none;
}

.besked-phone-dropdown.open {
    display: block;
    animation: besked-dropdown-in 0.15s ease-out;
}

@keyframes besked-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dropdown search */
.besked-phone-dropdown-search {
    position: sticky;
    top: 0;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}

.besked-phone-dropdown-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
}

.besked-phone-dropdown-search input:focus {
    border-color: #38BDF8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Dropdown items */
.besked-phone-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}

.besked-phone-dropdown-item:hover {
    background: #f0f9ff;
}

.besked-phone-dropdown-item.active {
    background: #eff6ff;
    font-weight: 600;
}

.besked-phone-dropdown-item-flag {
    font-size: 20px;
    flex-shrink: 0;
}

.besked-phone-dropdown-item-name {
    flex: 1;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.besked-phone-dropdown-item-prefix {
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
}

/* =====================================================
   WhatsApp Consent Toggle (iOS Style)
   ===================================================== */
.besked-consent-field {
    display: block;
    margin: 16px 0 20px;
    padding: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    transition: all 0.3s;
}

.besked-consent-field:has(input:checked) {
    background: #dcfce7;
    border-color: #86efac;
}

.besked-consent-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    user-select: none;
}

.besked-consent-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* iOS-style slider */
.besked-consent-slider {
    position: relative;
    display: inline-block;
    width: 52px;
    min-width: 52px;
    height: 28px;
    background-color: #d1d5db;
    border-radius: 28px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.besked-consent-slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.besked-consent-toggle input:checked + .besked-consent-slider {
    background-color: #25D366;
}

.besked-consent-toggle input:checked + .besked-consent-slider::before {
    transform: translateX(24px);
}

.besked-consent-toggle input:focus + .besked-consent-slider {
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.25);
}

/* Label text */
.besked-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
}

.besked-whatsapp-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

/* =====================================================
   Responsive
   ===================================================== */
@media screen and (max-width: 600px) {
    .besked-phone-dropdown {
        width: calc(100vw - 40px);
        max-width: 320px;
    }

    .besked-consent-toggle {
        gap: 10px;
    }

    .besked-consent-label {
        font-size: 13px;
    }

    .besked-consent-slider {
        width: 46px;
        min-width: 46px;
        height: 24px;
    }

    .besked-consent-slider::before {
        width: 18px;
        height: 18px;
    }

    .besked-consent-toggle input:checked + .besked-consent-slider::before {
        transform: translateX(22px);
    }
}
