/* Stile per l'header personalizzato */
.custom-header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 12px 28px;
    background: #ffffff;
    border-bottom: 1px solid #e5e5e5;
    position: sticky; /* sticky header */
    top: 0; /* default offset */
    z-index: 1200; /* sopra il contenuto, sotto pannelli più alti */
    transition: padding .25s ease, box-shadow .25s ease, background-color .25s ease;
    will-change: padding, box-shadow;
}

/* Stato compresso dopo scroll */
.custom-header.is-scrolled {
    padding: 6px 24px;
    box-shadow: 0 4px 18px -6px rgba(0,0,0,.15);
}
.custom-header.is-scrolled .logo img { max-height: 46px; }

/* Compensazione admin bar WP */
body.admin-bar .custom-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .custom-header { top: 46px; } }

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 2rem;
    min-height: 100px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    min-height: 40px;
}

.logo a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.custom-header .logo img {
    max-height: 54px;
    height: auto;
    width: auto;
    display: block;
}

/* Mostra sempre il burger */
.nav-toggle {
    background: transparent;
    border: 0;
    padding: 8px;
    cursor: pointer;
    display: inline-block;
    position: relative;
}

.nav-toggle-box {
    display: inline-flex;
    flex-direction: column;
    gap: 5px;
}

.nav-toggle-bar {
    width: 26px;
    height: 3px;
    background: #222;
    border-radius: 2px;
    transition: transform .3s, opacity .3s;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Navigation */
.main-navigation {
    margin-left: auto;
    position: relative;
}

.main-navigation .nav-menu {
    list-style: none;
    display: flex;
    gap: 2.4rem;
    margin: 0;
    padding: 0;
}

.main-navigation .nav-menu > li > a {
    text-decoration: none;
    font-weight: 600;
    color: #222;
    padding: .5rem 0;
    position: relative;
}

.main-navigation .nav-menu > li > a:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: #0073aa;
    transition: width .3s;
}

.main-navigation .nav-menu > li > a:hover:after,
.main-navigation .nav-menu > li > a:focus:after,
.main-navigation .nav-menu > li.current-menu-item > a:after {
    width: 100%;
}

.main-navigation .nav-menu > li > a:hover,
.main-navigation .nav-menu > li > a:focus {
    color: #0073aa;
}

/* Nasconde menu desktop finché non aperto */
.main-navigation:not(.is-open) {
    display: none;
}

.main-navigation.is-open {
    display: block;
}

/* Layout desktop quando aperto */
@media (min-width: 961px) {
    .nav-toggle {
        display: none;
    }

    .main-navigation {
        display: block !important;
        position: static;
    }

    .main-navigation .nav-menu {
        display: flex;
        gap: 2rem;
    }
}

/* Dropdown behaviour for mobile */
@media (max-width: 960px) {
    .nav-toggle {
        display: block;
    }

    .main-navigation {
        position: absolute;
        left: 0;
        top: 100%;
        width: 100%;
        background: #ffffff;
        border-bottom: 1px solid #e5e5e5;
        box-shadow: 0 6px 18px -4px rgba(0, 0, 0, .08);
        max-height: 0;
        overflow: hidden;
        transition: max-height .4s ease;
    }

    .main-navigation.is-open {
        max-height: 60vh;
        overflow: auto;
    }

    .main-navigation .nav-menu {
        flex-direction: column;
        gap: 0;
    }

    .main-navigation .nav-menu > li > a {
        padding: 14px 24px;
        border-bottom: 1px solid #f1f1f1;
    }

    .main-navigation .nav-menu > li:last-child > a {
        border-bottom: none;
    }
}

/* Mini cart popup ancorato al wrapper (no espansione header) */
.mini-cart-wrapper {
    position: relative;
    margin-left: 1.25rem;
}

.mini-cart-toggle {
    background: #ff6a00;
    color: #fff;
    border: 0;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
}

.mini-cart-toggle:hover {
    background: #e85e00;
}

.mini-cart-icon {
    display: flex;
}

.mini-cart-count {
    background: #fff;
    color: #ff6a00;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1;
    font-weight: 700;
}

.mini-cart-panel {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: 340px;
    max-height: 70vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 12px 32px -6px rgba(0, 0, 0, .18);
    padding: 18px 18px 22px;
    border-radius: 14px;
    z-index: 1500;
}

.mini-cart-panel[hidden] {
    display: none;
}

/* Optional overlay (se vuoi) */
body.nav-open,
body.minicart-open {
    overflow: hidden;
}

/* Miglioramento logo */
.site-logo-img {
    height: auto;
    max-height: 60px;
    width: auto;
    display: block;
    margin: 0 auto; /* Center the logo horizontally */
}

/* Spaziatura link menu */
.main-navigation .nav-menu > li > a {
    font-family: "Nunito Sans", sans-serif;
    font-weight: 600;
    padding: .5rem 0;
    position: relative;
}

.main-navigation .nav-menu > li > a:after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: #2872FA;
    transition: width .3s;
}

.main-navigation .nav-menu > li > a:hover:after,
.main-navigation .nav-menu > li > a:focus:after,
.main-navigation .nav-menu > li.current-menu-item > a:after {
    width: 100%;
}

.main-navigation .nav-menu > li > a {
    color: #222;
}

.main-navigation .nav-menu > li > a:hover,
.main-navigation .nav-menu > li > a:focus {
    color: #2872FA;
}

/* Utility */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width:961px){
  .main-navigation.always-desktop {display:block !important;}
}

/* Mobile layout migliorato con mini-cart visibile e compatto */
@media (max-width: 768px) {
  .custom-header { padding: 8px 14px; }
  .header-inner { flex-direction: row; align-items: center; gap: 0; min-height: 72px; padding:0; justify-content: flex-start; }
  .logo { flex: 1 1 auto; max-width: 33%; min-width: 0; justify-content: flex-start; margin-right: auto; }
  .logo a { width: 100%; height: 100%; }
  .custom-header .logo img { max-height: 46px; }

  /* Bottoni azioni a destra */
  .nav-toggle { order: 2; margin: 0 6px 0 0; display: flex; align-items:center; justify-content:center; width:44px; height:44px; border-radius:50%; }
  .mini-cart-wrapper { order: 3; display: block; margin-left: 4px; }

  /* Mini cart compatto circolare */
  .mini-cart-toggle { position: relative; background: #ff6a00; width: 44px; height: 44px; padding: 0; border-radius: 50%; justify-content: center; gap:0; }
  .mini-cart-toggle:hover { background:#e55d00; }
  .mini-cart-toggle .mini-cart-label { display: none; }
  .mini-cart-toggle .mini-cart-icon { line-height:0; }
  .mini-cart-count { position: absolute; top: 4px; right: 4px; padding:2px 6px; font-size:11px; }

  /* Pannello mini-cart ottimizzato su mobile */
  .mini-cart-panel { width: 92vw; right: 4%; top: calc(100% + 10px); max-height: 65vh; }

  /* Menu a discesa: piena larghezza già gestito sopra */
  .main-navigation { left:0; width:100%; }
}



