/**
 * Checkout Custom Styles
 * Приховуємо зайві елементи WooCommerce, залишаємо тільки наші
 */

/* ПРИХОВУЄМО ДУБЛІКАТИ ПОЛІВ в секції Доставка */
.checkout-section .woocommerce-billing-fields > h3:not(#wcus-billing-fields h3),
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_first_name_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_last_name_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_company_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_country_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_state_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_address_1_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_address_2_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_city_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_postcode_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_phone_field,
.checkout-section .woocommerce-billing-fields__field-wrapper > #billing_email_field,
.checkout-section .woocommerce-shipping-fields,
.checkout-section .woocommerce-additional-fields {
    display: none !important;
}

/* ПОКАЗУЄМО ТІЛЬКИ поля плагіна НП (блок "Укажите адрес доставки") */
.checkout-section #wcus-billing-fields {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Показуємо контейнер з полями */
.checkout-section #wcus-billing-fields > div {
    display: block !important;
}

/* Показуємо заголовок */
.checkout-section #wcus-billing-fields h3 {
    display: block !important;
}

/* Показуємо поля */
.checkout-section #wcus-billing-fields p.form-row,
.checkout-section #wcus-billing-fields .form-row,
.checkout-section #wcus-billing-fields .wcus-checkout-fields p,
.checkout-section #wcus-billing-fields .wcus-checkout-np-fields p {
    display: block !important;
    margin-bottom: 20px !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

/* Перекриваємо inline style="display: none" на полі shipping_type */
.woocommerce-billing-fields__field-wrapper > p[style*="display: none"],
.woocommerce-billing-fields__field-wrapper > p.form-row[style*="display: none"] {
    display: block !important;
}

/* Показуємо перший zen-ui-select (тип доставки) */
.woocommerce-billing-fields__field-wrapper .zen-ui-select:first-of-type,
.woocommerce-billing-fields__field-wrapper .zen-ui-select-1 {
    display: block !important;
}

/* Показуємо dropdown'и */
.checkout-section #wcus-billing-fields .zen-ui-select {
    display: block !important;
}

/* Прибираємо зайві обгортки WooCommerce */
.woocommerce-billing-fields__field-wrapper {
    display: block;
    width: 100%;
}

/* Поля плагіна НП */
.woocommerce-billing-fields__field-wrapper p {
    margin-bottom: 20px;
}

/* Всі input/select від плагіна стилізуємо */
.woocommerce-billing-fields__field-wrapper input[type="text"],
.woocommerce-billing-fields__field-wrapper select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-family: 'Geologica', sans-serif;
    background: #fff;
}

.woocommerce-billing-fields__field-wrapper input[type="text"]:focus,
.woocommerce-billing-fields__field-wrapper select:focus {
    border-color: #000;
    outline: none;
}

/* Label від плагіна */
.woocommerce-billing-fields__field-wrapper label {
    display: block !important;
    font-size: 14px;
    font-weight: 500;
    color: #000;
    margin-bottom: 8px;
    font-family: 'Geologica', sans-serif;
}

/* Поля плагіна НП (виводяться через хук) */
.wc-ukr-shipping-np-fields,
.wcus-np-checkout-fields {
    margin: 20px 0;
}

.wc-ukr-shipping-np-fields p,
.wcus-np-checkout-fields p,
.wc-ukr-shipping-np-fields .form-row,
.wcus-np-checkout-fields .form-row {
    margin-bottom: 20px;
}

/* Input та select від плагіна НП */
.wc-ukr-shipping-np-fields input[type="text"],
.wc-ukr-shipping-np-fields select,
.wcus-np-checkout-fields input[type="text"],
.wcus-np-checkout-fields select,
input.wcus-input,
select.wcus-select {
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 16px !important;
    font-family: 'Geologica', sans-serif !important;
    background: #fff !important;
}

