/* =========================================================
   استایل عمومی جدول‌ها در محصول، مقاله و صفحات سفارشی
========================================================= */

/* =========================================================
   انتخاب جدول‌های محصول، مقاله و جدول‌های سفارشی
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
) {
    width: 100% !important;
    max-width: 100% !important;

    margin:
        18px
        0
        24px !important;

    border:
        1px solid
        var(--color-border) !important;

    border-collapse: separate !important;
    border-spacing: 0 !important;

    border-radius: var(--radius-md) !important;

    background: var(--color-surface) !important;

    box-shadow:
        0 7px 24px
        rgba(20, 20, 20, 0.055);

    color: var(--color-text);

    overflow: hidden;
}


/* =========================================================
   سلول‌های جدول
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
:is(th, td) {
    padding:
        13px
        16px !important;

    border: 0 !important;

    border-bottom:
        1px solid
        var(--color-border) !important;

    vertical-align: middle !important;

    text-align: right !important;

    font-size: 14px;
    line-height: 1.9;

    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
}


/* =========================================================
   عنوان ستون‌های جدول
========================================================= */

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
thead
th {
    color: var(--brand-on-primary) !important;

    background:
        linear-gradient(
            135deg,
            var(--brand-primary-dark),
            var(--brand-primary)
        ) !important;

    border-bottom: 0 !important;

    font-weight: 700 !important;
}


/* =========================================================
   ستون عنوان ویژگی‌های ووکامرس
========================================================= */

body.single-product
table.shop_attributes
th.woocommerce-product-attributes-item__label {
    width: 30% !important;
    min-width: 155px;

    color: var(--brand-primary) !important;

    background:
        var(--brand-primary-soft) !important;

    font-weight: 700 !important;
}


/* ستون مقدار ویژگی ووکامرس */
body.single-product
table.shop_attributes
td.woocommerce-product-attributes-item__value {
    width: 70% !important;

    color: var(--color-text) !important;

    background: var(--color-surface) !important;

    font-weight: 500;
}


/* =========================================================
   حذف فاصله پاراگراف داخل سلول‌ها
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
td
p {
    margin: 0 !important;
}


/* =========================================================
   ردیف‌های یکی در میان
========================================================= */

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
tbody
tr:nth-child(even)
:is(th, td) {
    background:
        rgb(var(--brand-primary-rgb) / 0.025);
}


/* =========================================================
   حرکت نرم هاور
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
tbody
tr {
    transition:
        background-color 0.22s ease;
}


/* هاور جدول ویژگی‌های محصول */
body.single-product
table.shop_attributes
tbody
tr:hover
:is(th, td) {
    background:
        rgb(var(--brand-primary-rgb) / 0.075) !important;
}


/* هاور جدول‌های عادی محصول، مقاله و جدول سفارشی */
:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
tbody
tr:hover
:is(th, td) {
    background:
        rgb(var(--brand-primary-rgb) / 0.065) !important;
}


/* =========================================================
   حذف خط پایین آخرین ردیف
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
tbody
tr:last-child
:is(th, td) {
    border-bottom: 0 !important;
}


/* =========================================================
   لینک‌های داخل جدول
========================================================= */

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
a {
    color: var(--brand-primary);

    font-weight: 600;

    text-decoration: none;

    transition:
        color 0.2s ease;
}

:is(
    body.single-product table.shop_attributes,

    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table,

    body.single-product
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table
)
a:hover {
    color: var(--brand-primary-strong);
}


/* =========================================================
   اعداد و عبارات انگلیسی
========================================================= */

:is(
    body.single-product table,
    body.single-post table,
    table.yc-product-table
)
.yc-ltr {
    direction: ltr;
    unicode-bidi: isolate;

    display: inline-block;

    font-family:
        Arial,
        sans-serif;

    letter-spacing: 0.4px;
}


/* =========================================================
   سازگاری جدول‌های Gutenberg در مقاله
========================================================= */

