/* Mega Menu styles - Refactored for 5-Column Layout */

/* Top Bar */
/* Top Bar removed in current layout (kept for reference) */
.proeletronic-top-bar { display: none; }

.sathd-button {
    background-color: #e9ecef; /* Gray button */
    color: #495057;
    text-decoration: none;
    padding: 2px 10px; /* match 2px height */
    border-radius: 14px; /* Pill shape */
    font-size: 13px; /* compact */
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 180ms ease;
}

.sathd-button:hover {
    background-color: #dee2e6; /* Darker gray on hover */
}

/* General */
.proeletronic-mega-menu-wrapper {
    font-family: Arial, Helvetica, "sans-serif";
    position: sticky; /* stick to viewport top */
    /*top: 0;*/
    z-index: 1000;
    width: 100%;
    max-width: 1140px; /* Match theme container width */
    margin: 0 auto; /* Center within page */
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 220px 1fr; /* logo | content */
    grid-template-rows: auto auto; /* topbar + navbar */
    grid-template-areas:
        "logo topbar"
        "logo navbar";
    align-items: center; /* helps vertical centering */
    column-gap: 16px;
    background-color: #fff; /* ensure full header background is white */
    overflow-x: hidden; /* prevent any horizontal overflow beyond shortcode */
}

/* Account for WP Admin Bar when logged in */
body.admin-bar .proeletronic-mega-menu-wrapper { top: 32px; }
@media (max-width: 782px) {
  body.admin-bar .proeletronic-mega-menu-wrapper { top: 46px; }
}

/* Topbar above navbar */
.proeletronic-mega-menu-topbar {
    grid-area: topbar;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* align actions to right */
    padding: 0; /* remove inner padding to align to container edges */
    min-width: 0; /* allow shrinking inside grid */
}

.proeletronic-mega-menu-topbar-actions { display: flex; gap: 10px; }

/* Navbar */
.proeletronic-mega-menu-navbar {
    grid-area: navbar;
    min-height: 44px; /* reduced height */
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* align menu items to the right */
    flex-wrap: nowrap;
    padding: 0; /* remove inner padding to align to container edges */
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0; /* allow shrinking inside grid */
}

/* Logo spans both rows and is centered vertically */
.proeletronic-mega-menu-logo { grid-area: logo; display:flex; align-items:center; justify-content:flex-start; align-self: stretch; line-height: 0; background-color: #fff; padding-left: 0; }
.proeletronic-mega-menu-logo img { height: 32px; width:auto; display:block; }

.proeletronic-mega-menu-top-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center; /* Vertically align items with button */
    gap: 5px; /* Use gap for precise spacing */
    margin-left: auto; /* Push menu items to the right */
    margin-right: 0;
    white-space: nowrap; /* Prevent items from wrapping to the next line */
    min-width: 0; /* allow shrinking within navbar */
}

.proeletronic-mega-menu-actions { white-space: nowrap; }

.proeletronic-mega-menu-top-item a {
    text-decoration: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    padding: 2px 10px; /* More compact height */
    /* margin: 0 10px; */ /* Replaced by gap property on parent */
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 99px; /* rounded pill */
    transition: background-color 180ms ease, color 180ms ease;
    white-space: nowrap; /* Keep each label on a single line */
}

.proeletronic-mega-menu-top-item a:hover {
    background-color: #f2f2f2;
    color: #333;
}

.proeletronic-mega-menu-top-item.is-active a {
    color: #f57c00;
    background-color: #f2f2f2;
}

/* Remove the underline style */
.proeletronic-mega-menu-top-item.is-active a::after {
    display: none;
}

.proeletronic-mega-menu-chevron {
    margin-left: 8px;
    font-size: 10px;
}

/* Last Item Button Style */
/* Reset any special style on last menu item */
.proeletronic-mega-menu-top-item:last-child a {
    background: transparent;
    color: #333;
    font-weight: 500;
    padding: 2px 10px; /* Match reduced height */
    border-radius: 99px; /* match pill radius */
}

.proeletronic-mega-menu-top-item:last-child a:hover {
    background-color: #f2f2f2;
    color: #333;
}

/* Actions group on right */
.proeletronic-mega-menu-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
}

/* Search (fixed on navbar) */
.proeletronic-mega-menu-search {
    margin-left: 0;
    display: flex;
    align-items: center;
    background: #f0f2f1;
    border-radius: 20px;
    padding: 6px 12px;
}

.proeletronic-mega-menu-search input[type="search"] {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    width: 220px;
    height: 20px;
}

.proeletronic-mega-menu-search button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 2px 2px 8px;
}

/* Loja button */
.proeletronic-store-button {
    background-color: #f57c00;
    color: #fff;
    text-decoration: none;
    padding: 2px 14px; /* match 2px height */
    border-radius: 16px;
    font-weight: 700;
    font-size: 14px;
}