.wc-ukr-shipping-np-fields input[type="text"]:focus,
.wc-ukr-shipping-np-fields select:focus,
.wcus-np-checkout-fields input[type="text"]:focus,
.wcus-np-checkout-fields select:focus,
input.wcus-input:focus,
select.wcus-select:focus {
    border-color: #000 !important;
    outline: none !important;
}

/* Label від плагіна НП */
.wc-ukr-shipping-np-fields label,
.wcus-np-checkout-fields label {
    display: block !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #000 !important;
    margin-bottom: 8px !important;
    font-family: 'Geologica', sans-serif !important;
}

/* ВСІ МОЖЛИВІ ПОЛЯ ПЛАГІНА - універсальні класи */
.checkout-section input[type="text"]:not(.checkout-form__input),
.checkout-section select:not(.checkout-form__select),
.checkout-section .wcus-select,
.checkout-section .wcus-input,
.checkout-section input[name*="wcus"],
.checkout-section select[name*="wcus"],
.checkout-section input[name="billing_city"],
.checkout-section input[name="billing_address_1"] {
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 16px !important;
    font-family: 'Geologica', sans-serif !important;
    background: #fff !important;
    box-sizing: border-box !important;
}

.checkout-section input[type="text"]:focus:not(.checkout-form__input),
.checkout-section select:focus:not(.checkout-form__select) {
    border-color: #000 !important;
    outline: none !important;
}

/* Label в секції доставки */
.checkout-section label:not(.checkout-form__label):not(.checkout-form__checkbox) {
    display: block !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #000 !important;
    margin-bottom: 8px !important;
    font-family: 'Geologica', sans-serif !important;
}

/* Radio buttons shipping methods */
.checkout-section input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px !important;
}

/* Label всередині поля - прибираємо подвійний (але не в shipping methods!) */
.checkout-form__field > label,
.checkout-form__field .woocommerce-input-wrapper > label {
    display: none !important;
}

/* Наш label зверху залишаємо */
.checkout-form__label {
    display: block !important;
}

/* Label в shipping/payment methods залишаємо */
.woocommerce-shipping-methods label,
.wc_payment_methods label {
    display: flex !important;
}

/* Input всередині woocommerce_form_field */
.checkout-form__field .woocommerce-input-wrapper {
    width: 100%;
}

.checkout-form__field .woocommerce-input-wrapper input,
.checkout-form__field .woocommerce-input-wrapper select,
.checkout-form__field .woocommerce-input-wrapper textarea {
    width: 100%;
}

/* Прибираємо зірочку required */
.woocommerce-input-wrapper .required {
    display: none;
}

/* Помилки валідації */
.woocommerce-invalid .checkout-form__input {
    border-color: #EB2F06 !important;
}

.woocommerce-error {
    background: #EB2F06;
    color: #fff;
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Shipping methods */
.woocommerce-shipping-methods {
    list-style: none;
    padding: 0;
    margin: 0;
}

.woocommerce-shipping-methods li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.woocommerce-shipping-methods li:last-child {
    border-bottom: none;
}

.woocommerce-shipping-methods label {
    display: flex !important;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 16px;
}

.woocommerce-shipping-methods input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
}

/* Payment methods */
.wc_payment_methods {
    list-style: none;
    padding: 0;
    margin: 0;
}

.wc_payment_method {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.wc_payment_method:last-child {
    border-bottom: none;
}

.wc_payment_method label {
    display: flex !important;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 16px;
}

.wc_payment_method input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
}

/* Купон повідомлення */
.woocommerce-message {
    background: #4caf50;
    color: #fff;
    padding: 12px 20px;
    border-radius: 4px;
    margin: 10px 0;
}

.woocommerce-message a {
    color: #fff;
    text-decoration: underline;
}

/* Select2 / Autocomplete для Нової Пошти */
.select2-container {
    width: 100% !important;
    z-index: 9999 !important;
}