body.single-post
figure.wp-block-table {
    width: 100%;

    margin:
        18px
        0
        24px;

    overflow-x: auto;

    -webkit-overflow-scrolling: touch;
}

body.single-post
figure.wp-block-table
table {
    margin: 0 !important;
}


/* =========================================================
   نمایش موبایل
========================================================= */

@media (max-width: 767px) {

    /* جدول ویژگی‌های محصول به حالت کارت تبدیل شود */
    body.single-product
    table.shop_attributes {
        display: block !important;

        margin:
            14px
            0
            20px !important;

        border: 0 !important;
        border-radius: 0 !important;

        background: transparent !important;

        box-shadow: none;

        overflow: visible;
    }

    body.single-product
    table.shop_attributes
    tbody {
        display: grid;

        gap: 9px;
    }

    body.single-product
    table.shop_attributes
    tr.woocommerce-product-attributes-item {
        display: grid;

        grid-template-columns:
            minmax(105px, 38%)
            minmax(0, 62%);

        overflow: hidden;

        border:
            1px solid
            var(--color-border);

        border-radius: 10px;

        background: var(--color-surface);

        box-shadow:
            0 4px 14px
            rgba(20, 20, 20, 0.035);
    }

    body.single-product
    table.shop_attributes
    :is(
        th.woocommerce-product-attributes-item__label,
        td.woocommerce-product-attributes-item__value
    ) {
        display: flex;

        width: auto !important;
        min-width: 0 !important;

        align-items: center;

        padding:
            10px
            11px !important;

        border-bottom: 0 !important;

        font-size: 12.5px;
        line-height: 1.75;
    }

    body.single-product
    table.shop_attributes
    th.woocommerce-product-attributes-item__label {
        border-left:
            1px solid
            var(--color-border) !important;
    }


    /* جدول‌های عادی محصول، مقاله و جدول سفارشی در موبایل اسکرول شوند */
    :is(
        body.single-product
        .woocommerce-tabs
        .woocommerce-Tabs-panel
        table:not(.shop_attributes),

        body.single-product
        .elementor-widget-theme-post-content
        table:not(.shop_attributes),

        body.single-post
        .elementor-widget-theme-post-content
        table,

        body.single-post
        .entry-content
        table,

        table.yc-product-table:not(.shop_attributes)
    ) {
        display: block;

        max-width: 100% !important;

        overflow-x: auto;
        overflow-y: hidden;

        -webkit-overflow-scrolling: touch;
    }


    /* جلوگیری از فشرده‌شدن شدید ستون‌ها */
    :is(
        body.single-product
        .woocommerce-tabs
        .woocommerce-Tabs-panel
        table:not(.shop_attributes),

        body.single-product
        .elementor-widget-theme-post-content
        table:not(.shop_attributes),

        body.single-post
        .elementor-widget-theme-post-content
        table,

        body.single-post
        .entry-content
        table,

        table.yc-product-table:not(.shop_attributes)
    )
    :is(thead, tbody, tfoot) {
        min-width: 620px;
    }


    /* سلول‌ها در موبایل کمی جمع‌وجورتر شوند */
    :is(
        body.single-product
        .woocommerce-tabs
        .woocommerce-Tabs-panel
        table:not(.shop_attributes),

        body.single-product
        .elementor-widget-theme-post-content
        table:not(.shop_attributes),

        body.single-post
        .elementor-widget-theme-post-content
        table,

        body.single-post
        .entry-content
        table,

        table.yc-product-table:not(.shop_attributes)
    )
    :is(th, td) {
        padding:
            10px
            12px !important;

        font-size: 12.5px;
        line-height: 1.75;
    }
}


/* =========================================================
   گردی گوشه‌های بالای هدر جدول
========================================================= */

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
thead
tr:first-child
> :first-child {
    border-start-start-radius:
        calc(var(--radius-md) - 1px) !important;
}

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
thead
tr:first-child
> :last-child {
    border-start-end-radius:
        calc(var(--radius-md) - 1px) !important;
}



/* =========================================================
   تقسیم مساوی عرض ستون‌های جدول
========================================================= */

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
) {
    table-layout: fixed !important;
}

