/**
 * Category Mega Menu — desktop two-panel hover / tablet click
 */

.mega-menu {
    position: relative;
    z-index: 200;
}

.mega-menu .mega-menu-panel {
    min-width: 0;
    max-width: none;
    width: max-content;
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
    z-index: 1100;
}

.mega-menu-inner {
    display: flex;
    min-width: 420px;
}

.mega-menu-brands {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    padding: 8px;
    border-right: 1px solid #E2E8F0;
    background: #FAFBFC;
}

body.dark-mode .mega-menu-brands {
    background: #0F172A;
    border-right-color: #334155;
}

.mega-menu-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: #1E293B;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.mega-menu-brand:hover,
.mega-menu-brand.is-active,
.mega-menu-brand:focus-visible {
    background: #FFFFFF;
    color: #2563EB;
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body.dark-mode .mega-menu-brand {
    color: #E2E8F0;
}

body.dark-mode .mega-menu-brand:hover,
body.dark-mode .mega-menu-brand.is-active,
body.dark-mode .mega-menu-brand:focus-visible {
    background: #1E293B;
    color: #60A5FA;
    box-shadow: none;
}

.mega-menu-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.5;
}

.mega-menu-brand.is-active .mega-menu-chevron {
    opacity: 1;
}

.mega-menu-models {
    position: relative;
    min-width: 200px;
    padding: 8px;
}

.mega-menu-models-panel {
    display: none;
    flex-direction: column;
    gap: 2px;
}

.mega-menu-models-panel.is-active {
    display: flex;
}

.mega-menu-models-header {
    padding: 8px 12px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

body.dark-mode .mega-menu-models-header {
    color: #94A3B8;
}

.mega-menu .dropdown-item.active {
    background: #EFF6FF;
    color: #2563EB;
}

body.dark-mode .mega-menu .dropdown-item.active {
    background: rgba(37, 99, 235, 0.15);
    color: #60A5FA;
}

/* Mobile: hide mega menu, show mobile trigger */
.category-mobile-trigger {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: #64748B;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-radius: var(--radius, 6px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-mobile-trigger:hover,
.category-mobile-trigger.active {
    color: #2563EB;
    background: #EFF6FF;
}

body.dark-mode .category-mobile-trigger {
    color: #94A3B8;
}

body.dark-mode .category-mobile-trigger:hover,
body.dark-mode .category-mobile-trigger.active {
    color: #60A5FA;
    background: rgba(37, 99, 235, 0.15);
}

@media (max-width: 767px) {
    .mega-menu {
        display: none !important;
    }

    .category-mobile-trigger {
        display: inline-flex;
    }
}

/* Tablet: click opens panel */
@media (min-width: 768px) and (max-width: 1023px) {
    .mega-menu:not(.active) .mega-menu-panel {
        pointer-events: none;
    }

    .mega-menu.active .mega-menu-panel {
        pointer-events: auto;
        opacity: 1;
        visibility: visible;
        transform: translate3d(0, 0, 0);
    }

    .mega-menu.active .dropdown-icon {
        transform: rotate(180deg);
    }
}

/* Desktop & tablet: show panel when active or hovered */
@media (min-width: 768px) {
    .mega-menu.active .mega-menu-panel,
    .mega-menu:hover .mega-menu-panel {
        opacity: 1;
        visibility: visible;
        transform: translate3d(0, 0, 0);
    }

    .mega-menu.active .dropdown-icon,
    .mega-menu:hover .dropdown-icon {
        transform: rotate(180deg);
    }

    .mega-menu.active .dropdown-toggle {
        color: #2563EB;
        background: #EFF6FF;
    }

    body.dark-mode .mega-menu.active .dropdown-toggle {
        color: #60A5FA;
        background: rgba(37, 99, 235, 0.15);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mega-menu-brand,
    .category-mobile-trigger {
        transition: none;
    }
}
