/* ============================================================
   ElectroMart Header Module (Stage 3)
   ============================================================ */

.em-site-header {
    position: relative;
    z-index: 9990;
    font-family: var(--em-font-primary, "Poppins", sans-serif);
}

body.em-header-hide-theme .site-header,
body.em-header-hide-theme #masthead,
body.em-header-hide-theme .header-main,
body.em-header-hide-theme .main-header,
body.em-header-hide-theme .theme-header {
    display: none !important;
}

/* Above Header */
.em-header-above {
    background: #222529;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 13px;
}

.em-header-above-inner {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.em-header-above-left p {
    margin: 0;
    line-height: 1.4;
}

.em-header-above-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.em-header-above-link {
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.92;
}

.em-header-above-link:hover {
    color: var(--em-primary, #0088cc);
    opacity: 1;
}

/* Middle (logo + benefits + cart) */
.em-header-middle {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
}

.em-header-middle-grid {
    display: grid;
    grid-template-columns: 3fr 6fr 3fr;
    align-items: center;
    gap: 20px;
    min-height: 92px;
}

.em-header-logo {
    display: flex;
    align-items: center;
}

.em-header-logo img {
    max-width: 100%;
    width: auto;
    max-height: 62px;
    object-fit: contain;
}

.em-site-logo-link {
    font-size: 28px;
    line-height: 1;
    font-weight: 800;
    color: var(--em-dark, #212121);
    text-decoration: none;
}

.em-header-benefits-col {
    min-width: 0;
    overflow: hidden; /* clip do track em rolagem */
}

/* ── Benefit Slider — Etapa 5 ──────────────────────── */
.em-benefit-slider {
    overflow: hidden;
    width: 100%;
    position: relative;
}

.em-benefit-track {
    display: flex;
    flex-wrap: nowrap;
    /* gap removido para impedir quebra no loop matemático no translate 50% */
    width: max-content;
    align-items: center;
    will-change: transform;
}

/* Loop contínuo, ativado por JS quando slider está pronto */
.em-benefit-track.is-scrolling {
    animation: em-benefit-scroll var(--em-scroll-duration, 18s) linear infinite;
}

/* Pausa no hover */
.em-benefit-slider:hover .em-benefit-track.is-scrolling {
    animation-play-state: paused;
}

@keyframes em-benefit-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* Animação de entrada slide-up */
@keyframes em-benefit-slide-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.em-benefit-item.em-slide-in {
    animation: em-benefit-slide-up 0.45s ease both;
}

.em-benefit-item {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    text-align: center;
}

.em-benefit-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 136, 204, 0.12);
    color: var(--em-primary, #0088cc);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.em-benefit-info p {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #212121;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 120px; /* evita estourar e quebrar em 2-3 linhas */
    display: block;
    text-align: center;
}

.em-benefit-info span {
    /* Mantido para compatibilidade caso algum cache/template ainda renderize line2 */
    display: none;
}

.em-header-cart-col {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.em-header-cart-btn {
    border: 0;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    background: var(--em-primary, #0088cc);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 25px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.em-header-cart-btn:hover {
    background: var(--em-dark, #212121);
    color: #fff;
}

.em-cart-header-count {
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    color: var(--em-primary, #0088cc);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Search Row */
.em-header-search-bar {
    background: #1f2327;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.em-header-search-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 68px;
    position: relative;
}

.em-header-categories {
    position: relative;
}

.em-category-trigger {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 24px;
    background: var(--em-primary, #0088cc);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    cursor: pointer;
}

.em-category-trigger:hover {
    background: #0a74a6;
}

.em-category-panel {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    width: min(760px, 96vw);
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 30;
}

.em-header-categories:hover .em-category-panel,
.em-header-categories.is-open .em-category-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.em-category-panel-inner {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: 350px;
}

.em-category-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-right: 1px solid #efefef;
    max-height: 500px;
    overflow: auto;
}

.em-category-item {
    border-bottom: 1px solid #f4f4f4;
}

.em-category-item.is-active,
.em-category-item:hover {
    background: #f8fafc;
}

.em-category-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #222;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
}

.em-category-link img,
.em-category-fallback-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    object-fit: cover;
    background: #f0f2f4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #6c7580;
    flex-shrink: 0;
}

.em-category-subpanel-wrap {
    position: relative;
    padding: 14px 18px;
}

.em-category-subpanel {
    display: none;
}

.em-category-subpanel.is-active {
    display: block;
}

.em-category-subpanel h4 {
    margin: 0 0 10px;
    font-size: 16px;
    color: #212121;
}

.em-category-subpanel p {
    margin: 0;
    color: #666;
    font-size: 13px;
}

.em-category-subpanel ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
}

.em-category-subpanel ul a {
    text-decoration: none;
    color: #444;
    font-size: 13px;
}

.em-category-subpanel ul a:hover {
    color: var(--em-primary, #0088cc);
}

.em-category-empty {
    padding: 18px;
    color: #666;
    font-size: 13px;
}

.em-header-search-form-wrap {
    min-width: 0;
}

.em-header-search-form {
    display: flex;
    align-items: center;
    position: relative;
}

.em-header-search-input-wrap {
    position: relative;
    flex: 1;
}

.em-header-search-input {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 24px;
    padding: 0 54px 0 16px;
    background: #ffffff;
    color: #1e2226;
    font-size: 15px;
    outline: none;
}

.em-header-search-button {
    position: absolute;
    right: 5px;
    top: 5px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #212121;        /* era --em-primary azul; agora círculo escuro (Etapa 3) */
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s ease;
}

.em-header-search-button:hover {
    background: var(--em-primary, #0088cc); /* hover revela a cor primária */
}

.em-header-search-placeholder {
    pointer-events: none;
    position: absolute;
    left: 16px;
    right: 54px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    color: #1e2226;
    overflow: hidden;
}

.em-header-search-static {
    font-size: 14px;
    color: #555;
}

.em-header-search-spin {
    margin: 0;
    padding: 0;
    list-style: none;
    position: relative;
    min-width: 120px;
    height: 18px;
    perspective: 380px;
}

.em-header-search-spin li {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--em-primary, #0088cc);
    transform-origin: center center;
    transform: rotateX(90deg) translateZ(12px);
    opacity: 0;
    transition: transform 0.48s ease, opacity 0.48s ease;
    white-space: nowrap;
}

.em-header-search-spin li.is-active {
    transform: rotateX(0deg) translateZ(0);
    opacity: 1;
}

.em-header-search-input:focus + .em-header-search-placeholder,
.em-header-search-input:not(:placeholder-shown) + .em-header-search-placeholder {
    opacity: 0;
    visibility: hidden;
}

/* Primary Menu */
.em-header-nav-wrap {
    background: #fff;
    border-bottom: 1px solid #ececec;
    position: relative;
    z-index: 20;
}

.em-header-nav-wrap.is-sticky {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.admin-bar .em-header-nav-wrap.is-sticky {
    top: 32px;
}

.em-header-nav-inner {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.em-primary-nav {
    flex: 1;
}

.em-primary-menu,
.em-mobile-primary-menu,
.em-mobile-categories-menu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.em-primary-menu {
    display: flex;
    align-items: center;
    gap: 2px;
}

.em-primary-menu > .em-menu-item {
    position: relative;
}

.em-menu-link {
    display: inline-flex;
    align-items: center;
    height: 56px;
    padding: 0 12px;
    text-decoration: none;
    color: #222529;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}

.em-primary-menu > .em-menu-item:hover > .em-menu-link,
.em-primary-menu > .em-menu-item.current-menu-item > .em-menu-link,
.em-primary-menu > .em-menu-item.current_page_item > .em-menu-link {
    color: var(--em-primary, #0088cc);
}

.em-sub-toggle {
    border: 0;
    background: transparent;
    color: #666;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.em-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
    padding: 8px 0;
    display: none;
}

.em-submenu .em-menu-item {
    position: relative;
}

.em-submenu .em-menu-link {
    height: auto;
    width: 100%;
    padding: 9px 14px;
}

.em-menu-item:hover > .em-submenu,
.em-menu-item:focus-within > .em-submenu {
    display: block;
}

.em-submenu .em-submenu {
    left: calc(100% + 2px);
    top: -8px;
}

.em-mobile-menu-toggle {
    display: none;
    border: 0;
    background: var(--em-primary, #0088cc);
    color: #fff;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    align-items: center;
    gap: 8px;
}

/* Mobile Offcanvas */
.em-mobile-offcanvas-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9991;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.em-mobile-offcanvas {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    max-width: 88vw;
    height: 100vh;
    background: #fff;
    z-index: 9992;
    display: flex;
    flex-direction: column;
    transition: left 0.24s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
}

.em-mobile-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    border-bottom: 1px solid #ededed;
}

.em-mobile-offcanvas-close {
    border: 0;
    background: #f3f3f3;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
}

.em-mobile-offcanvas-body {
    padding: 12px 14px 20px;
    overflow-y: auto;
}

.em-mobile-offcanvas-block + .em-mobile-offcanvas-block {
    margin-top: 18px;
}

.em-mobile-offcanvas-block h5 {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
}

.em-mobile-primary-menu .em-menu-item,
.em-mobile-categories-menu .em-menu-item,
.em-mobile-categories-fallback li {
    border-bottom: 1px solid #f1f1f1;
}

.em-mobile-primary-menu .em-menu-link,
.em-mobile-categories-menu .em-menu-link,
.em-mobile-categories-fallback a {
    display: block;
    height: auto;
    padding: 10px 0;
    color: #222529;
    text-decoration: none;
    font-size: 14px;
}

.em-mobile-primary-menu .em-submenu,
.em-mobile-categories-menu .em-submenu {
    position: static;
    display: none;
    box-shadow: none;
    border: 0;
    border-left: 1px dashed #d7d7d7;
    border-radius: 0;
    min-width: 0;
    padding: 0 0 0 10px;
}

.em-mobile-primary-menu .em-menu-item.is-open > .em-submenu,
.em-mobile-categories-menu .em-menu-item.is-open > .em-submenu {
    display: block;
}

.em-mobile-primary-menu .em-sub-toggle,
.em-mobile-categories-menu .em-sub-toggle {
    display: inline-flex;
    float: right;
    margin-top: -38px;
}

body.em-mobile-menu-open .em-mobile-offcanvas-overlay {
    opacity: 1;
    visibility: visible;
}

body.em-mobile-menu-open .em-mobile-offcanvas {
    left: 0;
}

body.em-mobile-menu-open {
    overflow: hidden;
}

/* ── Nav Contact (Etapa 4) ──────────────────────────────── */
.em-nav-contact {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #222529;
    white-space: nowrap;
    flex-shrink: 0;
}

.em-nav-contact-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--em-primary, #0088cc);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.em-nav-contact-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.em-nav-contact-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.em-nav-contact-number {
    font-size: 14px;
    font-weight: 700;
    color: #222529;
    transition: color 0.2s ease;
}

.em-nav-contact:hover .em-nav-contact-icon {
    background: var(--em-dark, #212121);
}

.em-nav-contact:hover .em-nav-contact-number {
    color: var(--em-primary, #0088cc);
}

/* Responsive */
@media (max-width: 1199px) {
    .em-header-middle-grid {
        grid-template-columns: 3fr 5fr 4fr;
    }
}

@media (max-width: 991px) {
    .em-site-header { 
        position: relative; 
        padding-top: 0; 
    }
    
    .em-header-middle {
        position: relative; /* Nova âncora estável para o hambúrguer */
    }

    .em-header-middle-grid {
        grid-template-columns: 50px 1fr auto;
        grid-template-areas: "spacer logo cart" "benefits benefits benefits";
        align-items: center;
        gap: 10px;
        min-height: auto;
        padding: 12px 0;
    }

    /* Movemos o toggle visualmente para a linha do logo */
    .em-mobile-menu-toggle {
        position: absolute;
        left: 15px;
        top: 50%; /* Dinamicamente no centro da barra do logo */
        transform: translateY(-50%);
        display: inline-flex;
        z-index: 1000;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
        background: transparent;
        color: var(--em-dark, #212121);
        border: 1px solid #ddd;
    }
    .em-mobile-menu-toggle span { display: none; }

    .em-header-logo-col { grid-area: logo; display: flex; justify-content: center; }
    .em-header-cart-col { grid-area: cart; display: flex; justify-content: flex-end; }
    
    /* Configuração do Carrossel (Esteira) para não empilhar */
    .em-header-benefits-col { 
        grid-area: benefits; 
        margin-top: 10px; 
        border-top: 1px solid #f0f0f0; 
        padding-top: 10px;
        overflow: hidden;
    }
    .em-benefit-track {
        display: flex !important;
        flex-wrap: nowrap !important; /* impede o empilhamento vertical */
    }
    .em-benefit-item {
        flex-shrink: 0 !important; /* impede que os itens espremam */
    }

    .em-header-cart-btn {
        min-height: 44px;
        padding: 0 14px;
        border-radius: 22px;
    }

    .em-header-search-grid {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 10px 0;
    }
    .em-header-search-input { min-height: 44px; }
    .em-header-search-button { width: 44px; height: 44px; top: 1px; right: 1px; }

    .em-header-categories {
        display: none;
    }

    .em-primary-nav {
        display: none;
    }

    .em-nav-contact {
        display: none;
    }

    .em-header-nav-inner {
        min-height: 52px;
    }
    
    /* Espaçador do grid para o hambúrguer absoluto */
    .em-header-middle-grid::before {
        content: "";
        grid-area: spacer;
        width: 44px;
    }
}

@media (max-width: 782px) {
    .admin-bar .em-header-nav-wrap.is-sticky {
        top: 46px;
    }
    /* Ajusta posição do hambúrguer se barra do admin mudar */
    .admin-bar .em-mobile-menu-toggle { top: 112px; }
}

@media (max-width: 640px) {
    .em-header-above-inner {
        min-height: 0;
        padding: 8px 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 7px;
    }

    .em-header-above-right {
        gap: 12px;
        flex-wrap: wrap;
    }

    .em-header-logo img {
        max-height: 44px;
    }

    .em-header-cart-btn {
        width: auto;
        padding: 0 12px;
    }
    .em-header-cart-btn i { font-size: 18px; }
    .em-cart-trigger { 
        overflow: hidden; 
        text-overflow: ellipsis; 
        font-size: 0 !important; /* Esconde texto em telas <640px */
    } 
    .em-cart-header-count { font-size: 13px; margin-left: 0; }
}
