/* ==========================================================================
   1. STOREFRONT OVERFLOW FORCE RESET (Fixes the hover block)
   ========================================================================== */
.main-navigation,
.menu-custom-navigation-menu-container,
.main-navigation ul, 
.menu-custom-navigation-menu-container ul,
.main-navigation li, 
.menu-custom-navigation-menu-container li,
.main-navigation a,
.menu-custom-navigation-menu-container a {
    position: static !important;
    overflow: visible !important; /* Critical: Stops Storefront from chopping the box off */
}

/* Make sure the container that holds the entire nav bar is relative for absolute positioning */
.main-navigation > div > ul,
.menu-custom-navigation-menu-container > ul {
    position: relative !important; 
}

/* Hide Storefront's default sub-menus so they don't overlap our grid */
.main-navigation ul ul,
.menu-custom-navigation-menu-container ul ul:not(.mega-column-links) {
    /* display: none !important; */
}

/* ==========================================================================
   2. CORE MEGA DROPDOWN BOX
   ========================================================================== */
.alliance-mega-menu-container {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important; 
    
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.12) !important;
    border-radius: 0 0 6px 6px !important;
    z-index: 999999 !important;
    box-sizing: border-box !important;
    
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease-in-out !important;
}

/* ==========================================================================
   UPDATED SECTION 3: HOVER TRIGGERS (Fixes layout constraints)
   ========================================================================== */

/* Show the main container on hover */
.main-navigation li:hover .alliance-mega-menu-container,
.menu-custom-navigation-menu-container li:hover .alliance-mega-menu-container {
    display: block !important; /* Critical: Overrides 'display: none' */
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Activate the flex grid for categories */
.main-navigation li:hover .categories-full-width-grid,
.menu-custom-navigation-menu-container li:hover .categories-full-width-grid {
    display: flex !important; /* Critical: Activates your Section 4 flex rules */
}

/* Activate the grid/block layout for brands & bandsaw */
.main-navigation li:hover .brands-mega,
.menu-custom-navigation-menu-container li:hover .brands-mega,
.main-navigation li:hover .bandsaw-mega,
.menu-custom-navigation-menu-container li:hover .bandsaw-mega {
    display: block !important;
}

/* ==========================================================================
   4. CATEGORIES SINGLE ROW FORMATTING
   ========================================================================== */
.categories-full-width-grid {
    display: flex !important;           /* Forces all columns into one row */
    flex-direction: row !important;
    flex-wrap: nowrap !important;       /* Prevents wrapping to new lines */
    justify-content: space-between !important; /* Spreads them evenly across the width */
    padding: 30px 20px !important;
    width: 100% !important;
    max-width: 1200px !important;       /* Adjust based on your site's content container */
    margin: 0 auto !important;
}

.mega-grid-column {
    flex: 1 !important;                 /* Each column gets equal width */
    min-width: 150px !important;        /* Prevents columns from becoming too small */
    margin: 0 10px !important;          /* Adds breathing room between columns */
    display: flex !important;
    flex-direction: column !important;
}

/* Force Uniform Image Sizes */
.mega-column-image-link {
    display: block !important;
    width: 100% !important;
    height: 120px !important;           /* Set a fixed height for all images */
    /* margin-bottom: 15px !important; */
    overflow: hidden !important;
}

.mega-column-image-link img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;     /* Ensures full image is visible without distortion */
    border-radius: 4px !important;
}

/* Title and Links */
.mega-column-title {
    font-weight:bold;
    margin-bottom: 10px !important;
    text-align: center !important;      /* Centers title under image */
}
.mega-column-title a{
    font-size: 1.1rem !important;
}
.mega-column-title-link {
    display: block !important;
    width: 100% !important;
    margin-bottom: 15px !important;
    overflow: hidden !important;
}

.show-all-link{
    border-top:2px solid grey;
}

/* ==========================================================================
   5. BRANDS & BANDSAW
   ========================================================================== */
.brands-mega, .bandsaw-mega { 
    padding: 30px 20px !important; /* Updated to match category padding */
}

/* --- BRANDS GRID (6 Columns) --- */
.brands-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 12px !important;
}

.brand-card-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 90px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 4px !important;
    background: #ffffff !important;
}

.brand-card-link img { 
    max-height: 85% !important; 
    max-width: 85% !important; 
    object-fit: contain !important; 
}

/* --- BANDSAW GRID (4 Columns) --- */
.bandsaw-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important; /* Forces exactly 4 equal columns */
    gap: 20px !important;
    width: 100% !important;
    max-width: 1200px !important;
    margin: 0 auto !important;
}

/* Hide any nested subcategories (lists) inside the Bandsaw dropdown */
.bandsaw-grid ul {
    display: none !important; 
}

