/* ============================================================
   Catalogue Menu – Megamenu Widget
   ============================================================ */

/* ── Wrapper ── */
.catmenu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Trigger button ── */
.catmenu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    transition: color 0.25s ease, background 0.25s ease;
    white-space: nowrap;
    line-height: 1;
}

.catmenu__trigger:hover,
.catmenu__trigger[aria-expanded="true"] {
    color: #0B3954;
    background: rgba(255, 255, 255, 0.95);
}

.catmenu__trigger-icon {
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__trigger:hover .catmenu__trigger-icon {
    transform: scale(1.1);
}

.catmenu__trigger-chevron {
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__trigger[aria-expanded="true"] .catmenu__trigger-chevron {
    transform: rotate(180deg);
}


/* ── Dropdown ── */
.catmenu__dropdown {
    position: absolute;
    top: calc(100% + 0px);
    left: 0;
    z-index: 99999;
    min-width: 920px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: none;
    border-radius: 4px;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}

.catmenu__dropdown--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* ── CSS-only hover fallback before JS is ready ── */
.catmenu:not(.catmenu--js-ready):hover>.catmenu__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.catmenu__inner {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    min-height: 0;
}

/* ── Tabs (left column) ── */
.catmenu__tabs {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #f0f0f0;
    background: #fff;
    border-radius: 4px 0 0 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Scrollbar discrète */
.catmenu__tabs::-webkit-scrollbar {
    width: 4px;
}

.catmenu__tabs::-webkit-scrollbar-track {
    background: transparent;
}

.catmenu__tabs::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

.catmenu__tabs::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

.catmenu__tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    text-align: left;
    transition: all 0.2s ease;
    position: relative;
    width: 100%;
}

/* ── Tab category image ── */
.catmenu__tab-image {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: #fff;
    border: 1px solid #eee;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.catmenu__tab:hover .catmenu__tab-image,
.catmenu__tab--active .catmenu__tab-image {
    border-color: #ddd;
    transform: scale(1.05);
}

.catmenu__tab::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: #e3001a;
    border-radius: 0 3px 3px 0;
    transition: height 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__tab:hover {
    color: #333;
    background: #fafafa;
}

.catmenu__tab--active {
    color: #333;
    background: #fafafa;
    font-weight: 400;
}

.catmenu__tab--active::before {
    height: 55%;
}

.catmenu__tab-arrow {
    flex-shrink: 0;
    margin-left: auto;
    color: transparent;
    transition: color 0.2s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__tab:hover .catmenu__tab-arrow,
.catmenu__tab--active .catmenu__tab-arrow {
    color: #333;
    transform: translateX(3px);
}

/* ── Content (right column) ── */
.catmenu__content {
    padding: 20px 24px;
    position: relative;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Scrollbar discrète */
.catmenu__content::-webkit-scrollbar {
    width: 4px;
}

.catmenu__content::-webkit-scrollbar-track {
    background: transparent;
}

.catmenu__content::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

.catmenu__content::-webkit-scrollbar-thumb:hover {
    background: #b0b0b0;
}

/* ── Panel header (title + see all) ── */
.catmenu__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px 0;
    padding: 0 0 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.catmenu__panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
    color: #333;
    letter-spacing: 0.01em;
}

/* ── Panel ── */
.catmenu__panel {
    display: none;
}

.catmenu__panel--active {
    display: block;
    animation: catmenuFadeIn 0.18s ease-out;
}

@keyframes catmenuFadeIn {
    from {
        opacity: 0;
        transform: translateX(5px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ── Subcategories list ── */
.catmenu__subcats {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.catmenu__subcat-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 30px 9px 12px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: color 0.2s ease, background 0.2s ease;
    line-height: 1.4;
    border-radius: 4px;
    position: relative;
    white-space: normal;
}

.catmenu__subcat-link:hover {
    color: #0B3954;
    background: #f5f7f9;
}

.catmenu__subcat-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Arrow positioned absolutely so it never causes wrapping */
.catmenu__subcat-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    opacity: 0;
    display: flex;
    align-items: center;
    transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__subcat-link:hover .catmenu__subcat-arrow {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.catmenu__badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: #e3001a;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 4px;
    line-height: 1.4;
    flex-shrink: 0;
    margin-left: 6px;
}

/* ── See all link ── */
.catmenu__see-all {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #e3001a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: gap 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
    padding: 4px 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.catmenu__see-all:hover {
    gap: 8px;
    color: #c00017;
}

.catmenu__see-all svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__see-all:hover svg {
    transform: translateX(2px);
}

/* ── Bestsellers (inside panel, below subcats) ── */
.catmenu__bestsellers {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.catmenu__bestsellers-title {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #999;
    margin: 0 0 12px 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Product cards (2x2 grid) ── */
.catmenu__products {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.catmenu__product {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.2s ease;
    position: relative;
    flex: 1;
    min-width: 0;
    background: #fafafa;
}

.catmenu__product:hover {
    background: #f0f2f4;
}

.catmenu__product-image {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 1px solid #f0f0f0;
    box-sizing: border-box;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.catmenu__product:hover .catmenu__product-image {
    transform: scale(1.04);
}

.catmenu__product-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.catmenu__product-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.catmenu__product-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.catmenu__product:hover .catmenu__product-title {
    color: #0B3954;
}

.catmenu__product-price {
    font-size: 13px;
    font-weight: 700;
    color: #e3001a;
    line-height: 1.3;
}

.catmenu__product-price .woocommerce-Price-amount {
    color: inherit;
}

.catmenu__product-price .woocommerce-Price-currencySymbol {
    font-size: 11px;
}

.catmenu__product-price del {
    opacity: 0.5;
    font-size: 11px;
}

.catmenu__product-price ins {
    text-decoration: none;
}

.catmenu__product-sku {
    font-size: 10px;
    color: #999;
    font-weight: 500;
}

/* ── Product count badge on tab ── */
.catmenu__tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #f0f0f0;
    color: #777;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

.catmenu__tab--active .catmenu__tab-count,
.catmenu__tab:hover .catmenu__tab-count {
    background: #e3001a;
    color: #fff;
}

/* ── Empty state ── */
.catmenu__empty {
    color: #999;
    font-size: 13px;
    font-style: italic;
    margin: 0;
    padding: 20px 0;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .catmenu__dropdown {
        min-width: 580px;
    }

    .catmenu__inner {
        grid-template-columns: 240px 1fr;
    }

    .catmenu__tab-image {
        width: 32px;
        height: 32px;
    }

    .catmenu__products {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .catmenu__dropdown {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        min-width: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        transform: translateY(0);
        overflow-y: auto;
    }

    .catmenu__inner {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        min-height: 0;
        max-height: none;
    }

    .catmenu__tabs {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
        border-radius: 0;
        padding: 0;
        gap: 0;
        -webkit-overflow-scrolling: touch;
        max-height: none;
    }

    .catmenu__content {
        max-height: none;
        overflow-y: visible;
        padding: 20px 16px;
    }

    .catmenu__tab {
        white-space: nowrap;
        padding: 14px 18px;
        flex-shrink: 0;
    }

    .catmenu__tab::before {
        top: auto;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 3px;
        border-radius: 3px 3px 0 0;
    }

    .catmenu__tab--active::before {
        width: 60%;
        height: 3px;
    }

    .catmenu__tab-arrow {
        display: none;
    }

    .catmenu__tab-image {
        width: 28px;
        height: 28px;
    }

    .catmenu__products {
        flex-direction: column;
    }

    /* Mobile close button */
    .catmenu__dropdown--open::before {
        content: '\00d7';
        position: fixed;
        top: 12px;
        right: 16px;
        z-index: 100001;
        font-size: 28px;
        color: #333;
        cursor: pointer;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        border-radius: 50%;
    }
}