/* DCAShop Develop - expandable specifications and description.
   All rules are scoped to the new shortcode; existing UX Block design is intact. */

.dcashop-expand {
    width: 100%;
    min-width: 0;
    --dcashop-expand-brand: #446084;
}

.dcashop-expand__viewport {
    position: relative;
    width: 100%;
}

.dcashop-expand__inner {
    min-width: 0;
    display: flow-root;
}

/* Only limit the description if JavaScript measured actual overflowing content. */
.dcashop-expand--description.is-collapsible:not(.is-expanded) .dcashop-expand__viewport {
    max-height: var(--dcashop-expand-height-desktop, 420px);
    overflow: hidden;
}

.dcashop-expand--description.is-collapsible:not(.is-expanded) .dcashop-expand__viewport::after {
    content: '';
    position: absolute;
    bottom: 0;
    inset-inline: 0;
    height: 85px;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 92%);
}

/* WooCommerce's attribute table retains its original structure and styles. */
.dcashop-expand--attributes tr[hidden],
.dcashop-expand__toggle[hidden] {
    display: none !important;
}

/* DigiKala-style inline text link (not a boxed button).
   Keep the native button element for keyboard / screen-reader accessibility. */
.dcashop-expand__actions {
    direction: rtl;
    text-align: right;
}

.dcashop-expand.is-collapsible .dcashop-expand__actions {
    margin: 10px 0 8px;
}

.single-product .dcashop-expand button.dcashop-expand__toggle,
.dcashop-expand button.dcashop-expand__toggle {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    direction: rtl;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    width: auto;
    min-width: 0;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 4px 0;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    color: var(--dcashop-expand-brand) !important;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.7;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none !important;
    text-decoration-line: none !important;
    border-bottom: 0 !important;
    background-image: none !important;
    cursor: pointer;
    vertical-align: middle;
}

.dcashop-expand button.dcashop-expand__toggle:not([hidden]) {
    display: inline-flex;
}

.single-product .dcashop-expand button.dcashop-expand__toggle:hover,
.single-product .dcashop-expand button.dcashop-expand__toggle:active,
.single-product .dcashop-expand button.dcashop-expand__toggle:focus,
.dcashop-expand button.dcashop-expand__toggle:hover,
.dcashop-expand button.dcashop-expand__toggle:active,
.dcashop-expand button.dcashop-expand__toggle:focus {
    border: 0 !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    color: var(--dcashop-expand-brand) !important;
    text-decoration: none !important;
    text-decoration-line: none !important;
    border-bottom: 0 !important;
    background-image: none !important;
}

/* Keep the text clean in normal, hover, focus and expanded states. */
.dcashop-expand button.dcashop-expand__toggle .dcashop-expand__toggle-text,
.dcashop-expand button.dcashop-expand__toggle:hover .dcashop-expand__toggle-text,
.dcashop-expand button.dcashop-expand__toggle:focus .dcashop-expand__toggle-text,
.dcashop-expand button.dcashop-expand__toggle:active .dcashop-expand__toggle-text,
.dcashop-expand.is-expanded button.dcashop-expand__toggle .dcashop-expand__toggle-text {
    text-decoration: none !important;
    text-decoration-line: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    background-image: none !important;
}

/* Prevent theme hover decorations from drawing an underline under the link. */
.single-product .dcashop-expand .dcashop-expand__toggle::before,
.single-product .dcashop-expand .dcashop-expand__toggle::after {
    content: none !important;
    display: none !important;
}

.dcashop-expand button.dcashop-expand__toggle:focus-visible {
    outline: 2px solid var(--dcashop-expand-brand);
    outline-offset: 3px;
}

.dcashop-expand__arrow {
    width: 15px;
    height: 15px;
    flex: none;
    transform: none !important;
}

/* The chevron points left in both the open and closed states. */
.dcashop-expand.is-expanded .dcashop-expand__arrow {
    transform: none !important;
}

@media (max-width: 767px) {
    .dcashop-expand--description.is-collapsible:not(.is-expanded) .dcashop-expand__viewport {
        max-height: var(--dcashop-expand-height-mobile, 320px);
    }
    .dcashop-expand.is-collapsible .dcashop-expand__actions {
        margin-top: 12px;
    }
}


/* Fullscreen sheet: created only when the mobile read-more link is clicked. */
html.dcashop-expand-modal-open,
body.dcashop-expand-modal-open {
    overflow: hidden !important;
}

.dcashop-expand-modal {
    display: none;
}

