﻿@font -face {
    font-family: 'BNazanin';
    src: url('/fonts/BNazanin.woff2') format('woff2'), url('/fonts/BNazanin.woff') format('woff'), url('/fonts/BNazanin.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}


/* ===== DK Mega Menu (FINAL) ===== */
.dk-mega, .dk-mega * {
    box-sizing: border-box;
}

.dk-wrap {
    position: relative;
}

/* بسته/باز شدن با کلاس dk-open */
.dk-mega {
    position: absolute; /* برای اینکه به trigger بچسبد و نپرد */
    top: 100%;
    margin-top: -2px; /* overlap برای حذف شکاف */
    z-index: 9999999;
    /* چسبیدن به لبه راست صفحه */
    right: 10px;
    width: min(1200px, 95vw);
    height: min(560px, calc(100vh - 120px));
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(0,0,0,0.20);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    pointer-events: none;
    transition: .18s ease;
    font-size: 13px;
}

/* اگر منوی شما داخل container وسط‌چین است و به لبه راست نمی‌چسبد،
   این rule منو را به راست صفحه می‌کشد (Pixel-perfect) */
.dk-wrap .dk-mega {
    /* فاصله کانتینر از راست صفحه را خنثی کن */
    margin-right: calc((100vw - 100%) / -2);
}

/* باز شدن */
.dk-wrap.dk-open .dk-mega {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* پل نامرئی برای جلوگیری از پرش هنگام رفتن موس به داخل منو */
.dk-wrap::after {
    content: "";
    position: absolute;
    right: 0;
    top: 100%;
    width: 100%;
    height: 12px;
    background: transparent;
}

/* ===== Layout Fix (Right/Left stable) ===== */
.dk-mega-inner {
    height: 100%;
    display: flex;
    flex-direction: row;
    direction: ltr; /* layout پایدار */
    gap: 14px;
    padding: 14px;
}

/* راست: والدها */
.dk-parents {
    order: 2; /* همیشه راست */
    direction: rtl;
    flex: 0 0 290px;
    width: 290px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px;
    overflow-y: auto;
}

/* چپ: پنل */
.dk-panel {
    order: 1; /* همیشه چپ */
    direction: rtl;
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;
}

/* لینک همه دسته‌بندی‌ها */
.dk-allcats {
    display: block;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 10px;
    font-weight: 800;
    color: #111827;
    text-decoration: none;
}

    .dk-allcats:hover {
        background: rgba(34,197,94,0.12);
        color: #16a34a;
    }

/* آیتم والد */
.dk-parent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    color: #111827;
}

    .dk-parent-item:hover,
    .dk-parent-item.is-active {
        background: rgba(34,197,94,0.12);
        color: #16a34a;
    }

/* پنل‌ها */
.dk-panel-section {
    display: none;
}

    .dk-panel-section.is-active {
        display: block;
    }

/* عنوان پنل */
.dk-panel-title {
    display: block;
    font-weight: 800;
    margin: 4px 0 12px;
    color: #111827;
    text-decoration: none;
}

    .dk-panel-title:hover {
        color: #16a34a;
    }

/* شبکه زیر دسته‌ها */
.dk-children-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 10px;
}

/* لینک زیر دسته */
.dk-child-link {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #eef2f7;
    color: #374151;
    text-decoration: none;
    line-height: 1.6;
    transition: .12s ease;
}

    .dk-child-link:hover {
        background: rgba(34,197,94,0.10);
        border-color: rgba(34,197,94,0.25);
        color: #16a34a;
    }

/* اسکرول بار */
.dk-parents::-webkit-scrollbar,
.dk-panel::-webkit-scrollbar {
    width: 8px;
}

.dk-parents::-webkit-scrollbar-thumb,
.dk-panel::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* Responsive */
@media (max-width:1024px) {
    .dk-children-grid {
        grid-template-columns: repeat(3, minmax(0,1fr));
    }

    .dk-parents {
        flex-basis: 260px;
        width: 260px;
    }
}

@media (max-width:768px) {
    .dk-mega-inner {
        flex-direction: column;
        direction: rtl;
    }

    .dk-parents {
        order: 1;
        width: 100%;
        flex-basis: auto;
        max-height: 220px;
    }

    .dk-panel {
        order: 2;
        max-height: 360px;
    }

    .dk-children-grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }

    /* در موبایل دیگه margin-right لازم نیست */
    .dk-wrap .dk-mega {
        margin-right: 0;
        width: 95vw;
    }
}