/* =========================================================
   IBRICO - HEADER RESPONSIVE DEFINITIVO
   File: /header-ibrico/header-ibrico.css
   Versione: 2.0
   ========================================================= */

:root {
    --ih-blue: #072f5f;
    --ih-blue-dark: #05264d;
    --ih-red: #e30613;
    --ih-red-dark: #c8000b;
    --ih-yellow: #ffcc00;
    --ih-white: #ffffff;
    --ih-text: #1f2937;
    --ih-muted: #6b7280;
    --ih-border: #e5e7eb;
    --ih-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

/* =========================================================
   RESET HEADER
   ========================================================= */

.ibrico-header-top-final,
.ibrico-header-top-final * {
    box-sizing: border-box;
}

.ibrico-header-top-final {
    position: sticky;
    top: 0;
    z-index: 99990;
    width: 100%;
    margin: 0;
    padding: 0;
    background: var(--ih-white);
    font-family: Arial, Helvetica, sans-serif;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

body.admin-bar .ibrico-header-top-final {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .ibrico-header-top-final {
        top: 46px;
    }
}

html {
    scroll-padding-top: 150px;
}

.ibrico-header-top-final a {
    text-decoration: none;
}

.ibrico-header-top-final button,
.ibrico-header-top-final input {
    font-family: inherit;
}

.ibrico-header-top-final button:focus-visible,
.ibrico-header-top-final a:focus-visible,
.ibrico-header-top-final input:focus-visible {
    outline: 3px solid var(--ih-yellow);
    outline-offset: 3px;
}

/* =========================================================
   TOPBAR BLU
   ========================================================= */

.ih-topbar {
    width: 100%;
    background: var(--ih-blue);
    color: var(--ih-white);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.ih-topbar-inner {
    display: flex;
    width: 100%;
    max-width: 1480px;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 auto;
    padding: 7px 24px;
}

.ih-info-links {
    display: flex;
    min-width: 0;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ih-info-links a {
    display: inline-flex;
    align-items: center;
    color: var(--ih-white) !important;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.ih-info-links a:hover {
    color: var(--ih-yellow) !important;
}

.ih-top-sep {
    color: rgba(255, 255, 255, 0.38);
    font-size: 12px;
    font-weight: 900;
}

/* =========================================================
   SOCIAL TOP
   ========================================================= */

.ih-social-top {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.ih-social-top a {
    display: inline-flex;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    color: var(--ih-white) !important;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.ih-social-top a:hover {
    border-color: var(--ih-yellow);
    background: var(--ih-yellow);
    color: var(--ih-blue) !important;
    transform: translateY(-2px);
}

.ih-social-top svg {
    display: block;
    width: 17px;
    height: 17px;
    fill: currentColor;
}

/* =========================================================
   HEADER PRINCIPALE ROSSO
   ========================================================= */

.ih-main {
    position: relative;
    width: 100%;
    background: var(--ih-red);
    color: var(--ih-white);
    box-shadow: var(--ih-shadow);
}

.ih-main-inner {
    position: relative;
    display: grid;
    width: 100%;
    max-width: 1480px;
    grid-template-columns: 180px minmax(360px, 1fr) auto;
    gap: 22px;
    align-items: center;
    margin: 0 auto;
    padding: 13px 24px;
}

/* =========================================================
   LOGO
   ========================================================= */

.ih-logo {
    display: inline-flex;
    width: fit-content;
    align-items: center;
}

.ih-logo img {
    display: block;
    width: 162px;
    max-width: 100%;
    height: auto;
    max-height: 72px;
    padding: 7px;
    border-radius: 14px;
    background: var(--ih-white);
    object-fit: contain;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.13);
}

/* =========================================================
   CENTRO
   ========================================================= */

.ih-center {
    display: grid;
    min-width: 0;
    grid-template-columns: minmax(280px, 1fr) auto;
    gap: 14px;
    align-items: center;
}

/* =========================================================
   RICERCA
   ========================================================= */

.ih-search {
    width: 100%;
    min-width: 0;
}

.ih-search form {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: var(--ih-white);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.ih-search input[type="search"] {
    flex: 1;
    width: 100%;
    min-width: 0;
    height: 46px;
    margin: 0;
    padding: 0 18px;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: var(--ih-white);
    color: var(--ih-blue);
    font-size: 15px;
    font-weight: 800;
    box-shadow: none;
    -webkit-appearance: none;
}

.ih-search input[type="search"]::placeholder {
    color: #777777;
    font-weight: 700;
    opacity: 1;
}

.ih-search button {
    display: inline-flex;
    width: 58px;
    height: 46px;
    flex: 0 0 58px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--ih-yellow);
    color: var(--ih-blue);
    font-size: 24px;
    line-height: 1;
    font-weight: 900;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ih-search button:hover {
    background: #ffd633;
}

/* =========================================================
   REPARTI DESKTOP
   ========================================================= */

.ih-reparti-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ih-reparti-btn {
    display: inline-flex;
    height: 46px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 0 21px;
    border: 0;
    border-radius: 999px;
    background: var(--ih-yellow);
    color: var(--ih-blue) !important;
    font-size: 14px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.ih-reparti-btn:hover {
    background: #ffd633;
    transform: translateY(-2px);
}

.ih-reparti-arrow {
    display: inline-block;
    font-size: 12px;
    transition: transform 0.2s ease;
}

.ih-reparti-wrap.is-open .ih-reparti-arrow {
    transform: rotate(180deg);
}

/* =========================================================
   MEGA MENU
   ========================================================= */

.ih-mega {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 99999;
    width: min(800px, calc(100vw - 40px));
    padding: 22px;
    border: 1px solid var(--ih-border);
    border-radius: 22px;
    background: var(--ih-white);
    color: var(--ih-blue);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    transition:
        opacity 0.2s ease,
        visibility 0.2s ease,
        transform 0.2s ease;
}

.ih-reparti-wrap:hover .ih-mega,
.ih-reparti-wrap:focus-within .ih-mega,
.ih-reparti-wrap.is-open .ih-mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.ih-mega-title {
    margin: 0 0 16px;
    color: var(--ih-blue);
    font-size: 22px;
    line-height: 1.15;
    font-weight: 900;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.ih-mega-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.ih-mega-card {
    display: block;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--ih-border);
    border-radius: 16px;
    background: #f7f7f7;
    color: var(--ih-blue) !important;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.ih-mega-card:hover {
    border-color: var(--ih-yellow);
    background: #fff8d8;
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(7, 47, 95, 0.09);
}

.ih-mega-card strong {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 7px;
    color: var(--ih-blue);
    font-size: 15px;
    line-height: 1.2;
    font-weight: 900;
    text-transform: uppercase;
}

.ih-mega-card > span {
    display: block;
    color: #444444;
    font-size: 13px;
    line-height: 1.4;
    font-weight: 700;
}

/* =========================================================
   AZIONI DESTRA
   ========================================================= */

.ih-actions {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* =========================================================
   LOGIN / ACCOUNT
   ========================================================= */

.ih-login {
    display: inline-flex;
    height: 46px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    border-radius: 999px;
    background: var(--ih-white);
    color: var(--ih-blue) !important;
    font-size: 14px;
    line-height: 1;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.ih-login:hover {
    background: var(--ih-yellow);
    color: var(--ih-blue) !important;
    transform: translateY(-2px);
}

.ih-login-icon {
    font-size: 18px;
    line-height: 1;
}

.ih-login-text {
    display: inline-block;
}

/* =========================================================
   CARRELLO
   ========================================================= */

.ih-cart {
    position: relative;
    display: inline-flex;
    width: 46px;
    height: 46px;
    min-width: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ih-yellow);
    color: var(--ih-blue) !important;
    font-size: 21px;
    line-height: 1;
    font-weight: 900;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.ih-cart:hover {
    background: #ffd633;
    transform: translateY(-2px);
}

.ih-cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    min-width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--ih-white);
    border-radius: 999px;
    background: var(--ih-blue);
    color: var(--ih-white);
    font-size: 12px;
    line-height: 1;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.ih-cart-count.is-empty {
    display: none;
}

/* =========================================================
   TOGGLE MOBILE
   ========================================================= */

.ih-mobile-toggle {
    display: none;
    width: 46px;
    height: 46px;
    min-width: 46px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ih-yellow);
    color: var(--ih-blue);
    font-size: 24px;
    line-height: 1;
    font-weight: 900;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

.ih-mobile-toggle:hover {
    background: #ffd633;
}

.ih-mobile-toggle.is-open {
    transform: rotate(90deg);
}

/* =========================================================
   MENU MOBILE
   ========================================================= */

.ih-mobile-menu {
    display: none;
}

.ih-mobile-menu a {
    color: var(--ih-blue) !important;
}

/* =========================================================
   DESKTOP MEDIO
   ========================================================= */

@media (max-width: 1280px) {

    .ih-main-inner {
        grid-template-columns: 158px minmax(320px, 1fr) auto;
        gap: 16px;
    }

    .ih-logo img {
        width: 145px;
    }

    .ih-reparti-btn {
        padding-left: 17px;
        padding-right: 17px;
        font-size: 13px;
    }

    .ih-login {
        padding-left: 14px;
        padding-right: 14px;
        font-size: 13px;
    }

    .ih-mega {
        width: min(720px, calc(100vw - 40px));
    }
}

/* =========================================================
   TABLET ORIZZONTALE
   ========================================================= */

@media (max-width: 1024px) {

    .ih-topbar-inner,
    .ih-main-inner {
        padding-left: 18px;
        padding-right: 18px;
    }

    .ih-info-links a {
        font-size: 11px;
    }

    .ih-social-top a {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .ih-center {
        gap: 10px;
    }

    .ih-reparti-btn,
    .ih-login {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* =========================================================
   TABLET E SMARTPHONE
   ========================================================= */

@media (max-width: 920px) {

    html {
        scroll-padding-top: 190px;
    }

    .ih-topbar-inner {
        min-height: auto;
        flex-direction: column;
        gap: 7px;
        padding: 10px 18px;
        text-align: center;
    }

    .ih-info-links {
        justify-content: center;
        gap: 6px;
    }

    .ih-info-links a {
        font-size: 11px;
        line-height: 1.25;
    }

    .ih-main-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        padding: 14px 18px 16px;
    }

    .ih-logo {
        grid-column: 1;
        grid-row: 1;
    }

    .ih-logo img {
        width: 150px;
        max-height: 68px;
        padding: 6px;
        border-radius: 13px;
    }

    .ih-actions {
        grid-column: 2;
        grid-row: 1;
        gap: 8px;
    }

    .ih-center {
        display: block;
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-width: 0;
    }

    .ih-search input[type="search"] {
        height: 48px;
        padding: 0 18px;
        font-size: 14px;
    }

    .ih-search button {
        width: 58px;
        height: 48px;
        flex-basis: 58px;
        font-size: 22px;
    }

    .ih-reparti-wrap {
        display: none;
    }

    .ih-mobile-toggle {
        display: inline-flex;
    }

    .ih-login,
    .ih-cart,
    .ih-mobile-toggle {
        width: 46px;
        height: 46px;
        min-width: 46px;
    }

    .ih-login {
        padding: 0;
    }

    .ih-login-text {
        display: none;
    }

    .ih-login-icon {
        font-size: 20px;
    }

    .ih-cart {
        font-size: 20px;
    }

    .ih-mobile-toggle {
        font-size: 22px;
    }

    .ih-cart-count {
        top: -6px;
        right: -5px;
        min-width: 20px;
        height: 20px;
        padding: 0 5px;
        font-size: 11px;
    }

    .ih-mobile-menu {
        grid-column: 1 / -1;
        grid-row: 3;
        width: 100%;
        margin-top: 0;
        overflow: hidden;
        border-radius: 14px;
        background: var(--ih-white);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
    }

    .ih-mobile-menu.is-open {
        display: block;
    }

    .ih-mobile-menu a {
        display: flex;
        min-height: 48px;
        align-items: center;
        gap: 10px;
        padding: 13px 16px;
        border-bottom: 1px solid var(--ih-border);
        color: var(--ih-blue) !important;
        font-size: 14px;
        line-height: 1.25;
        font-weight: 900;
        transition:
            background 0.2s ease,
            color 0.2s ease,
            padding-left 0.2s ease;
    }

    .ih-mobile-menu a:last-child {
        border-bottom: 0;
    }

    .ih-mobile-menu a:hover {
        padding-left: 20px;
        background: #fff8d8;
        color: var(--ih-red) !important;
    }
}

/* =========================================================
   SMARTPHONE
   ========================================================= */

@media (max-width: 560px) {

    .ih-topbar-inner {
        padding: 10px 14px;
    }

    .ih-info-links {
        gap: 5px;
    }

    .ih-top-sep {
        display: none;
    }

    .ih-info-links a {
        width: 100%;
        justify-content: center;
        font-size: 11px;
    }

    .ih-social-top {
        gap: 8px;
    }

    .ih-social-top a {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .ih-main-inner {
        gap: 10px;
        padding: 14px 16px 16px;
    }

    .ih-logo img {
        width: 142px;
        max-height: 64px;
        padding: 6px;
        border-radius: 12px;
    }

    .ih-actions {
        gap: 7px;
    }

    .ih-login,
    .ih-cart,
    .ih-mobile-toggle {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .ih-search input[type="search"] {
        height: 46px;
        padding-left: 16px;
        font-size: 13px;
    }

    .ih-search button {
        width: 56px;
        height: 46px;
        flex-basis: 56px;
        font-size: 21px;
    }

    .ih-mobile-menu {
        border-radius: 12px;
    }

    .ih-mobile-menu a {
        min-height: 46px;
        padding: 12px 14px;
        font-size: 13px;
    }
}

/* =========================================================
   SMARTPHONE COMPATTI
   Adattamento fluido per tutti i dispositivi stretti
   ========================================================= */

@media (max-width: 420px) {

    .ih-topbar-inner {
        padding-left: 12px;
        padding-right: 12px;
    }

    .ih-main-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: clamp(6px, 2vw, 9px);
        padding-left: 12px;
        padding-right: 12px;
    }

    .ih-logo img {
        width: clamp(112px, 33vw, 132px);
        max-height: 60px;
    }

    .ih-actions {
        gap: clamp(4px, 1.6vw, 7px);
    }

    .ih-login,
    .ih-cart,
    .ih-mobile-toggle {
        width: clamp(38px, 11vw, 42px);
        height: clamp(38px, 11vw, 42px);
        min-width: clamp(38px, 11vw, 42px);
    }

    .ih-login-icon,
    .ih-cart {
        font-size: 18px;
    }

    .ih-mobile-toggle {
        font-size: 20px;
    }

    .ih-cart-count {
        top: -6px;
        right: -4px;
        min-width: 19px;
        height: 19px;
        font-size: 10px;
    }

    .ih-search input[type="search"] {
        height: 44px;
        padding-left: 14px;
        font-size: clamp(11px, 3.4vw, 13px);
    }

    .ih-search button {
        width: 54px;
        height: 44px;
        flex-basis: 54px;
        font-size: 20px;
    }

    .ih-mobile-menu a {
        font-size: 12px;
    }
}

/* =========================================================
   ACCESSIBILITÀ
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .ih-social-top a,
    .ih-login,
    .ih-cart,
    .ih-mobile-toggle,
    .ih-reparti-btn,
    .ih-reparti-arrow,
    .ih-mega,
    .ih-mega-card,
    .ih-mobile-menu a {
        transition: none;
    }

    .ih-social-top a:hover,
    .ih-login:hover,
    .ih-cart:hover,
    .ih-reparti-btn:hover,
    .ih-mega-card:hover {
        transform: none;
    }
}
