.yilko-header-mega-parent {
    position: relative !important;
}

.yilko-custom-mega-wrapper {
    display: flex;
    direction: rtl;
    background: #fff;
}

.yilko-mega-tab-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    padding: 12px 15px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    color: #555;
    text-decoration: none !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.yilko-tab-right-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.yilko-tab-text {
    font-weight: bold;
}

.yilko-tab-icon-right {
    width: 34px;
    height: 34px;
    position: relative;
    flex-shrink: 0;
}

.yilko-tab-icon-right img {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.icon-active {
    opacity: 0;
}

.yilko-tab-arrow {
    width: 24px;
    height: 24px;
    opacity: 0.6;
    flex-shrink: 0;
    background: url('https://yilkoshop.com/wp-content/uploads/2026/02/Alt-Arrow-Left.svg') center / contain no-repeat;
    transition: opacity 0.3s ease;
}

.yilko-mega-tab-btn:hover,
.yilko-mega-tab-btn.active {
    background: #fdf5e6;
    color: #e66806;
}

.yilko-mega-tab-btn:hover .yilko-tab-arrow,
.yilko-mega-tab-btn.active .yilko-tab-arrow {
    opacity: 1;
}

.yilko-mega-tab-btn:hover .icon-default,
.yilko-mega-tab-btn.active .icon-default {
    opacity: 0;
}

.yilko-mega-tab-btn:hover .icon-active,
.yilko-mega-tab-btn.active .icon-active {
    opacity: 1;
}

.yilko-mega-panel {
    display: none;
}

.yilko-mega-list-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 0 15px;
    margin-bottom: 15px;
    font-weight: bold;
    color: #333;
    font-size: 15px;
    box-sizing: border-box;
}

.yilko-header-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.yilko-mega-list-col ul {
    list-style: none;
    padding: 0 0 0 0;
    margin: 0;
    border-right: 1px solid #eaeaea;
    padding-right: 15px;
}

.yilko-mega-list-col li {
    margin-bottom: 12px;
}

.yilko-mega-list-col a {
    color: #666;
    text-decoration: none !important;
    font-size: 14px;
    transition: color 0.2s ease;
}

.yilko-mega-list-col a:hover {
    color: #e66806 !important;
    font-weight: bold;
}

