/**
 * Digikala-Style Mega Menu
 * Modern, clean, and professional design
 */

/* ========================================
   Base Mega Menu Container
   ======================================== */

.menu-item-has-mega-menu {
    position: relative;
}

.panda-mega-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 920px;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border-radius: 0 0 16px 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    overflow: hidden;
}

.menu-item-has-mega-menu:hover .panda-mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ========================================
   Mega Menu Layout (Digikala Style)
   ======================================== */

.mega-menu-container {
    display: flex;
    min-height: 380px;
    max-height: 480px;
}

/* Right Sidebar - Tab Navigation */
.mega-menu-tabs {
    flex: 0 0 200px;
    background: #f7f7f7;
    border-left: 1px solid #e0e0e6;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c4c4c4 transparent;
}

.mega-menu-tabs::-webkit-scrollbar {
    width: 6px;
}

.mega-menu-tabs::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

.mega-menu-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.mega-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-right: 3px solid transparent;
    font-size: 13px;
    font-weight: 700;
    color: #3f4064;
    text-align: right;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.mega-tab-name {
    flex: 1;
    text-align: right;
}

.mega-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 20px;
    padding: 0 6px;
    background: #e0e0e6;
    color: #62636a;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    margin-left: 8px;
    transition: all 0.2s ease;
}

.mega-tab::after {
    content: '\f053';
    font-family: 'uicons-regular-rounded', sans-serif;
    font-size: 11px;
    color: #a1a3a8;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.mega-tab:hover {
    background: #ebebeb;
    color: #19bfd3;
}

.mega-tab:hover::after {
    color: #19bfd3;
}

.mega-tab:hover .mega-tab-count {
    background: #19bfd3;
    color: #fff;
}

.mega-tab.active {
    background: #fff;
    color: #19bfd3;
    border-right-color: #19bfd3;
    font-weight: 700;
}

.mega-tab.active::after {
    color: #19bfd3;
}

.mega-tab.active .mega-tab-count {
    background: #19bfd3;
    color: #fff;
}

/* Left Content Area */
.mega-menu-content {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    background: #fff;
    scrollbar-width: thin;
    scrollbar-color: #c4c4c4 transparent;
}

.mega-menu-content::-webkit-scrollbar {
    width: 6px;
}

.mega-menu-content::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

.mega-tab-content {
    display: none;
    animation: fadeInContent 0.3s ease;
}

.mega-tab-content.active {
    display: block;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   Categories Grid (Digikala Style)
   ======================================== */

.mega-categories-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.mega-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid #f1f2f4;
}

.mega-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mega-column {
    min-width: 0;
}

/* Parent Category Title */
.mega-parent-title {
    margin: 0 0 12px 0;
    padding: 0;
}

.mega-parent-title a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    font-weight: 800;
    color: #3f4064;
    text-decoration: none;
    transition: color 0.2s ease;
    position: relative;
    letter-spacing: -0.2px;
}

.mega-parent-name {
    flex: 1;
    position: relative;
    padding-right: 12px;
}

.mega-parent-name::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    background: #19bfd3;
    border-radius: 50%;
}

.mega-parent-count {
    font-size: 11px;
    font-weight: 600;
    color: #81858b;
    transition: color 0.2s ease;
}

.mega-parent-title a:hover {
    color: #19bfd3;
}

.mega-parent-title a:hover .mega-parent-count {
    color: #19bfd3;
}

/* Children List */
.mega-children-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mega-children-list li {
    margin: 0;
    padding: 0;
}

.mega-children-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 400;
    color: #81858b;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    line-height: 1.6;
    padding: 2px 0;
}

.mega-child-count {
    font-size: 10px;
    color: #a1a3a8;
    margin-left: 6px;
    transition: color 0.2s ease;
}

.mega-children-list a:hover {
    color: #19bfd3;
    padding-right: 8px;
}

.mega-children-list a:hover .mega-child-count {
    color: #19bfd3;
}

.mega-children-list a:hover::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: #19bfd3;
    border-radius: 50%;
}

/* View More Link */
.mega-view-more {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f2f4;
}

.mega-view-more a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #19bfd3;
    padding: 0 !important;
}

.mega-view-more a::before {
    display: none !important;
}

