/*
 * Digikala-Style Mega Menu
 * مگا منو به سبک دیجی‌کالا با سایدبار چپ و محتوای راست
 * 
 * Features:
 * - Left sidebar with main categories (vertical list)
 * - Right content area with subcategories (3-5 columns)
 * - Smooth fade/slide animations
 * - RTL layout support
 * - Fully responsive
 */

/* === Container اصلی مگا منو === */
.mega-menu {
    display: none;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    width: 95vw;
    max-width: 1200px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 0 0 8px 8px;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1090;
    margin-right: 0;
    border: 1px solid #e0e0e0;
    transform: translateY(-10px);
    overflow: hidden;
}

/* === Wrapper برای سایدبار و محتوا === */
.mega-menu-wrapper {
    display: flex;
    direction: rtl;
    min-height: 400px;
    max-height: 600px;
}

/* === سایدبار چپ: دسته‌بندی‌های اصلی === */
.mega-menu-sidebar {
    width: 280px;
    min-width: 280px;
    background: #f5f5f5;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    overflow-x: hidden;
}

.mega-menu-categories-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-category-item {
    position: relative;
    border-bottom: 1px solid #e8e8e8;
}

.mega-menu-category-item:last-child {
    border-bottom: none;
}

.mega-menu-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: #424750;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.mega-menu-category-link:hover {
    background: #fff;
    color: #b91c1c;
    text-decoration: none;
}

.mega-menu-category-item.active .mega-menu-category-link {
    background: #fff;
    color: #b91c1c;
    font-weight: 600;
}

.mega-menu-category-item.active .mega-menu-category-link::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #b91c1c;
}

.mega-menu-category-title {
    flex: 1;
    text-align: right;
}

.mega-menu-arrow {
    font-size: 12px;
    color: #a1a3a8;
    transition: transform 0.2s ease;
    margin-right: 8px;
}

.mega-menu-category-item.active .mega-menu-arrow {
    color: #b91c1c;
    transform: translateX(-3px);
}

/* === محتوای راست: زیردسته‌بندی‌ها === */
.mega-menu-content {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.mega-menu-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.mega-menu-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mega-menu-panel-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #b91c1c;
}

.mega-menu-panel-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #23254e;
}

.mega-menu-panel-title a {
    color: #23254e;
    text-decoration: none;
    transition: color 0.2s ease;
}

.mega-menu-panel-title a:hover {
    color: #b91c1c;
    text-decoration: none;
}

.mega-menu-panel-body {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
}

.mega-menu-column {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mega-menu-link {
    display: block;
    padding: 8px 0;
    color: #424750;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s ease;
    position: relative;
    padding-right: 16px;
}

.mega-menu-link::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: #c0c2c5;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mega-menu-link:hover {
    color: #b91c1c;
    text-decoration: none;
    padding-right: 24px;
}

.mega-menu-link:hover::before {
    opacity: 1;
}

.mega-menu-empty-message {
    color: #81858b;
    font-size: 14px;
    margin: 20px 0;
    text-align: center;
}

.mega-menu-empty {
    padding: 40px;
    text-align: center;
    color: #81858b;
}

/* === Scrollbar سفارشی === */
.mega-menu-sidebar::-webkit-scrollbar,
.mega-menu-content::-webkit-scrollbar {
    width: 6px;
}

.mega-menu-sidebar::-webkit-scrollbar-track,
.mega-menu-content::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 3px;
}

.mega-menu-sidebar::-webkit-scrollbar-thumb,
.mega-menu-content::-webkit-scrollbar-thumb {
    background: #c0c2c5;
    border-radius: 3px;
}

.mega-menu-sidebar::-webkit-scrollbar-thumb:hover,
.mega-menu-content::-webkit-scrollbar-thumb:hover {
    background: #a1a3a8;
}

/* === وضعیت باز === */
.megamenu-parent.open + .mega-menu,
.mega-menu.open {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* === Responsive: Tablet === */
@media (max-width: 991px) {
    .mega-menu {
        width: 100vw;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
    }
    
    .mega-menu-wrapper {
        flex-direction: column;
        min-height: auto;
        max-height: 70vh;
    }
    
    .mega-menu-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-left: none;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .mega-menu-content {
        padding: 20px;
        max-height: calc(70vh - 200px);
    }
    
    .mega-menu-panel-body {
        gap: 24px;
    }
    
    .mega-menu-column {
        min-width: 150px;
    }
}

/* === Responsive: Mobile === */
@media (max-width: 768px) {
    .mega-menu-wrapper {
        max-height: 80vh;
    }
    
    .mega-menu-sidebar {
        max-height: 180px;
    }
    
    .mega-menu-category-link {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .mega-menu-content {
        padding: 16px;
        max-height: calc(80vh - 180px);
    }
    
    .mega-menu-panel-header {
        margin-bottom: 16px;
    }
    
    .mega-menu-panel-title {
        font-size: 16px;
    }
    
    .mega-menu-panel-body {
        gap: 16px;
        flex-direction: column;
    }
    
    .mega-menu-column {
        min-width: 100%;
    }
    
    .mega-menu-link {
        font-size: 12px;
        padding: 6px 0;
    }
}

/* === حذف استایل‌های قدیمی === */
.continuous-menu-list,
.main-category,
.sub-category {
    display: none !important;
}
