/*
Theme Name: Biagiotti Child
Theme URI: https://biagiotti.qodeinteractive.com
Description: A child theme of Biagiotti Theme
Author: Mikado Themes
Author URI: http://themeforest.net/user/mikado-themes
Version: 1.0.1
Text Domain: biagiotti
Template: biagiotti
*/

/* Biagiotti Galeri Hizalama Düzeltmesi. Galeriye eklenen ikici ve sonrası görseller birinci görselin altında kalıyordu */
@media only screen and (min-width: 769px) {

    /* 2. Resim (Listenin en tepesi) - %0 */
    .mkdf-woo-single-page.mkdf-woo-single-thumb-on-left-side .mkdf-single-product-content .images.woocommerce-product-gallery--columns-4 .woocommerce-product-gallery__image:nth-child(2) {
        top: 0 !important;
    }

    /* 3. Resim (Bir altı) - %25 + Boşluk */
    .mkdf-woo-single-page.mkdf-woo-single-thumb-on-left-side .mkdf-single-product-content .images.woocommerce-product-gallery--columns-4 .woocommerce-product-gallery__image:nth-child(3) {
        top: calc(25% + 10px) !important;
    }

    /* 4. Resim (Varsa bir altı) - %50 + Boşluk */
    .mkdf-woo-single-page.mkdf-woo-single-thumb-on-left-side .mkdf-single-product-content .images.woocommerce-product-gallery--columns-4 .woocommerce-product-gallery__image:nth-child(4) {
        top: calc(50% + 20px) !important;
    }
	
	/* 5. Resim (Varsa bir altı) - %75 + Boşluk */
    .mkdf-woo-single-page.mkdf-woo-single-thumb-on-left-side .mkdf-single-product-content .images.woocommerce-product-gallery--columns-4 .woocommerce-product-gallery__image:nth-child(5) {
        top: calc(75% + 30px) !important;
    }
}

/* Ek Bilgi Tablosu Düzenlemesi */
.shop_attributes th,
.woocommerce-product-attributes-item__label {
    min-width: 150px !important;  /* Sol sütuna en az 150px yer ayır */
    width: auto !important;       /* Sıkışırsa esnesin */
    white-space: nowrap !important; /* Kelimeleri asla alt satıra kırma */
    vertical-align: top !important; /* Uzun listelerde başlık hep tepede dursun */
    text-align: left !important;   /* Sola hizala */
}

/* Değerler (Sağ Taraf) Arasına Boşluk */
.shop_attributes td,
.woocommerce-product-attributes-item__value {
    padding-left: 20px !important; /* Başlık ile yazı arasına mesafe koy */
}


/* Checkout/Ödeme sayfasına fatura tipi ekle*/
add_action('wp_footer', 'custom_checkout_script');

function custom_checkout_script() {
    if (!is_checkout()) return;
    ?>
    <script>
    jQuery(function($){

        function toggleCorporateFields() {
            var type = $('input[name="billing_type"]:checked').val();

            if (type === 'corporate') {
                $('#billing_company_field').show();
                $('#billing_tax_number_field').show();
                $('#billing_tax_office_field').show();
            } else {
                $('#billing_company_field').hide();
                $('#billing_tax_number_field').hide();
                $('#billing_tax_office_field').hide();
            }
        }

        toggleCorporateFields();

        $('form.checkout').on('change', 'input[name="billing_type"]', function(){
            toggleCorporateFields();
        });

    });
    </script>
    <?php
}

#billing_company_field,
#billing_tax_number_field,
#billing_tax_office_field {
    display: none;
}

#billing_type_field .woocommerce-input-wrapper {
    display: flex;
    gap: 20px;
}

#billing_type_field label {
    display: flex;
    align-items: center;
    gap: 6px;
}