.proeletronic-store-button:hover {
    background-color: #e67000;
    color: #fff;
}

/* Mega Menu Panel */
.proeletronic-mega-menu-panel {
    display: none; /* Hidden by default */
    position: fixed; /* overlay over site, width/left set via JS to follow menu */
    background-color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
    overflow: hidden; /* ensure inner padding/content does not spill out */
    opacity: 0;
    transition: opacity 200ms ease, transform 200ms ease;
    z-index: 99999;
    padding-top: 10px; /* small breathing space at top */
}

.proeletronic-mega-menu-panel.is-open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Always-open mode (for debugging/preview):
   shows one panel (the one with .is-open) statically, not overlay */
/* (always-open debug mode removed) */

.proeletronic-mega-menu-panel-inner {
    display: flex;
    padding: 0; /* remove inner padding to avoid overflow */
    gap: 24px; /* balanced space between content and image */
    width: 100%; /* fill the panel width, which matches menu */
    box-sizing: border-box; /* include padding in width to avoid overflow */
    position: relative; /* anchor close button */
    max-width: 100%;
    overflow-x: hidden; /* prevent inner from overflowing container */
    flex-wrap: nowrap; /* keep single row by default */
}

/* Close button on open panel */
.proeletronic-mega-menu-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    background: #f0f2f1;
    color: #333;
    font-size: 22px;
    line-height: 24px;
    border-radius: 50%;
    cursor: pointer;
}

/* 4-Column Content Area */
.proeletronic-mega-menu-content-area {
    flex: 3;
    display: flex;
    gap: 20px;
    min-width: 0; /* allow flex children to shrink */
}

.proeletronic-mega-menu-col {
    flex: 1 1 0; /* share space equally and allow shrink */
    min-width: 0; /* avoid forcing overflow */
}

.proeletronic-mega-menu-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Parent Category Lists (Cols 1 & 3) */
.proeletronic-mega-menu-parent-list li a {
    text-decoration: none;
    color: #333;
    font-size: 14px;
    font-weight: normal;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 10px; /* compact vertical spacing */
    line-height: 1.2; /* tighter line height */
    border-radius: 4px;
    transition: background-color 180ms ease, color 180ms ease;
    white-space: normal; /* allow wrapping */
    word-break: break-word; /* break long words */
}

.proeletronic-mega-menu-parent-list li { margin: 0; }
.proeletronic-mega-menu-parent-list li + li { margin-top: 2px; }
/* Force compact bottom padding to override theme defaults */
.proeletronic-mega-menu-parent-list > li { padding-bottom: 5px !important; }

.proeletronic-mega-menu-parent-list li.is-active a {
    background-color: #f2f2f2;
    color: #333;
    font-weight: bold;
}

.proeletronic-mega-menu-chevron-right {
    font-size: 10px;
}

/* Child Item Lists (Cols 2 & 4) */
.proeletronic-mega-menu-child-items {
    display: none;
    background-color: #f2f2f2;
    padding: 8px 10px;
    border-radius: 4px;
}

.proeletronic-mega-menu-child-items ul li a {
    text-decoration: none;
    color: #333;
    font-size: 14px;
    display: block;
    padding: 2px 8px; /* compact vertical spacing */
    line-height: 1.2; /* tighter line height */
    border-radius: 4px;
    white-space: normal; /* allow wrapping */
    word-break: break-word; /* break long words */
}

.proeletronic-mega-menu-child-items ul li a:hover {
    background-color: #e0e0e0;
}

/* Image Area (Col 5) */
.proeletronic-mega-menu-thumb-area {
    flex: 0 1 clamp(140px, 22%, 220px); /* responsive basis with limits */
    max-width: clamp(140px, 22%, 220px);
    margin-left: 0; /* spacing handled by panel-inner gap */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    height: 140px; /* smaller fixed height on desktop */
    padding: 8px; /* inner spacing so image is not glued to edges */
    min-width: 0;
}

.proeletronic-mega-menu-thumb-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Small helpers for better alignment on wide screens */
@media (min-width: 1200px) {
}

/* Responsivo: reduzir preenchimentos e entradas para caber em containers menores */
@media (max-width: 1199px) {
    .proeletronic-mega-menu-navbar { padding: 0; }
    .proeletronic-mega-menu-topbar { padding: 0; }
}

@media (max-width: 992px) {
    .proeletronic-mega-menu-panel-inner { padding: 0; gap: 16px; }
    .proeletronic-mega-menu-navbar { padding: 0; }
    .proeletronic-mega-menu-topbar { padding: 0; }
    .proeletronic-mega-menu-logo { padding-left: 0; }
    .proeletronic-mega-menu-top-item a { padding: 2px 8px; }
}

