/* Mega menu compartilhado (layouts public e pages) */
.mega-menu-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.mega-menu-wrapper::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 14px;
}

.mega-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    line-height: inherit;
    white-space: nowrap;
    cursor: pointer;
}

.mega-menu-trigger:focus-visible {
    outline: 2px solid var(--mega-primary, #0f49bd);
    outline-offset: 4px;
    border-radius: 4px;
}

.mega-menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: auto;
    width: min(920px, calc(100vw - 2rem));
    max-height: min(70vh, 640px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #e6eaf0;
    border-radius: 14px;
    box-shadow: 0 18px 50px -24px rgba(15, 23, 42, 0.28), 0 8px 20px -14px rgba(15, 23, 42, 0.16);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transform-origin: top left;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    z-index: 999;
}

.mega-menu-wrapper:hover .mega-menu-dropdown,
.mega-menu-wrapper:focus-within .mega-menu-dropdown,
.mega-menu-wrapper.is-open .mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.mega-menu-dropdown--compact {
    width: max-content;
    min-width: 250px;
    max-width: min(320px, calc(100vw - 2rem));
    max-height: none;
    overflow: visible;
    padding: 0.5rem;
}

.mega-menu-panel {
    min-width: 0;
}

.mega-menu-quick-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.2rem;
}

.mega-menu-quick-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    padding: 0.5rem 0.55rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    text-decoration: none;
    transition: background 0.14s ease, color 0.14s ease;
}

.mega-menu-quick-link:hover {
    background: #f8fafc;
    border-color: transparent;
    color: var(--mega-primary, #0f49bd);
}

.mega-menu-quick-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border-radius: 8px;
    color: var(--mega-primary, #0f49bd);
    font-size: 13px;
}

.mega-menu-quick-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mega-menu-quick-arrow {
    flex-shrink: 0;
    color: #cbd5e1;
    font-size: 10px;
    transition: color 0.14s ease, transform 0.14s ease;
}

.mega-menu-quick-link:hover .mega-menu-quick-arrow {
    color: var(--mega-primary, #0f49bd);
    transform: translateX(2px);
}

.mega-menu-dropdown--compact .mega-menu-panel {
    min-width: 0;
}

.mega-menu-dropdown--compact .mega-menu-quick-grid {
    grid-template-columns: 1fr;
}

.mega-menu-dropdown--compact .mega-menu-quick-link {
    padding: 0.5rem 0.55rem;
    background: transparent;
    border-color: transparent;
}

.mega-menu-dropdown--compact .mega-menu-quick-link:hover {
    background: #f8fafc;
    border-color: transparent;
}

.mega-menu-chevron {
    transition: transform 0.18s ease;
}

.mega-menu-wrapper:hover .mega-menu-chevron,
.mega-menu-wrapper:focus-within .mega-menu-chevron,
.mega-menu-wrapper.is-open .mega-menu-chevron {
    transform: rotate(180deg);
}

.mega-menu-dropdown::-webkit-scrollbar {
    width: 5px;
}

.mega-menu-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.mega-menu-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.dark .mega-menu-dropdown {
    background: #111827;
    border-color: #1f2937;
    box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.6), 0 8px 20px -14px rgba(0, 0, 0, 0.45);
    scrollbar-color: #334155 transparent;
}

.dark .mega-menu-quick-link {
    background: transparent;
    border-color: transparent;
    color: #cbd5e1;
}

.dark .mega-menu-quick-link:hover {
    background: #1e293b;
    border-color: transparent;
    color: #93c5fd;
}

.dark .mega-menu-quick-icon {
    background: #1e293b;
    color: #93c5fd;
}

.dark .mega-menu-quick-arrow {
    color: #475569;
}

.dark .mega-menu-quick-link:hover .mega-menu-quick-arrow {
    color: #93c5fd;
}

.dark .mega-menu-dropdown--compact .mega-menu-quick-link {
    background: transparent;
    border-color: transparent;
}

.dark .mega-menu-dropdown--compact .mega-menu-quick-link:hover {
    background: #1e293b;
    border-color: transparent;
}

.dark .mega-menu-dropdown::-webkit-scrollbar-thumb {
    background: #334155;
}

@media (prefers-reduced-motion: reduce) {
    .mega-menu-dropdown,
    .mega-menu-trigger,
    .mega-menu-quick-link,
    .mega-menu-quick-arrow,
    .mega-menu-chevron {
        transition: none;
    }
}
