/**
 * MW Mega Menu - Frontend Styles
 * Desktop Only | RTL | Woodmart Compatible
 */

/* CSS Variables defaults (low specificity) */
:where(.mw-mega-menu-wrapper) {
    --mw-mm-parent-font: inherit;
    --mw-mm-parent-size: 15px;
    --mw-mm-parent-weight: 600;
    --mw-mm-parent-color: #2d2d2d;
    --mw-mm-parent-hover: #ff6b35;
    --mw-mm-child-font: inherit;
    --mw-mm-child-size: 14px;
    --mw-mm-child-weight: 500;
    --mw-mm-child-color: #444444;
    --mw-mm-child-hover: #ff6b35;
    --mw-mm-panel-title-font: inherit;
    --mw-mm-panel-title-size: 36px;
    --mw-mm-panel-title-weight: 700;
    --mw-mm-panel-title-color: #2d2d2d;
    --mw-mm-image-width: 22vw;
    --mw-mm-image-height: 22vw;
    --mw-mm-image-radius: 8px;
    --mw-mm-panel-max-width: 98%;
    --mw-mm-panel-padding: 35px;
    --mw-mm-panel-bg: #ffffff;
    --mw-mm-panel-border: #ff6b35;
    --mw-mm-panel-offset: 0px;
    --mw-mm-arrow-color: #ff6b35;
    --mw-mm-title-col-width: 240px;
}

.mw-mega-menu-wrapper {
    position: relative;
    direction: rtl;
    width: 100%;
}

.mw-mega-menu-wrapper .mw-mega-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
}

.mw-mega-menu > li.mw-mega-menu-item {
    position: static;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mw-mega-menu > li.mw-mega-menu-item > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.2s ease;
    position: relative;
    font-family: var(--mw-mm-parent-font);
    font-size: var(--mw-mm-parent-size);
    font-weight: var(--mw-mm-parent-weight);
    color: var(--mw-mm-parent-color);
}

.mw-mega-menu > li.mw-mega-menu-item:hover > a,
.mw-mega-menu > li.mw-mega-menu-item:focus-within > a,
.mw-mega-menu > li.mw-mega-menu-item.is-open > a {
    color: var(--mw-mm-parent-hover);
}

.mw-mega-menu > li.mw-mega-menu-item > a::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 20px;
    left: 20px;
    height: 2px;
    background: var(--mw-mm-parent-hover);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.mw-mega-menu > li.mw-mega-menu-item:hover > a::after,
.mw-mega-menu > li.mw-mega-menu-item:focus-within > a::after,
.mw-mega-menu > li.mw-mega-menu-item.is-open > a::after {
    transform: scaleX(1);
}

.mw-mega-menu .mw-mm-arrow {
    font-size: 10px;
    line-height: 1;
    transition: transform 0.25s ease;
    display: inline-block;
}

.mw-mega-menu > li.mw-mega-menu-item:hover .mw-mm-arrow,
.mw-mega-menu > li.mw-mega-menu-item.is-open .mw-mm-arrow {
    transform: rotate(180deg);
}

/* Panel */
.mw-mega-menu-panel {
    position: absolute;
    top: calc(100% + var(--mw-mm-panel-offset, 0px));
    right: 50%;
    transform: translateX(50%);
    width: var(--mw-mm-panel-max-width);
    max-width: var(--mw-mm-panel-max-width);
    background: var(--mw-mm-panel-bg);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    border-top: 2px solid var(--mw-mm-panel-border);
    border-radius: 0 0 8px 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 9999;
    pointer-events: none;
}