@media (min-width: 1025px) {
    .yilko-custom-mega-wrapper {
        width: 1320px !important;
        max-width: 96vw;
        min-height: 478px;
        border-radius: 12px;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
        padding: 15px;
        gap: 20px;
        position: absolute;
        /*
         * مقدار --yilko-mega-lift توسط JS بر اساس ارتفاع واقعی viewport
         * محاسبه می‌شود. در مانیتورهای معمولی صفر است و در لپ‌تاپ‌های
         * کم‌ارتفاع فقط به اندازه لازم منو را بالا می‌آورد.
         */
        top: calc(100% + 15px - var(--yilko-mega-lift, 0px));
        right: 0;
        margin-top: 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(15px);
        z-index: 99999;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.3s ease-in-out;
        max-height: calc(100vh - 24px);
    }

    .yilko-custom-mega-wrapper::before {
        content: '';
        position: absolute;
        top: -15px;
        left: 0;
        width: 100%;
        height: 15px;
        background: transparent;
    }

    /*
     * فقط مگامنوی قطعات در دسکتاپ ۲۰٪ عرض viewport به سمت راست منتقل می‌شود.
     * منوی ابزارآلات، جای شورت‌کدها و نسخهٔ موبایل هیچ تغییری ندارند.
     */
    #yilko-mega-wrap-parts {
        transform: translateX(8vw) translateY(15px);
    }

    .yilko-header-mega-parent:hover #yilko-mega-wrap-parts,
    .yilko-header-mega-parent:focus-within #yilko-mega-wrap-parts {
        transform: translateX(8vw) translateY(0);
    }

    .yilko-header-mega-parent:hover .yilko-custom-mega-wrapper,
    .yilko-header-mega-parent:focus-within .yilko-custom-mega-wrapper {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .yilko-mega-sidebar {
        width: 250px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        height: 478px;
        max-height: 478px;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: thin;
        scrollbar-color: #bfbfbf transparent;
        padding-left: 10px;
        border-left: 2px solid #f0f0f0;
    }

    .yilko-mega-sidebar::-webkit-scrollbar {
        width: 13px;
    }

    .yilko-mega-sidebar::-webkit-scrollbar-track {
        background: linear-gradient(to right, transparent 6px, #e5e5e5 6px, #e5e5e5 7px, transparent 7px);
    }

    .yilko-mega-sidebar::-webkit-scrollbar-thumb {
        background-color: #bfbfbf;
        border-radius: 999px;
        border-left: 3px solid transparent;
        border-right: 3px solid transparent;
        background-clip: padding-box;
        min-height: 52px;
    }

    .yilko-mega-content-area {
        flex-grow: 1;
        position: relative;
    }

    .yilko-mega-panel.active {
        display: flex !important;
        gap: 30px;
        /* تعویض تب باید بدون Fade/Translate انجام شود تا هیچ پرشی دیده نشود. */
        animation: none !important;
        transform: none !important;
    }

    .yilko-mega-tab-btn.hide-mobile-subs .yilko-tab-arrow {
        display: block !important;
        opacity: 0.6;
    }

    .yilko-mega-tab-btn.hide-mobile-subs:hover .yilko-tab-arrow {
        opacity: 1;
    }

    .yilko-mega-lists {
        display: flex;
        gap: 40px;
        flex-grow: 1;
        flex-wrap: nowrap;
    }

    .yilko-mega-list-col {
        flex: 1;
    }

    .yilko-mega-list-header {
        width: 100%;
        max-width: 300px;
        height: 54px;
    }

    .yilko-mega-banner {
        width: 220px;
        border-radius: 12px;
        overflow: hidden;
        background: #fff5eb;
        flex-shrink: 0;
    }

    .yilko-mega-banner img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 9990;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
    }

    body.yilko-mega-open::before {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 1024px) {
    /*
     * مهم: شورت‌کد مگامنو ممکن است هم‌زمان داخل هدر دسکتاپ Elementor
     * هم در DOM وجود داشته باشد. در تبلت/موبایل آن نسخه باید کاملاً از
     * Layout خارج شود تا آیتم‌های منو پشت محتوای صفحه دیده نشوند.
     * فقط کپی‌ای که داخل Drawer خود افزونه Mount می‌شود مجاز به نمایش است.
     */
    .yilko-custom-mega-wrapper {
        display: none !important;
    }

    .yilko-template-modal .yilko-custom-mega-wrapper {
        display: flex !important;
        width: 282px !important;
        min-width: unset;
        flex-direction: column;
        position: relative;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        padding: 10px 0;
        transform: none;
        background: transparent;
    }

    .yilko-mega-sidebar {
        width: 100%;
        height: auto;
        max-height: none;
        overflow: visible;
        border: none;
        padding-left: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .yilko-mega-tab-btn {
        background: #f9f9f9;
        padding: 10px 12px;
    }

    .yilko-mega-content-area {
        display: none;
    }

    .yilko-mega-tab-btn.hide-mobile-subs .yilko-tab-arrow {
        display: none !important;
    }

    .yilko-mega-panel.mobile-hidden-panel {
        display: none !important;
    }

    .yilko-mega-panel.active {
        display: flex;
        flex-direction: column;
        gap: 15px;
        padding: 5px 15px 15px 0;
        margin-bottom: 5px;
        animation: yilkoFadeIn 0.3s ease;
    }

    .yilko-mega-lists {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .yilko-mega-list-col {
        width: 100%;
    }

    .yilko-mega-list-header {
        width: 100%;
        height: auto;
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    .yilko-mega-banner {
        display: none;
    }
}

/* قالب کشویی موبایل — ظاهر قبلی بدون تغییر بصری */
.yilko-template-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.yilko-template-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border-radius: 0;
    z-index: 999999;
    visibility: hidden;
    transform: translateX(100%);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s ease;
}

.yilko-template-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.yilko-template-modal.active {
    transform: translateX(0);
    visibility: visible;
}

.yilko-template-close {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #f5f5f5;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    z-index: 9999999;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.yilko-template-close:hover {
    background: #e66806;
    color: #fff;
}

.yilko-template-modal::-webkit-scrollbar {
    width: 4px;
}

.yilko-template-modal::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 10px;
}

@media (min-width: 1025px) {
    .yilko-template-overlay,
    .yilko-template-modal {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yilko-custom-mega-wrapper,
    .yilko-mega-tab-btn,
    .yilko-tab-icon-right img,
    .yilko-tab-arrow,
    .yilko-template-overlay,
    .yilko-template-modal,
    .yilko-template-close {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