.mega-view-more a::after {
    content: '\f053';
    font-family: 'uicons-regular-rounded', sans-serif;
    font-size: 10px;
    transition: transform 0.2s ease;
}

.mega-view-more a:hover::after {
    transform: translateX(-3px);
}

/* View All Link */
.mega-view-all {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f2f4;
}

.mega-view-all a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #19bfd3;
    text-decoration: none;
    transition: gap 0.2s ease;
}

.mega-view-all a::after {
    content: '\f053';
    font-family: 'uicons-regular-rounded', sans-serif;
    font-size: 10px;
}

.mega-view-all a:hover {
    gap: 10px;
}

/* Empty State */
.mega-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

.mega-empty-state p {
    color: #81858b;
    font-size: 14px;
    margin: 0;
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 1024px) {
    .panda-mega-menu {
        width: 100%;
        max-width: 90vw;
    }
    
    .mega-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .mega-menu-tabs {
        flex: 0 0 180px;
    }
}

@media (max-width: 768px) {
    .menu-item-has-mega-menu {
        display: block;
    }
    
    .panda-mega-menu {
        position: static;
        transform: none;
        width: 100%;
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
        opacity: 1;
        visibility: visible;
        display: none;
        background: #f8f9fa;
    }
    
    .menu-item-has-mega-menu.mobile-open .panda-mega-menu {
        display: block;
    }
    
    .menu-item-has-mega-menu > a::after {
        content: '\f078';
        font-family: 'uicons-regular-rounded', sans-serif;
        margin-right: 8px;
        font-size: 10px;
        transition: transform 0.3s ease;
    }
    
    .menu-item-has-mega-menu.mobile-open > a::after {
        transform: rotate(180deg);
    }
    
    .mega-menu-container {
        flex-direction: column;
        min-height: auto;
        max-height: none;
    }
    
    .mega-menu-tabs {
        flex: none;
        background: #fff;
        border: none;
        max-height: none;
    }
    
    .mega-tab {
        padding: 16px 20px;
        border-right: none;
        border-bottom: 1px solid #f1f2f4;
        font-size: 14px;
    }
    
    .mega-tab-count {
        margin-left: 12px;
    }
    
    .mega-tab::after {
        content: '+';
        font-family: inherit;
        font-size: 18px;
        font-weight: 300;
        margin-left: 0;
    }
    
    .mega-tab.active::after {
        content: '−';
    }
    
    .mega-tab.active {
        background: #f7f7f7;
        border-right: none;
    }
    
    .mega-menu-content {
        padding: 0;
        max-height: none;
    }
    
    .mega-tab-content {
        padding: 20px;
        background: #fff;
        border-bottom: 1px solid #f1f2f4;
    }
    
    .mega-categories-grid {
        gap: 20px;
    }
    
    .mega-row {
        grid-template-columns: 1fr;
        gap: 20px;
        padding-bottom: 16px;
    }
    
    .mega-parent-title a {
        font-size: 13px;
    }
    
    .mega-children-list {
        gap: 8px;
    }
    
    .mega-children-list a {
        font-size: 12px;
    }
}

/* ========================================
   Performance & Accessibility
   ======================================== */

.panda-mega-menu,
.mega-tab-content {
    will-change: opacity, transform;
}

.mega-tab:focus,
.mega-parent-title a:focus,
.mega-children-list a:focus {
    outline: 2px solid #19bfd3;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .panda-mega-menu,
    .mega-tab,
    .mega-children-list a,
    .mega-tab-content {
        transition: none;
        animation: none;
    }
}

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] .mega-menu-tabs {
    border-left: none;
    border-right: 1px solid #e0e0e6;
}

[dir="rtl"] .mega-tab {
    border-right: none;
    border-left: 3px solid transparent;
    text-align: left;
}

[dir="rtl"] .mega-tab.active {
    border-left-color: #19bfd3;
}

[dir="rtl"] .mega-tab::after {
    content: '\f054';
}

[dir="rtl"] .mega-parent-title a::before {
    order: 2;
}

[dir="rtl"] .mega-children-list a:hover {
    padding-right: 0;
    padding-left: 8px;
}

[dir="rtl"] .mega-children-list a:hover::before {
    right: auto;
    left: 0;
}

[dir="rtl"] .mega-view-all a::after {
    content: '\f054';
}