/* ==========================================================================
   6. PRIMARY MENU SPACING & ALIGNMENT
   ========================================================================== */
.main-navigation > div > ul,
.menu-custom-navigation-menu-container > ul {
    display: flex !important;
    justify-content: center !important; /* Centers the group of links */
    align-items: center !important;
    gap: 25px !important; /* Adds breathing room between each button */
    width: 100% !important;
    padding: 0 !important;
    margin: 0 auto !important;
}

/* Strip out any default theme margins that might push things off-center */
.main-navigation > div > ul > li,
.menu-custom-navigation-menu-container > ul > li {
    margin: 0 !important;
    padding: 0 !important;
}
#menu-custom-navigation-menu > .menu-item > a {
    font-size: 24px !important;
}
.main-navigation{
    margin-top:0.5rem !important;
}

/* ==========================================================================
   PRIMARY MENU VISUAL STYLING (Fixes readability)
   ========================================================================== */

/* Top-level menu links (The white boxes: Categories, Brands, etc.) */
.main-navigation > div > ul > li > a,
.menu-custom-navigation-menu-container > ul > li > a {
    background-color: transparent !important;
    color: #333333 !important; /* Dark charcoal text for high contrast */
    font-weight: 700 !important;
    text-transform: uppercase !important;
    border-radius: 4px !important;
    padding: 2px 15px !important;
    transition: all 0.2s ease-in-out !important;
}

/* Top-level menu links - HOVER STATE */
.main-navigation > div > ul > li > a:hover,
.menu-custom-navigation-menu-container > ul > li > a:hover {
    background-color: #0073b1 !important; /* Theme blue background on hover */
    color: #ffffff !important; /* White text on hover */
}

/* ==========================================================================
   DROPDOWN & MEGA MENU VISUAL STYLING
   ========================================================================== */

/* Ensure all base text inside the dropdown is dark */
.alliance-mega-menu-container {
    color: #333333 !important; 
    max-height:80vh;
    overflow:auto;
}

/* Style the links inside the mega menu */
.alliance-mega-menu-container a {
    color: #333333 !important; /* Dark text */
    text-decoration: none !important;
    transition: color 0.2s ease !important;
}

/* Hover state for links inside the dropdown */
.alliance-mega-menu-container a:hover {
    color: #0073b1 !important; /* Theme blue text on hover */
}

/* Specifically target the category titles under the images */
.mega-column-title {
    color: #333333 !important;
    font-weight: 700 !important;
}

.mega-column-image-link:hover .mega-column-title {
    color: #0073b1 !important; /* Highlights title when hovering the image block */
}

ul.mega-column-links li a{
    white-space: nowrap;      /* 1. Prevents text from wrapping */
    overflow: hidden;         /* 2. Hides the overflow content */
    text-overflow: ellipsis;  /* 3. Adds the ... */
    display:block;
    width:100%;
}

/* =========================================
   CUSTOM MOBILE HEADER STYLES
   ========================================= */

/* 1. Hide our custom bar on Desktop */
@media screen and (min-width: 769px) {
    .alliance-custom-mobile-header {
        display: none !important;
    }
}

/* 2. Mobile Layout Settings */
@media screen and (max-width: 768px) {
    
    /* Top Bar */
    .alliance-custom-mobile-bar {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        background-color: #ffd800;
        padding: 10px 15px;
    }

    /* Nav Row */
    .alliance-mobile-nav-row {
        display: flex !important;
        background: #333 !important;
        overflow-x: auto !important;
        /* padding: 5px !important; */
    }

    .nav-btn {
        flex: 1 !important;
        padding: 10px !important;
        color: white !important;
        background: none !important;
        border: none !important;
        font-weight: bold !important;
        text-transform: uppercase !important;
        font-size: 14px !important;
    }

    /* Dropdown Areas */
    .mobile-menu-content {
        display: none;
        background: #fff !important;
        padding: 15px !important;
        border-bottom: 2px solid #ffd800 !important;
    }
    
    /* Ensure Mega Menu Grid works inside mobile */
    .mobile-menu-content .alliance-mega-menu-container {
        position: relative !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        box-shadow: none !important;
        border: none !important;
    }
    
    .mobile-menu-content .categories-full-width-grid,
    .mobile-menu-content .brands-grid,
    .mobile-menu-content .bandsaw-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* Stack in 2 columns for mobile */
        gap: 10px !important;
    }
    .mobile-menu-content ul{
        list-style:none;
        margin-left:0px;
    }

    /* Hide Storefront legacy stuff */
    .site-header { display: none !important; }
    .storefront-handheld-footer-bar{
        display:none !important;
    }
    .acmb-right a {
        padding: 0px 10px;
    }
    .brands-mega, .bandsaw-mega { 
    padding: 0px 0px !important; /* Updated to match category padding */
}
}