.mw-mega-menu > li.mw-mega-menu-parent:hover > .mw-mega-menu-panel,
.mw-mega-menu > li.mw-mega-menu-parent:focus-within > .mw-mega-menu-panel,
.mw-mega-menu > li.mw-mega-menu-parent.is-open > .mw-mega-menu-panel {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.mw-mega-menu-inner {
    padding: var(--mw-mm-panel-padding);
    display: flex;
    gap: 40px;
    align-items: stretch;
    flex-direction: row;
}

/* אזור 1 - כותרת */
.mw-mega-menu-title-col {
    flex: 0 0 var(--mw-mm-title-col-width);
    width: var(--mw-mm-title-col-width);
    max-width: var(--mw-mm-title-col-width);
    display: flex;
    align-items: flex-start;
    padding-top: 4px;
    border-left: 1px solid #eee;
    padding-left: 30px;
}

/* אזור 2 - רשימה */
.mw-mega-menu-items {
    flex: 1 1 auto;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mw-mega-menu-items li.mw-mega-menu-subitem {
    margin: 0;
    padding: 0;
    list-style: none;
    border-bottom: 1px solid #eee;
}

.mw-mega-menu-items li.mw-mega-menu-subitem:last-child {
    border-bottom: none;
}

.mw-mega-menu-items li.mw-mega-menu-subitem > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px;
    text-decoration: none;
    line-height: 1.5;
    transition: color 0.2s ease, padding 0.2s ease;
    font-family: var(--mw-mm-child-font);
    font-size: var(--mw-mm-child-size);
    font-weight: var(--mw-mm-child-weight);
    color: var(--mw-mm-child-color);
}

.mw-mega-menu-items li.mw-mega-menu-subitem > a:hover,
.mw-mega-menu-items li.mw-mega-menu-subitem > a:focus {
    color: var(--mw-mm-child-hover);
    padding-right: 10px;
}

.mw-mega-menu-items .mw-mm-text {
    flex: 1 1 auto;
    text-align: right;
}

.mw-mega-menu-items .mw-mm-child-arrow {
    flex: 0 0 auto;
    display: inline-block;
    font-size: calc(var(--mw-mm-child-size) + 4px);
    line-height: 1;
    color: var(--mw-mm-arrow-color);
    margin-right: 12px;
    transition: transform 0.2s ease;
    font-family: var(--mw-mm-parent-font);
}

.mw-mega-menu-items li.mw-mega-menu-subitem > a:hover .mw-mm-child-arrow {
    transform: translateX(-4px);
}

/* אזור 3 - תמונה */
.mw-mega-menu-image-wrap {
    flex: 0 0 var(--mw-mm-image-width);
    width: var(--mw-mm-image-width);
    height: var(--mw-mm-image-height);
    max-width: var(--mw-mm-image-width);
    border-radius: var(--mw-mm-image-radius);
    overflow: hidden;
    background: #f7f7f7;
    display: flex;
}

.mw-mega-menu-image-link {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 0;
    overflow: hidden;
    border-radius: var(--mw-mm-image-radius);
}

.mw-mega-menu-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
}

.mw-mega-menu-image-link:hover .mw-mega-menu-image {
    transform: scale(1.05);
}

/* כותרת inline - !important לדריסת theme */
.mw-mega-menu-wrapper .mw-mega-menu-panel-title {
    font-family: var(--mw-mm-panel-title-font) !important;
    font-size: var(--mw-mm-panel-title-size) !important;
    font-weight: var(--mw-mm-panel-title-weight) !important;
    color: var(--mw-mm-panel-title-color) !important;
}

.mw-mega-menu-wrapper .mw-mega-menu-panel-title a {
    font-family: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
}

/* Hide on tablets/mobile */
@media (max-width: 991px) {
    .mw-mega-menu-wrapper {
        display: none !important;
    }
}

/* Woodmart header compatibility */
.whb-header .mw-mega-menu-wrapper,
.whb-main-header .mw-mega-menu-wrapper {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.whb-header .mw-mega-menu-wrapper .mw-mega-menu,
.whb-main-header .mw-mega-menu-wrapper .mw-mega-menu {
    height: 100%;
    justify-content: center;
}

.whb-header .mw-mega-menu > li.mw-mega-menu-item,
.whb-main-header .mw-mega-menu > li.mw-mega-menu-item {
    display: flex;
    align-items: center;
}
