/* MEGH Mega Menu Frontend Styles (V2 Inline) */

.megh-inline-nav {
    font-family: 'Inter', 'Roboto', sans-serif;
    position: relative;
    z-index: 9999;
}

/* Root Menu Level (Horizontal) */
.megh-inline-root-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 30px; /* Spacing between root items like the reference image */
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative; /* All dropdowns will align to this container */
}

.megh-inline-root-item {
    position: static; /* Let dropdown position relate to the root list */
}

.megh-inline-root-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-weight: 500;
    color: #1A1835;
    padding: 10px 15px;
    height: 100%; /* For full height alignment */
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

/* --- Root Level Hover Effects (Level 1) --- */
.megh-root-hover-underline .megh-inline-root-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15px;
    right: 15px;
    height: 2px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s ease;
}
.megh-root-hover-underline .megh-inline-root-item:hover .megh-inline-root-link::after,
.megh-root-hover-underline .megh-inline-root-item.active .megh-inline-root-link::after {
    transform: scaleX(1);
}

.megh-root-hover-scale .megh-inline-root-item:hover .megh-inline-root-link,
.megh-root-hover-scale .megh-inline-root-item.active .megh-inline-root-link {
    transform: scale(1.05);
}

.megh-root-hover-lift .megh-inline-root-item:hover .megh-inline-root-link,
.megh-root-hover-lift .megh-inline-root-item.active .megh-inline-root-link {
    transform: translateY(-4px);
}
/* ------------------------------------------ */

.megh-inline-root-link:hover,
.megh-inline-root-item.active > .megh-inline-root-link {
    color: #0d47a1; /* Active color reference */
}

/* Page Overlay Backdrop */
.megh-mm-overlay {
    position: fixed;
    top: calc(var(--megh-header-bottom, 0px) - 1px);
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--megh-header-bottom, 0px) + 1px);
    background: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: visibility 0s 0.4s, opacity 0.4s ease;
}

.megh-mm-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: visibility 0s 0s, opacity 0.4s ease;
}

/* Mega Menu Dropdown Wrapper (Base) */
.megh-mega-menu-wrapper {
    position: absolute;
    top: 100%;
    left: 0; /* Align perfectly to the left of the .megh-inline-root-list */
    width: max-content;
    max-width: 90vw;
    background: #ffffff;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    z-index: 99999;
    
    /* Animation base using visibility/opacity to avoid block/none blinking */
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px); /* Start slightly below for slide-up-to-place effect */
    transition: visibility 0s 0.3s, opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.megh-mega-menu-wrapper.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: visibility 0s 0s, opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --- Sidebar Layout Mode Overrides --- */
