/* ==========================================================================
   BrandFlow Mega Menu Styles
   Premium, Modern, Glassmorphism Aesthetics
   ========================================================================== */

.brandflow-mega-menu-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: relative;
    width: 100%;
    z-index: 999;
}

/* Base List Resets */
.brandflow-mega-menu ul {
    list-style: none !important;
    margin: 0;
    padding: 0;
}

.brandflow-mega-menu a {
    text-decoration: none !important;
    color: inherit;
    transition: all 0.2s ease;
}

/* -----------------------------------------
   Desktop Navigation
----------------------------------------- */
@media (min-width: 992px) {
    .bf-mobile-toggle {
        display: none;
    }

    .brandflow-mega-menu {
        display: block;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
        padding: 0 10px;
    }

    .bf-menu-level-1 {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        row-gap: 5px;
    }

    .bf-menu-item {
        position: relative;
    }

    .bf-menu-item-header {
        display: flex;
        align-items: center;
        cursor: pointer;
    }

    .bf-menu-item-header > a {
        display: block;
        padding: 16px 4px 16px 14px;
        font-weight: 600;
        font-size: 14px;
        color: #1a1a1a;
        letter-spacing: 0.2px;
    }

    .bf-menu-item-header:hover > a {
        color: #d32f2f;
    }

    .bf-toggle-btn {
        padding: 16px 14px 16px 2px;
        display: flex;
        align-items: center;
        background: transparent;
        border-left: none; /* Visually seamless on desktop */
    }
    
    .bf-toggle-btn:hover {
        background: transparent;
    }

    .bf-dropdown-icon {
        width: 14px;
        height: 14px;
        color: #4b5563;
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .bf-menu-item:hover .bf-dropdown-icon,
    .bf-menu-item-header:hover .bf-dropdown-icon {
        transform: rotate(180deg);
        color: #d32f2f;
    }

    /* Mega Dropdown Panel - Free Floating with Screen Constraints */
    .brandflow-mega-menu {
        display: block;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
        padding: 0 20px;
    }

    .bf-mega-dropdown {
        position: absolute;
        top: 100%;
        /* left/right handled dynamically by JS to prevent screen overflow */
        width: max-content;
        min-width: min(600px, 90vw);
        max-width: 90vw; /* Prevent horizontal stretching of the webpage */
        max-height: 60vh; /* Extremely strict vertical constraint to prevent page stretching */
        overflow-y: auto; /* Enable scrolling if dropdown is taller than screen */
        background: #ffffff;
        border-radius: 12px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        border: 1px solid rgba(0,0,0,0.05);
        opacity: 0;
        visibility: hidden;
        margin-top: 15px; /* Replaces transform for animation so JS can control X axis freely */
        transition: margin-top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease, visibility 0.3s ease;
        padding: 30px;
        z-index: 1000;
        pointer-events: none;
    }

    .bf-menu-item:hover .bf-mega-dropdown {
        opacity: 1;
        visibility: visible;
        margin-top: 0;
        pointer-events: auto;
    }

    .bf-mega-dropdown-inner {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 30px;
    }

    .bf-column-title {
        margin: 0 0 15px 0;
        font-size: 16px;
        font-weight: 700;
        color: #111827;
        border-bottom: 2px solid #f3f4f6;
        padding-bottom: 8px;
    }
    
    .bf-column-title a:hover {
        color: #d32f2f;
    }

    .bf-menu-level-3 li {
        margin-bottom: 8px;
    }

    .bf-menu-level-3 a {
        font-size: 14px;
        color: #6b7280;
        display: inline-block;
        position: relative;
    }

    .bf-menu-level-3 a:hover {
        color: #d32f2f;
        transform: translateX(4px);
    }
}

/* -----------------------------------------
   Mobile Navigation
----------------------------------------- */
@media (max-width: 991px) {
    .brandflow-mega-menu-container {
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        overflow: hidden;
    }

    .bf-mobile-toggle {
        display: flex;
        align-items: center;
        padding: 16px 20px;
        cursor: pointer;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }

    .bf-hamburger {
        width: 24px;
        height: 20px;
        position: relative;
        margin-right: 12px;
    }

    .bf-hamburger span {
        display: block;
        position: absolute;
        height: 2px;
        width: 100%;
        background: #1e293b;
        border-radius: 2px;
        opacity: 1;
        left: 0;
        transform: rotate(0deg);
        transition: .25s ease-in-out;
    }

    .bf-hamburger span:nth-child(1) { top: 0px; }
    .bf-hamburger span:nth-child(2) { top: 9px; }
    .bf-hamburger span:nth-child(3) { top: 18px; }

    .bf-mobile-toggle.active .bf-hamburger span:nth-child(1) {
        top: 9px;
        transform: rotate(135deg);
    }
    .bf-mobile-toggle.active .bf-hamburger span:nth-child(2) {
        opacity: 0;
        left: -40px;
    }
    .bf-mobile-toggle.active .bf-hamburger span:nth-child(3) {
        top: 9px;
        transform: rotate(-135deg);
    }

    .bf-mobile-text {
        font-weight: 600;
        font-size: 16px;
        color: #1e293b;
    }

    .brandflow-mega-menu {
        display: none; /* toggled via JS */
        max-height: 70vh;
        overflow-y: auto;
    }

    .bf-menu-level-1 {
        display: flex;
        flex-direction: column;
    }

    .bf-menu-item {
        border-bottom: 1px solid #f1f5f9;
    }

    .bf-menu-item-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0;
    }

    .bf-menu-item-header > a {
        flex: 1;
        padding: 18px 20px;
        font-size: 16px;
        font-weight: 600;
        color: #1e293b;
    }

    .bf-toggle-btn {
        padding: 18px 24px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border-left: 1px solid #f1f5f9;
        transition: background 0.2s ease;
    }
    
    .bf-toggle-btn:hover {
        background: #f8fafc;
    }

    .bf-dropdown-icon {
        width: 18px;
        height: 18px;
        color: #64748b;
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .bf-menu-item.open > .bf-menu-item-header .bf-dropdown-icon {
        transform: rotate(180deg);
        color: #d32f2f;
    }

    .bf-mega-dropdown {
        display: none;
        background: #f8fafc;
        padding: 0 20px 20px 20px;
    }

    .bf-column-title {
        font-size: 15px;
        font-weight: 700;
        margin: 16px 0 10px 0;
        color: #0f172a;
    }

    .bf-menu-level-3 {
        padding-left: 12px;
        border-left: 2px solid #e2e8f0;
    }

    .bf-menu-level-3 li {
        margin-bottom: 8px;
    }

    .bf-menu-level-3 a {
        font-size: 14px;
        color: #64748b;
    }
}

/* =========================================================
   ACCORDION MODE (For sidebars and Bricks Mobile Navs)
   [brandflow_mega_menu layout="accordion"]
   ========================================================= */
.bf-accordion-mode .bf-mobile-toggle {
    display: none !important;
}

.bf-accordion-mode.brandflow-mega-menu-container,
.bf-accordion-mode .brandflow-mega-menu {
    display: block !important;
    position: static !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-height: none !important;
    backdrop-filter: none !important;
    width: 100% !important;
}

.bf-accordion-mode .bf-menu-level-1 {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    row-gap: 0 !important;
}

.bf-accordion-mode .bf-menu-item {
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
    width: 100% !important;
}

.bf-accordion-mode .bf-menu-item-header {
    padding: 0 !important;
    display: flex !important;
    justify-content: space-between !important;
}

.bf-accordion-mode .bf-menu-item-header > a {
    padding: 16px 0 !important;
    width: 100% !important;
    font-size: 15px !important;
}

.bf-accordion-mode .bf-toggle-btn {
    padding: 16px 10px !important;
    border: none !important;
}

.bf-accordion-mode .bf-mega-dropdown {
    position: static !important;
    display: none; /* JS will toggle this */
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 10px 0 20px 15px !important;
    background: transparent !important;
    margin-top: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

.bf-accordion-mode .bf-mega-dropdown-inner {
    display: block !important; /* Stack columns vertically */
}

.bf-accordion-mode .bf-mega-column {
    margin-bottom: 20px !important;
}
