/* Mega menu Petbuy - struttura e stile desktop/mobile */
:root {
    --petbuy-orange: #e9782f;
    --petbuy-orange-soft: #f7c7aa;
    --petbuy-text: #1f1f1f;
    --petbuy-muted: #606060;
    --petbuy-panel-radius: 14px;
    --petbuy-shadow: 0 18px 45px rgba(0, 0, 0, 0.14);
}

#petbuy-mega-menu {
    position: fixed;
    top: var(--petbuy-menu-top, 96px);
    left: var(--petbuy-menu-left, 50%);
    width: var(--petbuy-menu-width, min(1480px, calc(100vw - 48px)));
    transform: translate3d(0, 12px, 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.22s ease;
    z-index: 9999999;
    max-height: calc(100vh - var(--petbuy-menu-top, 96px) - 24px);
    overflow: auto;
    overscroll-behavior: contain;
}

#petbuy-menu-overlay {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--petbuy-overlay-top, 0);
    bottom: 0;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 9999998;
}

#petbuy-menu-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

#petbuy-mega-menu.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
}

.petbuy-menu__panel {
    display: flex;
    width: 100%;
    min-height: min(720px, calc(100vh - var(--petbuy-menu-top, 96px) - 24px));
    background: #fff;
    border-radius: var(--petbuy-panel-radius);
    overflow: hidden;
    box-shadow: var(--petbuy-shadow);
    animation: petbuy-menu-pop 320ms ease-out;
}

.petbuy-menu__left {
    width: 40%;
    color: #fff;
    padding: 24px 28px 28px;
    background: var(--petbuy-orange);
    background-image:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.08) 0, rgba(255, 255, 255, 0.08) 18%, transparent 18%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.08) 0, rgba(255, 255, 255, 0.08) 16%, transparent 16%),
        radial-gradient(circle at 15% 80%, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0.06) 14%, transparent 14%);
}

.petbuy-menu__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.petbuy-menu__logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    font-size: 16px;
}

.petbuy-menu__logo-text {
    font-size: 17px;
}

.petbuy-menu__categories {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 24px;
}

.petbuy-menu__cat {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    color: #fff;
    text-align: left;
    font-size: 21px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 0;
    transition: transform 0.18s ease, opacity 0.18s ease;
    opacity: 0;
    transform: translateX(-6px);
    animation: petbuy-cat-pop 320ms ease forwards;
}

.petbuy-menu__cat:hover {
    transform: translateX(4px);
}

.petbuy-menu__cat--active {
    opacity: 1;
}

.petbuy-menu__cat:nth-child(1)  { animation-delay: 40ms; }
.petbuy-menu__cat:nth-child(2)  { animation-delay: 70ms; }
.petbuy-menu__cat:nth-child(3)  { animation-delay: 100ms; }
.petbuy-menu__cat:nth-child(4)  { animation-delay: 130ms; }
.petbuy-menu__cat:nth-child(5)  { animation-delay: 160ms; }
.petbuy-menu__cat:nth-child(6)  { animation-delay: 190ms; }
.petbuy-menu__cat:nth-child(7)  { animation-delay: 220ms; }
.petbuy-menu__cat:nth-child(8)  { animation-delay: 250ms; }
.petbuy-menu__cat:nth-child(9)  { animation-delay: 280ms; }
.petbuy-menu__cat:nth-child(10) { animation-delay: 310ms; }
.petbuy-menu__cat:nth-child(11) { animation-delay: 340ms; }
.petbuy-menu__cat:nth-child(12) { animation-delay: 370ms; }

.petbuy-menu__cat-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--petbuy-orange-soft);
    color: var(--petbuy-text);
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.petbuy-menu__cat-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.petbuy-menu__cat-icon.has-img {
    background: #fff;
    padding: 0;
}

.petbuy-menu__cat-icon.has-img img {
    transform: scale(1.1);
}

.petbuy-menu__cat-name {
    border-bottom: 3px solid rgba(255, 255, 255, 0.24);
    padding-bottom: 4px;
    display: inline-block;
}

.petbuy-menu__cat--active .petbuy-menu__cat-name {
    border-color: #fff;
}