/* Tablet stacking: if space is tight, stack image below content */
@media (max-width: 1024px) and (min-width: 769px) {
    .proeletronic-mega-menu-panel-inner { flex-wrap: wrap; }
    .proeletronic-mega-menu-content-area { flex: 1 1 100%; }
    .proeletronic-mega-menu-thumb-area {
        flex: 1 1 100%;
        max-width: 100%;
        height: 140px;
        margin-top: 8px;
    }
}

/* Toggle (desktop hidden) */
.proeletronic-mega-menu-toggle {
    display: none;
    margin-right: auto;
    background: #f0f2f1;
    border: none;
    padding: 8px 10px;
    border-radius: 8px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.proeletronic-mega-menu-topbar .proeletronic-mega-menu-toggle { display: none; }
.proeletronic-mega-menu-toggle svg { display:block; width: 22px; height: 22px; fill: #333; }
.proeletronic-mega-menu-toggle:hover svg { fill: #000; }
.proeletronic-mega-menu-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #333;
}
.proeletronic-mega-menu-toggle-label {
    font-size: 14px;
    color: #333;
}

/* Mobile layout */
@media (max-width: 768px) {
    .proeletronic-mega-menu-wrapper {
        grid-template-columns: auto 1fr; /* logo | actions */
        grid-template-rows: auto auto; /* header + navbar */
        grid-template-areas:
            "logo topbar"
            "navbar navbar";
        row-gap: 6px;
        column-gap: 6px;
        max-width: 100%;
        padding: 0; /* remove extra padding to avoid layout break when open */
    }
    .proeletronic-mega-menu-logo { padding-left: 0; }
    .proeletronic-mega-menu-logo img { height: 26px; }
    .proeletronic-mega-menu-topbar { display:flex; align-items:center; justify-content: flex-end; padding: 0; min-width: 0; }
    .proeletronic-mega-menu-topbar-actions { display:flex; align-items:center; gap: 6px; min-width: 0; }
    .proeletronic-mega-menu-topbar-actions a { display:inline-flex; align-items:center; justify-content:center; }

    .proeletronic-mega-menu-navbar {
        border-top: 1px solid #eee;
        border-bottom: 1px solid #eee;
        padding: 0; /* align flush within wrapper */
        display: block;
        min-height: 0;
    }
    /* Show toggle next to actions; hide the navbar toggle */
    .proeletronic-mega-menu-topbar .proeletronic-mega-menu-toggle { display: inline-flex; padding: 4px; margin: 0; }
    .proeletronic-mega-menu-navbar .proeletronic-mega-menu-toggle { display: none; }
    .proeletronic-mega-menu-toggle .proeletronic-mega-menu-toggle-label { display: none; }
    .proeletronic-mega-menu-toggle svg { width: 20px; height: 20px; }

    .proeletronic-mega-menu-top-items {
        display: none;
        flex-direction: column;
        gap: 0;
        margin: 8px 0 0 0;
    }
    .proeletronic-mega-menu-wrapper.is-menu-open .proeletronic-mega-menu-top-items {
        display: flex;
    }

    .proeletronic-mega-menu-top-item a {
        padding: 10px 12px;
        border-radius: 6px;
        justify-content: space-between;
    }

    /* Panels become accordion */
    .proeletronic-mega-menu-panel {
        position: static;
        display: none;
        opacity: 1;
        transform: none;
        box-shadow: none;
        margin: 6px 0 10px 0;
        border: 1px solid #eee;
        border-radius: 6px;
        padding-top: 0; /* no extra top padding in accordion mode */
        grid-column: 1 / -1; /* span both grid columns so it doesn't follow logo width */
        width: 100%;
    }
    .proeletronic-mega-menu-panel.is-open { display: block; }

    .proeletronic-mega-menu-panel-inner {
        padding: 0;
        gap: 12px;
        flex-direction: column;
    }
    .proeletronic-mega-menu-content-area {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .proeletronic-mega-menu-col { flex: none; width: 100%; min-width: 0; }
    .proeletronic-mega-menu-child-items,
    .proeletronic-mega-menu-child-items ul { width: 100%; }

    .proeletronic-mega-menu-thumb-area { display: none !important; }

    /* Compact header actions as icons only */
    .sathd-button,
    .proeletronic-store-button { padding: 4px; border-radius: 6px; }
    .sathd-button { font-size: 0; }
    .sathd-button::before { content: "\1F4E1"; /* 📡 */ font-size: 18px; line-height: 1; }
    .proeletronic-store-button { font-size: 0; }
    .proeletronic-store-button span { font-size: 18px; line-height: 1; }
}

/* (Removed fixed spacing below header on desktop) */
