/**
 * Tabbed Mega Menu Styles
 * Styles for tabbed navigation in The7 mega menus
 * Matches The7 design system and existing mega menu styling
 */

@media (min-width: 769px) {
    /* Tabs Navigation Container */
    .dt-mega-menu-tabbed .dt-mega-menu-wrap {
        display: flex;
        flex-direction: row;
        position: relative;
        align-items: stretch;
        overflow: hidden;
    }

    .dt-mega-tabs-nav {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap;
        gap: 0;
        padding: 4px 0;
        background-color: rgba(0, 0, 0, 0.08);
        order: -1;
        position: relative;
        z-index: 2;
        width: auto;
        max-width: fit-content;
        flex-shrink: 0;
        margin-right: 0;
    }

    /* Ensure tab button list items stack vertically */
    .dt-mega-tabs-nav > li {
        display: block !important;
        width: 100%;
        float: none !important;
    }

    .dt-mega-menu-wrap {
        margin-top: 0;
    }

    /* Container for tab content */
    .dt-mega-menu-tabbed .dt-mega-menu-wrap > .sub-nav {
        position: relative;
        flex: 1;
        padding: 0;
    }

    /* Tab Buttons - Match The7 mega menu title styling */
    .dt-mega-tab-button {
        padding: 14px 16px;
        background-color: transparent;
        border: none;
        border-left: 3px solid transparent;
        cursor: pointer;
        font-size: 18px;
        font-weight: 600;
        line-height: 1.4;
        transition: all 0.2s ease;
        position: relative;
        color: inherit;
        margin: 0;
        outline: none;
        text-align: left;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        width: 100% !important;
        white-space: nowrap;
        min-width: auto;
    }

    .dt-mega-tabs-nav > li > a.dt-mega-tab-button {
        display: flex !important;
        width: 100%;
    }

    /* Arrow indicator for active/hover state */
    .dt-mega-tab-button::after {
        content: '→';
        opacity: 0;
        margin-left: 12px;
        transition: opacity 0.2s ease;
        font-size: 18px;
    }

    .dt-mega-tab-button .menu-text {
        padding-right: 32px;
    }

    /* Hover state - matches mega menu hover */
    .dt-mega-tab-button:hover {
        background-color: rgba(0, 0, 0, 0.05);
        border-left-color: transparent;
    }

    .dt-mega-tab-button:hover::after {
        opacity: 0.6;
    }

    /* Active state - uses accent color like current menu items */
    .dt-mega-tab-button.dt-tab-button-active {
        background-color: rgba(0, 0, 0, 0.12);
        border-left-color: transparent;
        font-weight: 700;
    }

    .dt-mega-tab-button.dt-tab-button-active::after {
        opacity: 1;
    }

    /* Hide level 2 item titles when in tabbed mode (tabs replace them) */
    .dt-mega-menu-tabbed .dt-mega-tab > a {
        display: none !important;
    }

    /* Tab Content Visibility */
    .dt-mega-menu-tabbed .dt-mega-tab {
        position: relative;
        display: none !important; /* Hide all tabs by default */
        width: 100% !important;
        max-width: 100%;
        padding: 0 !important; /* Override default mega parent padding for tabs */
    }

    /* Show active tab */
    .dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active {
        display: block !important; /* Only show active tab */
        opacity: 1;
        visibility: visible;
    }

    /* Hide inactive tab content */
    .dt-mega-menu-tabbed .dt-mega-tab:not(.dt-tab-active) {
        display: none !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab:not(.dt-tab-active) > .sub-nav {
        display: none !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active > .sub-nav {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 10px 20px;
        width: 100%;
        min-height: 100%;
        opacity: 1 !important;
        visibility: visible !important;
        align-content: start;
    }

    /* Level 3 items layout - maintain existing mega menu structure */
    .dt-mega-menu-tabbed .dt-mega-tab .sub-nav {
        position: relative;
        width: 100%;
        padding: 0;
        background: none;
        box-shadow: none;
    }

    .dt-mega-menu-tabbed .dt-mega-tab .sub-nav > li {
        position: relative;
        padding: 0;
    }

    /* Ensure proper visibility when mega menu is shown */
    .dt-mega-menu.dt-hovered .dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active > .sub-nav,
    .show-mega-menu.dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active > .sub-nav {
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Smooth transitions matching The7's animation style */
    .dt-mega-menu-tabbed .dt-mega-tab .sub-nav {
        transition: opacity 0.15s ease;
    }

    .dt-mega-tab-button {
        transition: all 0.15s ease;
    }

    /* Simple fade in for tab content */
    .dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active > .sub-nav {
        animation: dt-tab-fadeIn 0.2s ease;
    }

    @keyframes dt-tab-fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    /* Maintain existing mega menu structure for level 3 items */
    .masthead:not(.sub-downwards) .dt-mega-menu-tabbed .dt-mega-tab .sub-nav,
    .masthead:not(.sub-downwards) .dt-mega-menu-tabbed .dt-mega-tab .sub-nav.right-overflow {
        position: relative;
        left: auto !important;
        top: auto;
        max-width: 100%;
        padding: 0;
        background: none;
        box-shadow: none;
    }

    /* Show level 3 items in active tab */
    .dt-mega-menu-tabbed.dt-hovered .sub-nav .sub-nav,
    .show-mega-menu.dt-mega-menu-tabbed .sub-nav .sub-nav {
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Spacing for level 3 items */
    .dt-mega-parent .sub-nav .sub-nav {
        margin-left: 20px;
    }

    /* Tab Color Theming */
    /* Wood theme */
    .dt-mega-menu-tabbed .dt-mega-tab-button.tab-color-wood.dt-tab-button-active {
        border-left-color: var(--color-wood);
        background-color: var(--color-wood);
        color: #fff !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab-button.tab-color-wood.dt-tab-button-active .menu-text,
    .dt-mega-menu-tabbed .dt-mega-tab-button.tab-color-wood.dt-tab-button-active:hover .menu-text {
        color: #fff !important;
    }


    .dt-mega-menu-tabbed .dt-mega-tab.dt-tab-active {
        padding: 30px 20px 30px 30px !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-wood.dt-tab-active {
        background-color: var(--color-wood) !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-wood.dt-tab-active > .sub-nav,
    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-wood.dt-tab-active > .sub-nav * {
        color: #fff !important;
    }

    /* Glass theme */
    .dt-mega-menu-tabbed .dt-mega-tab-button.tab-color-glass.dt-tab-button-active {
        border-left-color: var(--color-glass);
        background-color: var(--color-glass);
        color: #000;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-glass.dt-tab-active {
        background-color: var(--color-glass) !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-glass.dt-tab-active > .sub-nav,
    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-glass.dt-tab-active > .sub-nav * {
        color: #000 !important;
    }

    /* Stone theme */
    .dt-mega-menu-tabbed .dt-mega-tab-button.tab-color-stone.dt-tab-button-active {
        border-left-color: var(--color-stone);
        background-color: var(--color-stone);
        color: #000;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-stone.dt-tab-active {
        background-color: var(--color-stone) !important;
    }

    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-stone.dt-tab-active > .sub-nav,
    .dt-mega-menu-tabbed .dt-mega-tab.tab-color-stone.dt-tab-active > .sub-nav * {
        color: #000 !important;
    }
}