.layout-sidebar .megh-mega-menu-wrapper {
    position: fixed;
    top: calc(var(--megh-header-bottom, 0px) - 1px); /* Slight 1px overlap upwards to hide gaps, but low enough to clear the logo */
    left: 0;
    right: auto;
    height: calc(100vh - var(--megh-header-bottom, 0px) + 1px);
    max-height: calc(100vh - var(--megh-header-bottom, 0px) + 1px);
    border-radius: 0;
    border-top: 1px solid #EAEAEA;
    box-shadow: 10px 0 50px rgba(0, 0, 0, 0.2);
    /* Start off-canvas to the left */
    transform: translateX(-100%);
    transition: visibility 0s 0.4s, opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.layout-sidebar .megh-mega-menu-wrapper.active {
    transform: translateX(0);
    transition: visibility 0s 0s, opacity 0.4s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.layout-sidebar .megh-mm-flex-container {
    height: 100%;
}

.layout-sidebar .megh-mm-column {
    height: 100%;
    overflow-y: auto; /* Allowing scrolling inside the panel if content is very long */
}

.layout-sidebar .megh-mm-close-wrapper {
    top: 25px; /* Adjusting close button position for full-height sidebar */
}
/* ------------------------------------- */

/* Flex Container inside Wrapper */
.megh-mm-flex-container {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    position: relative; /* For the close btn */
}

/* Base Column Style */
.megh-mm-column {
    background: #ffffff;
    border-right: 1px solid #EAEAEA;
    flex-shrink: 0;
    width: 320px; /* Fixed width for each column */
    /* Animation for dynamic columns */
    animation: meghSlideInLeft 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes meghSlideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

.megh-mm-column:last-child {
    border-right: none;
}

/* Column 1: Info */
.megh-mm-col-info {
    padding: 40px 30px;
    display: block !important;
    animation: none; /* Already visible */
}

.megh-mm-title {
    font-size: 24px;
    font-weight: 700;
    color: #000000;
    margin: 0 0 20px 0;
    padding: 0;
}

.megh-mm-description {
    font-size: 14px;
    line-height: 1.6;
    color: #555555;
    margin: 0;
}

/* Column 2+: List Styles */
.megh-mm-col-first-level {
    animation: none; /* First level is visible with wrapper */
}

.megh-mm-list {
    list-style: none;
    margin: 0;
    padding: 40px 30px 30px 30px; /* padding top for header spacing */
}

.megh-mm-item {
    border-bottom: 1px solid #EEEEEE;
}

.megh-mm-item:last-child {
    border-bottom: none;
}

.megh-mm-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    text-decoration: none !important;
    color: #777777;
    font-size: 15px;
    transition: all 0.2s ease;
}

.megh-mm-link:hover,
.megh-mm-link:focus,
.megh-mm-item.active > .megh-mm-link {
    color: #1A1835;
    font-weight: 500;
}

/* Icons */
.megh-mm-icon {
    display: flex;
    align-items: center;
    color: #CCCCCC;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.megh-mm-item:hover > .megh-mm-link .megh-mm-icon,
.megh-mm-item.active > .megh-mm-link .megh-mm-icon {
    color: #1A1835;
}

/* --- Sub-items Hover Effects (Level 2+) --- */
.megh-sub-hover-shift-right .megh-mm-item:hover > .megh-mm-link,
.megh-sub-hover-shift-right .megh-mm-item.active > .megh-mm-link {
    transform: translateX(10px);
}
.megh-sub-hover-shift-right .megh-mm-item:hover > .megh-mm-link .megh-mm-icon,
.megh-sub-hover-shift-right .megh-mm-item.active > .megh-mm-link .megh-mm-icon {
    transform: translateX(3px); /* extra push to arrow */
}

.megh-sub-hover-scale .megh-mm-item:hover > .megh-mm-link,
.megh-sub-hover-scale .megh-mm-item.active > .megh-mm-link {
    transform: scale(1.03);
    transform-origin: left center;
}

.megh-sub-hover-bg-fade .megh-mm-link {
    border-radius: 4px;
    padding-left: 10px;
    padding-right: 10px;
}
.megh-sub-hover-bg-fade .megh-mm-item:hover > .megh-mm-link,
.megh-sub-hover-bg-fade .megh-mm-item.active > .megh-mm-link {
    background-color: rgba(0, 0, 0, 0.04);
}
/* ------------------------------------------ */

/* Close Button */
.megh-mm-close-wrapper {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
}

.megh-mm-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #1A1835;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.megh-mm-close-btn:hover {
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 992px) {
    .megh-inline-root-list {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .megh-mega-menu-wrapper,
    .layout-sidebar .megh-mega-menu-wrapper {
        position: static;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: none;
        box-shadow: none;
        border-left: 2px solid #EAEAEA;
        margin-top: 10px;
        transform: translateY(-10px);
        transition: visibility 0s 0.3s, opacity 0.3s ease, transform 0.3s ease;
    }

    .megh-mega-menu-wrapper.active,
    .layout-sidebar .megh-mega-menu-wrapper.active {
        transform: translateY(0);
        transition: visibility 0s 0s, opacity 0.3s ease, transform 0.3s ease;
    }

    .megh-mm-overlay {
        display: none !important;
    }

    .megh-mm-flex-container {
        flex-direction: column;
    }

    .megh-mm-column {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #EAEAEA;
    }

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

/* ========================================================================= */
/* MEGH Cascade Grid Implementation */
/* ========================================================================= */

.megh-cascade-grid-wrapper { width: 100%; font-family: 'Inter', 'Roboto', sans-serif; }
.megh-cascade-grid {
	display: flex; flex-wrap: nowrap; width: 100%;
	gap: 20px; /* Overridden by settings */
}
@media (max-width: 1024px) {
	.megh-cascade-grid { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding-bottom: 15px; }
	.megh-cascade-item { scroll-snap-align: start; }
}
@media (max-width: 767px) {
	.megh-cascade-grid { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
}
.megh-cascade-grid::-webkit-scrollbar { height: 6px; }
.megh-cascade-grid::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 4px; }
.megh-cascade-grid::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.megh-cascade-grid::-webkit-scrollbar-thumb:hover { background: #aaa; }

.megh-cascade-item {
	position: relative; flex: 0 0 300px; width: 300px; height: 400px; border-radius: 10px; overflow: hidden;
	opacity: 0; transform: translateY(30px) scale(0.95); will-change: transform, opacity;
}
.megh-cascade-item .megh-cascade-link { display: block; width: 100%; height: 100%; position: relative; text-decoration: none; }
.megh-cascade-image-wrap { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.megh-cascade-image {
	width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); will-change: transform; display: block;
}
.megh-cascade-image-placeholder { width: 100%; height: 100%; background-color: #e0e0e0; }
.megh-cascade-overlay {
	position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); opacity: 0; transition: opacity 0.4s ease; z-index: 1;
}
.megh-cascade-content {
	position: absolute; top: 50%; left: 0; width: 100%; transform: translateY(-40%); padding: 20px; text-align: center; z-index: 2; opacity: 0; transition: opacity 0.4s ease, transform 0.4s ease; box-sizing: border-box;
}
.megh-cascade-content h3 { margin: 0; color: #fff; line-height: 1.2; }

/* Hover & Active Effects */
.megh-cascade-item:hover .megh-cascade-image, .megh-cascade-item.is-active .megh-cascade-image { transform: scale(var(--mcg-zoom, 1.1)); }
.megh-cascade-item:hover .megh-cascade-overlay, .megh-cascade-item.is-active .megh-cascade-overlay { opacity: 1; }
.megh-cascade-item:hover .megh-cascade-content, .megh-cascade-item.is-active .megh-cascade-content { opacity: 1; transform: translateY(-50%); }

/* Entrance Animation Triggered via JS (.is-visible) */
.megh-cascade-grid.is-visible .megh-cascade-item {
	animation: var(--mcg-anim-name, mcgCascadeFadeInUp) var(--mcg-duration, 600ms) cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
	animation-delay: calc(var(--mcg-index, 0) * var(--mcg-delay-step, 150ms));
}
@keyframes mcgCascadeFadeInUp { 0% { opacity: 0; transform: translateY(30px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes mcgCascadeFadeInDown { 0% { opacity: 0; transform: translateY(-30px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes mcgCascadeFadeInLeft { 0% { opacity: 0; transform: translateX(-30px) scale(0.95); } 100% { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes mcgCascadeFadeInRight { 0% { opacity: 0; transform: translateX(30px) scale(0.95); } 100% { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes mcgCascadeZoomIn { 0% { opacity: 0; transform: scale(0.85); } 100% { opacity: 1; transform: scale(1); } }
@keyframes mcgCascadeFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

.elementor-editor-active .megh-cascade-item { opacity: 1; transform: none; animation: none; }

/* ========================================================================= */
/* Cascade Grid – Submenu Panel (below the grid)                              */
/* ========================================================================= */

/* Cards that have sub-items: pointer cursor */
.megh-cascade-item[data-cg-has-sub] {
	cursor: pointer;
}

/* Highlight ring on the selected card */
.megh-cascade-item.megh-cg-selected::after {
	content: '';
	position: absolute;
	inset: 0;
	border: 3px solid #1A3C8E;
	border-radius: inherit;
	z-index: 3;
	pointer-events: none;
}

/* Panel wrapper — collapses to 0 height by default, expands when .is-open */
.megh-cg-submenu-wrapper {
	width: 100%;
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transition: max-height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
	            opacity 0.3s ease;
}

.megh-cg-submenu-wrapper.is-open {
	max-height: 250px;
	opacity: 1;
}

/* Inner layout: count left / info right, separated from grid by a subtle line */
.megh-cg-submenu-inner {
	display: flex;
	align-items: stretch;
	gap: 0;
	margin-top: 16px;
	border-top: 1px solid #e0e4ee;
	background: transparent;
	font-family: 'Inter', 'Roboto', sans-serif;
	overflow: hidden;
}

/* Left column – count + label */
.megh-cg-sub-count-col {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: flex-start;
	padding: 24px 30px 24px 24px;
	border-right: 1px solid #e8ecf6;
	min-width: 130px;
}

.megh-cg-sub-count {
	font-size: 52px;
	font-weight: 700;
	line-height: 1;
	color: #1A3C8E;
	letter-spacing: -2px;
	display: block;
}

.megh-cg-sub-count-label {
	font-size: 11px;
	color: #888888;
	margin-top: 5px;
	letter-spacing: 0.02em;
	text-transform: lowercase;
}

/* Right column – title + sub-links */
.megh-cg-sub-info-col {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 10px;
	padding: 24px 24px;
}

.megh-cg-sub-title {
	margin: 0;
	font-size: 28px;
	font-weight: 700;
	color: #1A3C8E;
	line-height: 1.1;
}

.megh-cg-sub-links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 20px;
}

.megh-cg-sub-links li a {
	font-size: 14px;
	color: #555555;
	text-decoration: none;
	transition: color 0.2s ease;
}

.megh-cg-sub-links li a:hover {
	color: #1A3C8E;
	text-decoration: underline;
}

.megh-cg-sub-links li a.is-active {
	color: #1A3C8E;
	font-weight: 600;
	text-decoration: underline;
	pointer-events: none;
}

/* Responsive */
@media (max-width: 767px) {
	.megh-cg-submenu-wrapper.is-open { max-height: 350px; }
	.megh-cg-submenu-inner {
		flex-direction: column;
		gap: 0;
	}
	.megh-cg-sub-count-col {
		border-right: none;
		border-bottom: 1px solid #e8ecf6;
		padding: 16px 20px;
		flex-direction: row;
		align-items: baseline;
		gap: 8px;
	}
	.megh-cg-sub-count { font-size: 36px; }
	.megh-cg-sub-title { font-size: 20px; }
}

/* =========================================================================
   Elementor Editor Preview Mode
   Applied when wrapper has .megh-editor-preview (editor + first card shown)
   ========================================================================= */

/* Dashed border hints that this is edit-mode preview */
.megh-editor-preview .megh-cg-submenu-inner {
	border-top: 2px dashed #8c9fc5;
	position: relative;
}

/* "Pré-visualização do Editor" badge */
.megh-editor-preview .megh-cg-submenu-inner::before {
	content: '⬙ Pré-visualização do Editor';
	position: absolute;
	top: -1px;
	right: 16px;
	transform: translateY(-100%);
	background: #1A3C8E;
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.04em;
	padding: 3px 10px 3px 8px;
	border-radius: 4px 4px 0 0;
	pointer-events: none;
	line-height: 1.6;
}

/* Highlight the auto-selected card in editor so it's obvious which one is showing */
.megh-editor-preview .megh-cascade-item.megh-cg-selected::after {
	border-color: #4e7de9;
	border-style: dashed;
}
