/**
 * Vertical Mega Menu Styles with Overlay Submenu
 *
 * @author CodeBreaker <office@codebreaker.ro>
 * @copyright 2025 CodeBreaker
 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0
 */

/* Container principal */
.cb-vertical-megamenu-container {
    width: 100%;
    margin: 0;
    position: relative;
}

/* Wrapper cu flexbox pentru layout desktop */
.cb-vmm-wrapper {
    display: flex;
    flex-direction: row;
    gap: 0;
    align-items: stretch;
    width: 100%;
    position: relative; /* Overlay se poziționează relativ la wrapper */
    min-height: 400px; /* Înălțime minimă pentru overlay */
    max-height: 491px;
}

/* Coloana stânga - Meniul vertical */
.cb-vmm-menu {
    flex: 0 0 236px;
    max-width: 236px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-left: none;
    overflow: visible; /* Important pentru overlay */
    z-index: 100;
}

.cb-vmm-categories {
    width: 100%;
    height: 100%;
}

.cb-vmm-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cb-vmm-item {
    border-bottom: 1px solid #ebebeb;
    position: static;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 1px;
    color: #6921E4;
    padding: 0;
    line-height: normal;
}

.cb-vmm-item:last-child {
    border-bottom: 1px solid #ebebeb;
}

.cb-vmm-link {
    display: block;
    padding: 0 40px 0 5px;
    height: 34.19px;
    color: #222;
    text-decoration: none;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 1px;
    line-height: 34.2px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    backface-visibility: hidden;
    width: 236px;
}

.cb-vmm-link:hover {
    color: #000;
}

/* Icon styling */
.cb-vmm-icon {
    width: 22px;
    height: 22px;
    margin-right: 1px;
    object-fit: contain;
}

.cb-vmm-link-text {
    flex: 1;
}

/* Arrow indicator via ::after on link */
.cb-vmm-link[data-has-submenu="1"]::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.5px solid #999;
    border-bottom: 1.5px solid #999;
    display: block;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%) rotate(-45deg);
    transition: right 0.2s ease, border-color 0.2s ease;
}

.cb-vmm-item:hover .cb-vmm-link[data-has-submenu="1"]::after {
    right: 10px;
    border-color: #222;
}

/* Coloana dreapta - Banner */
.cb-vmm-banner {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    position: relative;
    background: #f0f0f0;
    z-index: 1;
    aspect-ratio: 1018 / 534;
}

.cb-vmm-banner-link,
.cb-vmm-banner-wrapper {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.cb-vmm-banner-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

.cb-vmm-banner-img[data-fit-mode="cover"] {
    object-fit: cover;
}

.cb-vmm-banner-img[data-fit-mode="contain"] {
    object-fit: contain;
}

.cb-vmm-banner-img[data-object-position="top"] {
    object-position: top;
}

.cb-vmm-banner-img[data-object-position="bottom"] {
    object-position: bottom;
}

.cb-vmm-banner-img[data-object-position="center"] {
    object-position: center;
}

.cb-vmm-banner-link {
}

.cb-vmm-banner-link:hover {
    opacity: 0.95;
}

/* ============================================
   OVERLAY SUBMENU - Covers banner completely
   ============================================ */

.cb-vmm-overlay {
    position: absolute;
    top: 0;
    left: 236px; /* Menu width */
    right: 0; /* Se extinde până la marginea dreaptă a wrapper-ului */
    bottom: 0; /* Se extinde până la marginea de jos a wrapper-ului */
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    overflow: hidden; /* Fără scroll - conținutul trebuie să încapă */
    pointer-events: none;
}

/* Show overlay on hover */
.cb-vmm-item:hover .cb-vmm-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Keep overlay visible when hovering over it */
.cb-vmm-overlay:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.cb-vmm-overlay-content {
    padding: 15px 25px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Subcategories grid - flows top to bottom using CSS columns */
.cb-vmm-subcategories-grid {
    column-count: 4;
    column-gap: 25px;
    column-fill: auto; /* Umple coloana complet înainte de a trece la următoarea */
    flex: 1;
    margin-bottom: 10px;
    overflow: hidden;
}

.cb-vmm-subcat-column {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    break-inside: auto;
    -webkit-column-break-inside: auto;
    page-break-inside: auto;
}

/* Doar titlul nu se sparge de children */
.cb-vmm-subcat-title {
    font-size: 13px;
    font-weight: 700;
    color: #000;
    text-decoration: none;
    margin-bottom: 4px;
    display: block;
    break-after: avoid;
    -webkit-column-break-after: avoid;
}

.cb-vmm-subcat-title:hover {
    color: #0066cc;
}

/* Subcategory title without children (standalone) */
.cb-vmm-subcat-title-only {
    margin-bottom: 0;
}

.cb-vmm-subcat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cb-vmm-subcat-item {
    margin-bottom: 3px;
}

.cb-vmm-subcat-link {
    font-size: 12px;
    font-weight: 400;
    color: #555;
    text-decoration: none;
    display: block;
    padding-left: 0;
    line-height: 1.4;
}

/* Fără bullets */
.cb-vmm-subcat-link:before {
    display: none;
}

.cb-vmm-subcat-link:hover {
    color: #b28ef1;
}

/* Overlay footer with button */
.cb-vmm-overlay-footer {
    padding-top: 10px;
    border-top: none; /* Fără linie */
    margin-top: auto;
    flex-shrink: 0;
}

.cb-vmm-view-all-btn {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: #ebebeb;
    color: #222;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    border: 2px solid #ebebeb;
}

.cb-vmm-view-all-btn:hover {
    background: #ddd;
    border-color: #ddd;
    color: #222;
}

/* ============================================
   RESPONSIVE - Sub 1170px
   ============================================ */

@media (max-width: 1169px) {
    /* Ascunde complet meniul și overlay-ul */
    .cb-vmm-menu {
        display: none;
    }
    
    .cb-vmm-overlay {
        display: none;
    }
    
    .cb-vmm-wrapper {
        min-height: 0;
    }

    /* Banner ocupă întreaga lățime, imaginea dictează înălțimea */
    .cb-vmm-banner {
        flex: 1 1 100%;
        width: 100%;
    }

    .cb-vmm-banner-link,
    .cb-vmm-banner-wrapper {
        height: auto;
    }

    .cb-vmm-banner-img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }
}

/* Desktop breakpoint - asigurăm că meniul e vizibil */
@media (min-width: 1170px) {
    .cb-vmm-menu {
        display: block;
    }
    
    /* Pe desktop, bannerul nu are min-height impus */
    .cb-vmm-banner {
        min-height: 0;
    }
}

/* Stiluri pentru când nu există imagine */
.cb-vmm-banner:empty {
    display: none;
}

/* Accesibilitate - focus state */
.cb-vmm-link:focus,
.cb-vmm-banner-link:focus,
.cb-vmm-subcat-title:focus,
.cb-vmm-subcat-link:focus,
.cb-vmm-view-all-btn:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .cb-vertical-megamenu-container {
        display: none;
    }
}

/* Animation for subcategories */
.cb-vmm-item:hover .cb-vmm-subcategories-grid {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state placeholder */
.cb-vmm-overlay-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.cb-vmm-overlay-loading:after {
    content: "Loading...";
    color: #999;
    font-size: 16px;
}