/* جلوگیری از شکسته‌شدن غیرطبیعی متن */
:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
:is(th, td) {
    width: auto !important;

    overflow-wrap: break-word !important;
    word-break: normal !important;
    hyphens: none;
}



/* =========================================================
   موبایل: جدول خوانا با اسکرول افقی
========================================================= */
/* راهنمای جدول به‌صورت پیش‌فرض مخفی است */
.yc-table-hint {
    display: none;
}

@media (max-width: 767px) {
    .yc-table-wrap {
        width: 100%;
        max-width: 100%;
        margin: 18px 0 24px;
    }

    /*
     * راهنما فقط زمانی نمایش داده می‌شود
     * که JS اسکرول واقعی را تشخیص دهد.
     */
    .yc-table-wrap.yc-table-wrap--scrollable .yc-table-hint {
        display: inline-flex;
        align-items: center;
        gap: 6px;

        margin: 0 0 8px auto;
        padding: 6px 10px;

        border-radius: 99px;

        color: #fff;
        background: rgb(var(--brand-primary-rgb) / 0.92);

        font-size: 11px;
        font-weight: 600;
        line-height: 1.4;
        white-space: nowrap;

        animation: yc-table-scroll-hint 1.5s ease-in-out infinite;
    }

    .yc-table-scroll {
        width: 100%;
        max-width: 100%;

        overflow-x: auto;
        overflow-y: hidden;

        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--brand-primary) transparent;
    }

    .yc-table-scroll::-webkit-scrollbar {
        height: 5px;
    }

    .yc-table-scroll::-webkit-scrollbar-thumb {
        border-radius: 99px;
        background: var(--brand-primary);
    }

    /*
     * جدول‌های سه‌ستونه و بیشتر
     * در موبایل فضای کافی برای خوانایی داشته باشند.
     */
    .yc-table-scroll table {
        width: 680px !important;
        min-width: 555px !important;
        margin: 0 !important;
    }

    /*
     * جدول‌های یک یا دو ستونه داخل عرض صفحه قرار بگیرند.
     */
    .yc-table-scroll table:not(:has(tr > :nth-child(3))) {
        width: 100% !important;
        min-width: 0 !important;
    }
}

@keyframes yc-table-scroll-hint {
    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-9px);
    }
}

/* =========================================================
   تقسیم مساوی ستون‌ها در دسکتاپ و موبایل
   این بخش باید انتهای تمام CSSهای جدول باشد
========================================================= */

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
) {
    table-layout: fixed !important;
}

:is(
    body.single-product
    .woocommerce-tabs
    .woocommerce-Tabs-panel
    table:not(.shop_attributes),

    body.single-product
    .elementor-widget-theme-post-content
    table:not(.shop_attributes),

    body.single-post
    .elementor-widget-theme-post-content
    table,

    body.single-post
    .entry-content
    table,

    table.yc-product-table:not(.shop_attributes)
)
:is(th, td) {
    width: auto !important;
    min-width: 0 !important;

    overflow-wrap: break-word !important;
    word-break: normal !important;
}

/* در موبایل خود جدول باید همچنان display: table باشد */
@media (max-width: 767px) {
    :is(
        body.single-product
        .woocommerce-tabs
        .woocommerce-Tabs-panel
        .yc-table-scroll
        > table:not(.shop_attributes),

        body.single-product
        .elementor-widget-theme-post-content
        .yc-table-scroll
        > table:not(.shop_attributes),

        body.single-post
        .elementor-widget-theme-post-content
        .yc-table-scroll
        > table,

        body.single-post
        .entry-content
        .yc-table-scroll
        > table,

        .yc-table-scroll
        > table.yc-product-table:not(.shop_attributes)
    ) {
        display: table !important;
        table-layout: fixed !important;
        overflow: visible !important;
    }

    .yc-table-scroll > table:not(.shop_attributes)
    :is(thead, tbody, tfoot) {
        min-width: 0 !important;
    }
}