.petbuy-menu__right {
    width: 60%;
    padding: 22px 28px 290px;
    position: relative;
}

.petbuy-menu__close-row {
    display: flex;
    justify-content: flex-end;
}

.petbuy-menu__close {
    background: transparent;
    border: none;
    font-size: 26px;
    cursor: pointer;
    padding: 6px;
    color: var(--petbuy-muted);
    line-height: 1;
}

.petbuy-menu__content {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "subcats";
    align-items: start;
    gap: 10px 16px;
}

.petbuy-menu__header {
    grid-column: span 2;
    grid-area: header;
}

.petbuy-menu__title {
    margin: 0 0 10px;
    font-size: 23px;
    color: var(--petbuy-text);
    text-align: center;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    position: relative;
}

.petbuy-menu__title::after {
    content: "";
    display: block;
    width: 44px;
    height: 3px;
    background: var(--petbuy-orange);
    border-radius: 999px;
    margin: 8px auto 0;
}

.petbuy-menu__divider {
    height: 1px;
    width: 100%;
    background: #dedede;
}

.petbuy-menu__subcats {
    grid-area: subcats;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px 20px;
    align-items: start;
}

.petbuy-menu__subcat {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--petbuy-text);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
    transition: color 0.15s ease, border-color 0.16s ease, box-shadow 0.18s ease, transform 0.16s ease;
    line-height: 1.3;
    opacity: 0;
    transform: translateY(6px);
    animation: petbuy-subcat-pop 320ms ease forwards;
}

.petbuy-menu__subcat:hover {
    color: #f08a3c;
    border-color: #ffd9bf;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.07);
    transform: translateY(-1px);
}

.petbuy-menu__subcat::before {
    content: "";
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #f7f7f7;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px #ededed;
}

.petbuy-menu__subcat:nth-child(1)  { animation-delay: 40ms; }
.petbuy-menu__subcat:nth-child(2)  { animation-delay: 70ms; }
.petbuy-menu__subcat:nth-child(3)  { animation-delay: 100ms; }
.petbuy-menu__subcat:nth-child(4)  { animation-delay: 130ms; }
.petbuy-menu__subcat:nth-child(5)  { animation-delay: 160ms; }
.petbuy-menu__subcat:nth-child(6)  { animation-delay: 190ms; }
.petbuy-menu__subcat:nth-child(7)  { animation-delay: 220ms; }
.petbuy-menu__subcat:nth-child(8)  { animation-delay: 250ms; }
.petbuy-menu__subcat:nth-child(9)  { animation-delay: 280ms; }
.petbuy-menu__subcat:nth-child(10) { animation-delay: 310ms; }
.petbuy-menu__subcat:nth-child(11) { animation-delay: 340ms; }
.petbuy-menu__subcat:nth-child(12) { animation-delay: 370ms; }

.petbuy-menu__empty {
    color: var(--petbuy-muted);
    margin: 0;
}

.petbuy-menu__hero {
    position: absolute;
    bottom: 18px;
    right: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.petbuy-menu__hero-blob {
    width: 360px;
    height: 250px;
    border-radius: 55% 45% 60% 40%;
    background: var(--petbuy-orange-soft);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    animation: petbuy-blob-float 4s ease-in-out infinite;
}

.petbuy-menu__hero-blob::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.24), transparent 45%);
    opacity: 0.5;
}

.petbuy-menu__hero-icon {
    width: 212px;
    height: 212px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 26px;
    color: var(--petbuy-text);
    position: relative;
    z-index: 1;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.petbuy-menu__hero-icon img {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0;
    object-fit: cover;
    transform: scale(1.06);
    display: none;
}

.petbuy-menu__hero-icon.has-img img {
    display: block;
}

.petbuy-menu__hero-icon.has-img span {
    display: none;
}

/* Highlight search bar when mega menu is open */
body.petbuy-menu-open .edit-form-header,
body.petbuy-menu-open .aws-search-field,
body.petbuy-menu-open input[type="search"] {
    border-color: var(--petbuy-orange);
    box-shadow: 0 0 0 3px rgba(233, 120, 47, 0.16);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}


/* Rimuove la X nativa dai campi search per evitare sovrapposizioni con l'icona custom */
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    height: 0;
    width: 0;
}

