/* =========================================================
   Advanced Post Settings — Frontend Styles (v1.3.1)
   دکمه‌ها، جدول‌ها، TOC یکپارچه، FAQ آکاردئون، CTA، پست مرتبط، کروسل محصولات
   ========================================================= */

:root {
    --aps-primary: var(--wp--preset--color--primary,
            var(--e-global-color-primary,
                var(--ast-global-color-0,
                    var(--global-palette1,
                        var(--bs-primary,
                            var(--accent, var(--accent-color,
                                    var(--theme-primary, var(--primary,
                                            var(--primary-color, #2563eb))))))))));
    --aps-primary-dark: #1d4ed8;
    --aps-text: #111827;
    --aps-border: #e5e7eb;
    --aps-muted: #f3f4f6;
    --aps-radius: 10px;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Buttons */
.aps-btn {
    display: inline-block;
    padding: .6em 0;
    text-decoration: none;
    line-height: 1.2;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    border-radius: 10px;
    border: 1px solid;
}


.aps-primary {
    color: #fff;
}


.aps-secondary {
    background: var(--aps-muted);
    color: var(--aps-text);
    border-color: var(--aps-border);
}

.aps-secondary:hover {
    background: #e5e7eb;
}

.aps-outline {
    background: transparent;
    color: var(--aps-text);
    border-color: #9ca3af;
}

.aps-outline:hover {
    background: #f9fafb;
}

.aps-sm {
    font-size: 13px;
}

.aps-md {
    font-size: 15px;
    padding-right: 15px;
    padding-left: 15px;
}

.aps-lg {
    font-size: 17px;
    padding: .7em 1.2em;
}

/* Tables */
.aps-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 15px;
}

.aps-table th,
.aps-table td {
    border: 1px solid var(--aps-border);
    padding: .6rem .75rem;
    text-align: start;
    vertical-align: middle;
}

.aps-table thead th {
    background: var(--aps-muted);
    font-weight: 700;
}

/* TOC (یکپارچه) */
.aps-toc {
    position: relative;
    padding: .75rem 1rem;
    margin: 1rem 0 1.25rem;
    border: 1px solid var(--aps-border);
    border-radius: var(--aps-radius);
    background: #fff;
}

.aps-toc__title {
    font-weight: 700;
    margin-bottom: .5rem;
}

.aps-toc__root {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aps-toc__root>li {
    margin: .25rem 0;
}

.aps-toc a {
    text-decoration: none !important;
    color: inherit;
}

.aps-toc a:hover {
    text-decoration: underline;
}

.aps-toc__group {
    margin: .2rem 0;
}

.aps-toc__row {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.aps-toc__btn {
    width: 1.6rem;
    height: 1.6rem;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    outline: none !important;
}

.aps-toc__btn--empty {
    width: 1.6rem;
    height: 1.6rem;
    display: inline-block;
}

.aps-toc__caret {
    width: .8rem;
    height: .8rem;
    position: relative;
    display: block;
}

.aps-toc__caret::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: .55rem;
    height: .55rem;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: rotate(45deg);
    transition: transform .2s ease;
}

.aps-toc__btn[aria-expanded="true"] .aps-toc__caret::before {
    transform: rotate(-135deg);
}

.aps-toc__children {
    margin: .25rem 0 .5rem 2.2rem;
    padding: 0 0 0 .6rem;
    list-style: disc;
    overflow: hidden;
    transition: height .22s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.aps-toc__children[hidden] {
    display: block;
    height: 0;
}

.aps-toc__children .lvl-3 {
    list-style: circle;
}

.aps-toc__children .lvl-4 {
    list-style: square;
    padding-inline-start: 12px;
}

/* Related Post */
.aps-related {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 14px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--aps-border);
    border-radius: 12px;
    padding: 12px;
    margin: 18px 0;
}

.aps-related__thumb img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}

.aps-related__title {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.aps-related__title a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    margin-bottom: 0;
    max-height: 85px;
    max-width: 445px;
    line-height: 25px;
}

@media (max-width:640px) {
    .aps-related {
        grid-template-columns: 1fr;
    }
}

/* CTA */
.aps-cta {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin: 24px 0;
}

.aps-cta__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .06);
    pointer-events: none;
}

.aps-cta__inner {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 24px;
    padding: 28px;
    flex-direction: row-reverse;
    justify-content: space-between;
}

.aps-cta__col--left {}

.aps-cta__col--right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.aps-cta__content {
    font-size: 16px;
    line-height: 1.8;
    font-weight: 600;
    text-align: justify;
}

.aps-cta__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

@media (max-width:992px) {
    .aps-cta__inner {
        grid-template-columns: 1fr;
    }

    .aps-cta__col--left {
        display: none;
    }
}

/* FAQ (Accordion) */
.aps-faq {
    margin-top: 32px;
}

.aps-faq__title {
    font-size: 1.25rem;
    margin-bottom: 20px;
}

.aps-accordion {
    border: 0;
}

.aps-acc-item {
    border: 1px solid var(--aps-border);
    border-radius: 10px;
    margin-bottom: 10px;
    background: #fff;
    overflow: hidden;
    padding-bottom: 10px;
}

.aps-acc-summary {
    width: 100%;
    text-align: start;
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #fff;
    border: 0;
    padding: 12px 14px;
    font-weight: 600;
    cursor: pointer;
    flex-direction: row-reverse;
    justify-content: space-between;
    padding-bottom: 10px;
    margin-top: 10px;
}

.aps-acc-summary:focus {
    outline: none;
}

.aps-acc-icon {
    width: 1rem;
    height: 1rem;
    display: inline-block;
    position: relative;
    flex: 0 0 1rem;
}

.aps-acc-icon::before,
.aps-acc-icon::after {
    content: "";
    position: absolute;
    background: #6b7280;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.aps-acc-icon::before {
    width: 12px;
    height: 2px;
}

.aps-acc-icon::after {
    width: 2px;
    height: 12px;
    transition: opacity .2s ease;
}

.aps-acc-summary[aria-expanded="true"] .aps-acc-icon::after {
    opacity: 0;
}

.aps-acc-panel {
    overflow: hidden;
    transition: height .24s ease;
    padding: 0 14px;
}

.aps-acc-panel[hidden] {
    display: block;
    height: 0;
}


/* Products Carousel */
.aps-products {
    margin: 28px 0;
}

.aps-products__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.aps-products__title {
    font-size: 1.2rem;
    margin: 0;
}

.aps-products__nav {
    display: flex;
    gap: 8px;
}

.aps-products__nav button {
    border: 1px solid var(--aps-border);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.aps-products__track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
}

.aps-product-card {
    flex: 0 0 calc(25% - 10.5px);
    scroll-snap-align: start;
    background: #fff;
    border: 1px solid var(--aps-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aps-product-card__thumb img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.aps-product-card__title {
    font-size: .98rem;
    margin: 4px 0;
    line-height: 1.5;
}

.aps-product-card__title a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    margin-bottom: 0;
    max-height: 85px;
    max-width: 445px;
    line-height: 30px;
    min-height: 60px;
}

.aps-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aps-products[data-cols="3"] .aps-product-card {
    flex-basis: calc(33.333% - 9.33px);
}

.aps-products[data-cols="2"] .aps-product-card {
    flex-basis: calc(50% - 7px);
}

.aps-products[data-cols="1"] .aps-product-card {
    flex-basis: 100%;
}

@media (max-width:992px) {
    .aps-products .aps-product-card {
        flex-basis: calc(33.333% - 9.33px);
    }
}

@media (max-width:768px) {
    .aps-products .aps-product-card {
        flex-basis: calc(50% - 7px);
    }
}

@media (max-width:480px) {
    .aps-products .aps-product-card {
        flex-basis: 100%;
    }
}

/* Optional legacy button */
.my-shortcode-button {
    background: #fff;
    font-weight: 700;
    color: var(--aps-primary);
    fill: currentColor;
    border: 1px solid currentColor;
    border-radius: 10px 25px 10px 25px;
    padding: 10px 30px;
    display: inline-flex;
    gap: .5rem;
}

.my-shortcode-button:hover {
    background: var(--aps-primary);
    color: #fff !important;
}