.select2-dropdown {
    z-index: 99999 !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.select2-results__option {
    padding: 12px 16px;
    font-size: 14px;
    cursor: pointer;
}

.select2-results__option--highlighted {
    background: #f5f5f5 !important;
    color: #000 !important;
}

.select2-results__option--selected {
    background: #E91E63 !important;
    color: #fff !important;
}

/* Autocomplete список */
.wcus-autocomplete-list,
.wcus-address-autocomplete,
.wc-ukr-shipping-autocomplete,
.wc-ukr-shipping-autocomplete-list,
ul[class*="autocomplete"],
.wcus-city-autocomplete,
.wcus-warehouse-autocomplete {
    position: absolute !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    border-radius: 0 0 4px 4px !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    z-index: 99999 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    margin-top: -1px !important;
}

.wcus-autocomplete-list li,
.wcus-address-autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.wcus-autocomplete-list li:hover,
.wcus-address-autocomplete-item:hover,
.wcus-autocomplete-list li.active,
.wcus-address-autocomplete-item.active {
    background: #f5f5f5;
}

.wcus-autocomplete-list li:last-child,
.wcus-address-autocomplete-item:last-child {
    border-bottom: none;
}

/* Input з автокомплітом має відносне позиціонування */
.checkout-form__field {
    position: relative;
}

/* Select створені плагіном */
.checkout-form__field select.wcus-select,
.checkout-form__field select[name="billing_address_1"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-family: 'Geologica', sans-serif;
    background: #fff;
    cursor: pointer;
}

.checkout-form__field select.wcus-select:focus,
.checkout-form__field select[name="billing_address_1"]:focus {
    border-color: #000;
    outline: none;
}

/* СТИЛІ ДЛЯ ZEN-UI-SELECT (плагін НП) */
.zen-ui-select {
    width: 100% !important;
    position: relative !important;
}

.zen-ui-select__value {
    width: 100% !important;
    padding: 12px 16px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 16px !important;
    font-family: 'Geologica', sans-serif !important;
    background: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease !important;
}

.zen-ui-select__value:hover {
    border-color: #000 !important;
}

.zen-ui-select__value-text {
    font-size: 16px !important;
    font-family: 'Geologica', sans-serif !important;
    color: #000 !important;
    flex: 1 !important;
}

.zen-ui-select__value svg {
    width: 16px !important;
    height: 16px !important;
    fill: #000 !important;
    transition: transform 0.2s ease !important;
    flex-shrink: 0 !important;
    margin-left: 8px !important;
}

.zen-ui-select.zen-ui-select--open .zen-ui-select__value svg {
    transform: rotate(180deg) !important;
}

/* Dropdown zen-ui-select */
.zen-ui-select__dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    border-radius: 0 0 4px 4px !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    z-index: 99999 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    margin-top: -1px !important;
}

.zen-ui-select__option {
    padding: 12px 16px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-family: 'Geologica', sans-serif !important;
    border-bottom: 1px solid #f0f0f0 !important;
    transition: background 0.15s ease !important;
}

.zen-ui-select__option:hover,
.zen-ui-select__option.zen-ui-select__option--active {
    background: #f5f5f5 !important;
}

.zen-ui-select__option:last-child {
    border-bottom: none !important;
}

/* Контейнер плагіна НП */
#wcus-billing-fields .wcus-checkout-fields {
    margin: 0 !important;
    padding: 0 !important;
}

#wcus-billing-fields h3 {
    font-size: 16px !important;
    font-weight: 500 !important;
    margin-bottom: 20px !important;
    font-family: 'Geologica', sans-serif !important;
    color: #000 !important;
}

#wcus-billing-fields p.form-row {
    margin-bottom: 20px !important;
}

/* Login button (відкриває модалку) */
button.checkout-section__link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: #000;
    text-decoration: underline;
    font-family: 'Geologica', sans-serif;
    transition: opacity 0.2s ease;
}

button.checkout-section__link:hover {
    opacity: 0.7;
}