@media (max-width: 767px) {
    .dcashop-expand-modal,
    .single-product .dcashop-expand-modal {
        position: fixed;
        inset: 0;
        z-index: 2147483000;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 100%;
        height: 100dvh;
        padding: 0;
        margin: 0;
        background: #fff;
        color: #292929;
        direction: rtl;
        text-align: right;
        box-sizing: border-box;
        isolation: isolate;
    }

    .dcashop-expand-modal *,
    .dcashop-expand-modal *::before,
    .dcashop-expand-modal *::after {
        box-sizing: border-box;
    }

    .dcashop-expand-modal__header {
        flex: 0 0 auto;
        min-height: 62px;
        padding: 12px 18px;
        padding-top: max(12px, env(safe-area-inset-top));
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 16px;
        border-bottom: 1px solid #e1e5e9;
        background: #fff;
    }

    .dcashop-expand-modal__title {
        font-family: inherit;
        font-size: 17px;
        font-weight: 700;
        line-height: 1.6;
        color: #243b62;
        margin: 0;
    }

    .dcashop-expand-modal button.dcashop-expand-modal__close,
    .single-product .dcashop-expand-modal button.dcashop-expand-modal__close {
        display: inline-flex;
        direction: rtl;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        gap: 8px;
        min-width: 0;
        height: 38px;
        line-height: 1.7;
        padding: 4px 0;
        margin: 0;
        border: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        color: #292929 !important;
        font-family: inherit;
        font-size: 14px;
        font-weight: 500;
        text-decoration: none !important;
        cursor: pointer;
    }

    .dcashop-expand-modal__close svg {
        flex: 0 0 auto;
    }

    .dcashop-expand-modal__close:focus-visible {
        outline: 2px solid #446084;
        outline-offset: 3px;
    }

    .dcashop-expand-modal__scroll {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 22px 18px max(25px, env(safe-area-inset-bottom));
    }

    .dcashop-expand-modal__scroll > .dcashop-expand__viewport {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        width: 100%;
        position: static;
    }

    .dcashop-expand-modal__scroll .dcashop-expand__viewport::after {
        content: none !important;
        display: none !important;
    }

    .dcashop-expand-modal__scroll .dcashop-expand__inner {
        display: flow-root;
        min-width: 0;
        width: 100%;
        overflow-wrap: anywhere;
    }

    .dcashop-expand-modal__scroll img,
    .dcashop-expand-modal__scroll video,
    .dcashop-expand-modal__scroll iframe {
        max-width: 100%;
    }

}

/* Compact product specification cards, shared by the product page and mobile dialog.
   Scope strictly to this shortcode; other product tables are unaffected. */
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-spacing: 0 !important;
    border-collapse: separate !important;
    background: transparent !important;
    box-shadow: none !important;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes tbody,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes tbody {
    display: grid !important;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes tr:not([hidden]),
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes tr:not([hidden]) {
    display: block !important;
    width: auto !important;
    min-width: 0;
    height: auto !important;
    margin: 0 !important;
    padding: 12px 15px !important;
    border: 0 !important;
    border-radius: 10px;
    background: #f3f7fb !important;
    box-shadow: none !important;
    direction: rtl;
    text-align: right;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes tr[hidden],
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes tr[hidden] {
    display: none !important;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes th,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes th,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes td,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes td {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    text-align: right !important;
    vertical-align: top;
    overflow-wrap: anywhere;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes th,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes th {
    margin-bottom: 5px !important;
    color: #263a54 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.8 !important;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes td,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes td {
    color: #363b42 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.85 !important;
}

:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes td p,
:is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes td p {
    margin: 0 !important;
    padding: 0 !important;
    font: inherit !important;
    line-height: inherit !important;
}

@media (max-width: 767px) {
    :is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes tbody,
    :is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes tbody {
        grid-template-columns: minmax(0, 1fr);
        gap: 9px;
    }
    :is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.woocommerce-product-attributes tr:not([hidden]),
    :is(.dcashop-expand--attributes, .dcashop-expand-modal--attributes) .dcashop-expand__inner table.shop_attributes tr:not([hidden]) {
        padding: 11px 14px !important;
    }
}


/* Desktop specifications: one feature per full-width row, with its label and
   value in facing columns. The mobile card layout remains unchanged. */
@media (min-width: 768px) {
    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) tbody {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 0 !important;
    }

    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) tr:not([hidden]) {
        display: grid !important;
        grid-template-columns: minmax(145px, 28%) minmax(0, 1fr);
        align-items: start;
        column-gap: 20px;
        padding: 14px 12px !important;
        margin: 0 !important;
        border: 0 !important;
        border-bottom: 1px solid #e7ebf0 !important;
        border-radius: 0 !important;
        background: #fff !important;
    }

    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) th,
    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) td {
        width: auto !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) th {
        color: #263a54 !important;
        font-weight: 600 !important;
    }

    .dcashop-expand--attributes .dcashop-expand__inner table:is(.woocommerce-product-attributes, .shop_attributes) td {
        color: #41464e !important;
        font-weight: 400 !important;
    }
}
