/* ================================
   WPBCS Price Table - FINAL (Desktop)
   Order: Actions | Update | Title+Icon
================================ */

/* Base table */
table.wpbcs-price-table {
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    border: 1.5px solid #926F6F !important;
    background: #ffffff !important;
    box-shadow: none !important;
}

thead {
    background: none !important;
}
span.wpbcs-categories-list__text {
    color: #bf0041!important;
    font-weight: 800;
}
li.wpbcs-categories-list__cat {
    border-radius: 8px !important;
    background-color: #ffe3e3 !important;
}
/* TOP BAR (thead row 1) */
table.wpbcs-price-table thead tr:first-child th {
    padding: 18px 18px !important;
    border-bottom: 1px solid #f2e8e8 !important;
    background: #fff !important;
}

/* ✅ Header layout: Grid LTR for correct left/right placement */
@media (min-width: 981px) {

    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head {
        display: grid !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-areas: "actions update title" !important;
        align-items: center !important;
        gap: 14px !important;

        direction: ltr !important;
        /* اکشن‌ها واقعاً چپ می‌نشینند */
        min-height: 64px !important;
    }

    /* ---------- Actions (LEFT) ---------- */
    table.wpbcs-price-table .wpbcs-actions {
        grid-area: actions !important;
        justify-self: start !important;
        align-self: center !important;

        display: flex !important;
        gap: 8px !important;
        padding: 8px !important;
       

        visibility: visible !important;
        opacity: 1 !important;
    }

    table.wpbcs-price-table .wpbcs-action-btn {
width: 38px !important;
    height: 38px !important;
    border-radius: 12px !important;
    border: 0px;
    background: #FAF6F6 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    }

    table.wpbcs-price-table .wpbcs-action-btn svg {
        width: 18px !important;
        height: 18px !important;
    
    }

    /* ---------- Update (CENTER) - one line ---------- */
    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head .wpbcs-updatebox {
        grid-area: update !important;
        justify-self: center !important;
        align-self: center !important;

        position: static !important;
        transform: none !important;

        display: inline-flex !important;
        flex-direction: row !important;
        /* ✅ تاریخ + چک‌باکس کنار هم */
        align-items: center !important;
        gap: 12px !important;

        white-space: nowrap !important;
        flex-wrap: nowrap !important;

      
        border-radius: 14px !important;
        padding: 10px 14px !important;
    

        direction: rtl !important;
        /* متن RTL */
        text-align: center !important;
    }

    table.wpbcs-price-table .wpbcs-updatebox * {
        white-space: nowrap !important;
    }

    table.wpbcs-price-table .wpbcs-updated-at {
        margin: 0 !important;
        font-size: 13px !important;
        font-weight: 800 !important;
        color: #664D4D !important;
        line-height: 1 !important;
    }

    table.wpbcs-price-table .wpbcs-vat-label {
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 12.5px !important;
        font-weight: 700 !important;
        color: #926F6F !important;
        line-height: 1 !important;
    }

    table.wpbcs-price-table input.wpbcs-vat-toggle {
        margin: 0 !important;
        width: 16px !important;
        height: 16px !important;
        accent-color: #BF0413;
    }

    /* ---------- Title + Icon (RIGHT) ---------- */
    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head .wpbcs-titlebox {
grid-area: title !important;
    justify-self: end !important;
    align-self: center !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    direction: rtl !important;
    white-space: nowrap !important;
    max-width: 62vw !important;
    flex-direction: row-reverse;
    }

    /* اگر ترتیب HTML برعکس بود، با order درستش می‌کنیم */
    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head .wpbcs-titlebox h3 {
        order: 1 !important;
    }

    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head .wpbcs-titlebox img {
        order: 2 !important;
    }

    table.wpbcs-price-table thead tr:first-child th>div.wpbcs-head .wpbcs-titlebox img {
        width: 44px !important;
        height: 44px !important;
        object-fit: contain !important;
        flex: 0 0 auto !important;
    }

    table.wpbcs-price-table thead tr:first-child h3 {
        margin: 0 !important;
        font-size: 28px !important;
        font-weight: 900 !important;
        line-height: 1.15 !important;
        color: #BF0413 !important;

        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    table.wpbcs-price-table thead tr:first-child h3 a {
        color: #BF0413 !important;
        text-decoration: none !important;
    }

    table.wpbcs-price-table thead tr:first-child h3 a:hover {
        opacity: .92 !important;
    }
}

/* Column headers (thead row 2) */
table.wpbcs-price-table thead tr:last-child th {
    background: #ffffff !important;
    color: #574C4C !important;
    font-weight: 600 !important;
    padding: 14px 10px !important;
    border-bottom: 1px solid #f2e8e8 !important;
    white-space: nowrap !important;
}

/* Body */
table.wpbcs-price-table tbody td {
    padding: 18px 10px !important;
    color: #334155 !important;
    text-align: center !important;
    border: 0 !important;
    background: #ffffff !important;
}

table.wpbcs-price-table tbody tr {
    background: #fff !important;
}

table.wpbcs-price-table tbody tr:hover {
    background: transparent !important;
}

table.wpbcs-price-table td.wpbcs-price-cell {
    font-weight: 700 !important;
    color: #1f2937 !important;
}

table.wpbcs-price-table a {
    color: #334155 !important;
    text-decoration: none !important;
}

table.wpbcs-price-table a:hover {
    opacity: .9 !important;
}

/* Fluctuation pill (limit scope to fluctuation column only) */
table.wpbcs-price-table tbody td.wpbcs-col-fluctuation span,
table.wpbcs-price-table tbody td.wpbcs-col-fluctuation .wpbcs-fluct-pill {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 64px !important;
    padding: 6px 12px !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
}

/* Optional: if fluctuation is rendered with the new pill classes */
table.wpbcs-price-table .wpbcs-fluct-pill.wpbcs-fluct-up{
    background:#E8F5E9 !important;
    color:#0E5D2E !important;
}
table.wpbcs-price-table .wpbcs-fluct-pill.wpbcs-fluct-down{
    background:#FFEBEE !important;
    color:#9E1532 !important;
}
table.wpbcs-price-table .wpbcs-fluct-pill.wpbcs-fluct-flat{
    background:#f2f2f2 !important;
    color:#555 !important;
}

/* ================================
   Row hover: full-width bg + radius
   (apply on TDs, since TD bg overrides TR)
================================ */
table.wpbcs-price-table tbody tr:not(.wpbcs-row-details):hover > td{
    background:#FAF6F6 !important;
    transition: background-color .18s ease;
}

/* Right side (works in RTL/LTR) */
table.wpbcs-price-table tbody tr:not(.wpbcs-row-details):hover > td:first-child{
    border-top-right-radius:5px !important;
    border-bottom-right-radius:5px !important;
}

/* Left side */
table.wpbcs-price-table tbody tr:not(.wpbcs-row-details):hover > td:last-child{
    border-top-left-radius:5px !important;
    border-bottom-left-radius:5px !important;
}

/* Print */
@media print {
    table.wpbcs-price-table .wpbcs-actions {
        display: none !important;
    }

    table.wpbcs-price-table {
        border: 1px solid #999 !important;
    }
}

/* ==========================================
   Mobile Header Layout (FIX)
   Row 1: Logo + Table Title
   Row 2: Update/VAT (right) + Actions (left)
========================================== */
@media (max-width: 980px) {

    /* padding کمتر برای موبایل */
    table.wpbcs-price-table thead tr:first-child th {
        padding: 14px 14px !important;
    }

    /* ✅ تبدیل هدر به Grid دو ردیفی */
    table.wpbcs-price-table thead tr:first-child th > div.wpbcs-head {
        display: grid !important;
        grid-template-columns: auto 1fr !important;
        grid-template-areas:
            "title title"
            "actions update" !important;
        align-items: center !important;
        gap: 10px !important;

        direction: ltr !important; /* اکشن‌ها واقعاً سمت چپ می‌نشینند */
        min-height: 0 !important;
    }

    /* ---------- Title (Row 1) ---------- */
    table.wpbcs-price-table thead tr:first-child th > div.wpbcs-head .wpbcs-titlebox {
        grid-area: title !important;
        justify-self: end !important;

        display: inline-flex !important;
        align-items: center !important;
        gap: 10px !important;

        direction: rtl !important;
        flex-direction: row-reverse !important; /* لوگو سمت راست */
        max-width: 100% !important;
        min-width: 0 !important;
        white-space: normal !important;
    }

    table.wpbcs-price-table thead tr:first-child th > div.wpbcs-head .wpbcs-titlebox img {
        width: 38px !important;
        height: 38px !important;
        object-fit: contain !important;
        flex: 0 0 auto !important;
        margin: 0 !important;
    }

    table.wpbcs-price-table thead tr:first-child h3 {
        margin: 0 !important;
        font-size: 18px !important;
        font-weight: 900 !important;
        line-height: 1.25 !important;
        color: #BF0413 !important;

        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: normal !important;
        text-align: right !important;
    }

    table.wpbcs-price-table thead tr:first-child h3 a {
        color: #BF0413 !important;
        text-decoration: none !important;
    }

    /* ---------- Update/VAT (Row 2 - Right) ---------- */
    table.wpbcs-price-table thead tr:first-child th > div.wpbcs-head .wpbcs-updatebox {
        grid-area: update !important;
        justify-self: end !important;

        position: static !important;
        transform: none !important;

        display: inline-flex !important;
        align-items: center !important;
        gap: 10px !important;
        flex-wrap: wrap !important;

        
        border-radius: 14px !important;
        padding: 10px 12px !important;
        

        direction: rtl !important;
        text-align: right !important;
        max-width: 100% !important;
        min-width: 0 !important;
        white-space: normal !important;
    }

    table.wpbcs-price-table .wpbcs-updated-at {
        margin: 0 !important;
        font-size: 12.5px !important;
        font-weight: 800 !important;
        color: #664D4D !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }

    table.wpbcs-price-table .wpbcs-vat-label {
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #926F6F !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }

    table.wpbcs-price-table input.wpbcs-vat-toggle {
        margin: 0 !important;
        width: 16px !important;
        height: 16px !important;
        accent-color: #BF0413;
    }

    /* ---------- Actions (Row 2 - Left) ---------- */
    table.wpbcs-price-table .wpbcs-actions {
        grid-area: actions !important;
        justify-self: start !important;

        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 0 !important;

        visibility: visible !important;
        opacity: 1 !important;
    }

    table.wpbcs-price-table .wpbcs-action-btn {
        width: 36px !important;
        height: 36px !important;
        border-radius: 12px !important;
        border: 0 !important;
        background: #FAF6F6 !important;

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        cursor: pointer !important;
        padding: 0 !important;
        line-height: 0 !important;
        -webkit-tap-highlight-color: transparent;
    }

    table.wpbcs-price-table .wpbcs-action-btn svg {
        width: 18px !important;
        height: 18px !important;
        display: block !important;
    }
}


/* ===========================
   Mobile - Moghatte tables
   current order (as you said):
   1 سایز | 2 حالت | 3 آنالیز | 4 وزن | 5 واحد | 6 بارگیری | 7 نوسان | 8 قیمت
   => keep: 1,3,6,8
=========================== */
@media (max-width: 980px) {

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(2),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(2),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(4),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(4),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(5),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(5),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(7),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(7) {
        display: none !important;
    }

    /* کمی جمع‌وجورتر */
    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th,
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td {
        padding: 10px 8px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }
}/* ==========================================
   Mobile - Moghatte tables (4 columns only)
   FIX: last (Price) column clipped
========================================== */
@media (max-width: 980px) {

    /* ✅ والدهای احتمالی اسکرول/کات را خنثی کن */
    .wpbcs-table-wrap,
    .wpbcs-wrap,
    .wpbcs-table-container,
    .elementor-widget-container {
        overflow-x: visible !important;
    }

    /* ✅ خود جدول */
    table.wpbcs-price-table.wpbcs-moghatte-mobile {
        width: 100% !important;
        table-layout: auto !important;
        /* ✅ fixed باعث کاتِ ستون آخر می‌شود */
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    /* ستون‌های اضافی را ببند */
    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(2),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(2),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(4),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(4),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(5),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(5),

    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(7),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(7) {
        display: none !important;
    }

    /* ✅ مهم: در موبایل min-width های span را خنثی کن (این دقیقا عامل بیرون‌زدگی است) */
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td span {
        min-width: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        font-weight: inherit !important;
    }

    /* سلول‌ها: اجازه بده متن کوتاه شود، نه اینکه جدول را بکشد */
    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th,
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td {
        padding: 10px 6px !important;
        font-size: 12.5px !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        text-align: center !important;

        min-width: 0 !important;
        max-width: 1px !important;
        /* ✅ ترفند: ستون آخر بیرون نزند */
    }

    /* قیمت: خوانا و بدون بریدن */
    table.wpbcs-price-table.wpbcs-moghatte-mobile td.wpbcs-price-cell {
        font-weight: 900 !important;
        font-size: 13px !important;
        overflow: visible !important;
        /* ✅ قیمت نباید ... بخورد */
        text-overflow: clip !important;
    }

    /* ستون قیمت را آخر ردیف کمی فضای بیشتر بده */
    table.wpbcs-price-table.wpbcs-moghatte-mobile thead tr:last-child th:nth-child(8),
    table.wpbcs-price-table.wpbcs-moghatte-mobile tbody td:nth-child(8) {
        padding-right: 10px !important;
        padding-left: 10px !important;
    }
}