@keyframes petbuy-menu-pop {
    0% {
        transform: translate3d(0, 16px, 0) scale(0.98);
        opacity: 0;
    }
    55% {
        transform: translate3d(0, -6px, 0) scale(1.01);
        opacity: 1;
    }
    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes petbuy-blob-float {
    0% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -4px, 0);
    }
    100% {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes petbuy-subcat-pop {
    0% {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    70% {
        opacity: 1;
        transform: translateY(-2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes petbuy-cat-pop {
    0% {
        opacity: 0;
        transform: translateX(-10px) scale(0.98);
    }
    70% {
        opacity: 1;
        transform: translateX(2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}


@media (max-width: 1280px) {
    .petbuy-menu__left {
        width: 42%;
        padding: 22px 24px 24px;
    }

    .petbuy-menu__right {
        width: 58%;
        padding: 20px 24px 250px;
    }

    .petbuy-menu__categories {
        gap: 12px 18px;
    }

    .petbuy-menu__cat {
        font-size: 19px;
    }

    .petbuy-menu__hero {
        right: 18px;
        bottom: 16px;
    }

    .petbuy-menu__hero-blob {
        width: 300px;
        height: 214px;
    }

    .petbuy-menu__hero-icon {
        width: 182px;
        height: 182px;
    }
}

@media (max-width: 1024px) {
    #petbuy-mega-menu {
        max-height: calc(100vh - var(--petbuy-menu-top, 84px) - 20px);
    }

    .petbuy-menu__panel {
        flex-direction: column;
        min-height: unset;
    }

    .petbuy-menu__left,
    .petbuy-menu__right {
        width: 100%;
    }

    .petbuy-menu__left {
        padding: 20px 22px 18px;
    }

    .petbuy-menu__right {
        padding: 18px 22px 220px;
    }

    .petbuy-menu__categories {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .petbuy-menu__content {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "subcats";
    }

    .petbuy-menu__hero {
        bottom: 10px;
        right: 10px;
    }

    .petbuy-menu__hero-blob {
        width: 250px;
        height: 176px;
    }

    .petbuy-menu__hero-icon {
        width: 146px;
        height: 146px;
    }
}

@media (max-width: 768px) {
    #petbuy-mega-menu {
        max-height: calc(100vh - var(--petbuy-menu-top, 72px) - 16px);
    }

    .petbuy-menu__categories {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .petbuy-menu__cat {
        font-size: 18px;
    }

    .petbuy-menu__left,
    .petbuy-menu__right {
        padding-left: 18px;
        padding-right: 18px;
    }

    .petbuy-menu__right {
        padding-bottom: 22px;
    }

    .petbuy-menu__content {
        grid-template-areas:
            "header"
            "hero"
            "subcats";
    }

    .petbuy-menu__hero {
        position: relative;
        right: auto;
        bottom: auto;
        grid-area: hero;
        margin: 6px auto 4px;
    }

    .petbuy-menu__hero-blob {
        width: 220px;
        height: 156px;
    }

    .petbuy-menu__hero-icon {
        width: 118px;
        height: 118px;
        font-size: 20px;
    }

    .petbuy-menu__subcats {
        grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
        gap: 10px 14px;
    }
}

@media (max-width: 480px) {
    .petbuy-menu__left,
    .petbuy-menu__right {
        padding: 16px;
    }

    .petbuy-menu__cat {
        font-size: 17px;
        gap: 10px;
    }

    .petbuy-menu__cat-icon {
        width: 56px;
        height: 56px;
    }

    .petbuy-menu__categories {
        grid-template-columns: 1fr;
    }

    .petbuy-menu__title {
        font-size: 20px;
    }

    .petbuy-menu__hero-blob {
        width: 180px;
        height: 128px;
        animation-duration: 3.6s;
    }

    .petbuy-menu__hero-icon {
        width: 100px;
        height: 100px;
        font-size: 18px;
    }

    .petbuy-menu__right {
        padding-bottom: 20px;
    }
}
