/* Header Submenu Styles - Multi-level Navigation (theme-aligned) */
:root {
    /* Fallbacks if styles.css isn't loaded first */
    --primary-color: #1e40af;
    --secondary-color: #dc2626;
    --accent-color: #059669;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f9fafb;
}

/* Main submenu container (Tailwind-like panel) */
.nav-menu-bar .group > div[class*="absolute"] {
    min-width: 200px;
    /* twin soft shadow similar to Tailwind's shadow-lg */
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -4px rgba(0, 0, 0, 0.1);
    border-radius: 8px; /* rounded-lg */
    overflow: hidden;
    background: #ffffff; /* light surface */
    border: 1px solid color-mix(in srgb, var(--primary-color) 8%, white); /* subtle tinted border */
}

/* Submenu items styling */
.nav-menu-bar .group a {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-direction: row;
    gap: 8px;
}

/* Ensure text container shrinks properly */
.nav-menu-bar .group a span {
    flex: 1 1 auto;
    min-width: 0; /* allow text ellipsis */
}

/* Submenu link colors on light panel (override top-level white) */
.nav-menu-bar .group > div[class*="absolute"] a {
    color: var(--text-dark);
}

/* Hover/active states similar to Tailwind */
.nav-menu-bar .group > div[class*="absolute"] a:hover {
    background-color: rgba(15, 23, 42, 0.06); /* ~slate-900 @ 6% */
    color: var(--primary-color);
}

.nav-menu-bar .group > div[class*="absolute"] a.active,
.nav-menu-bar .group > div[class*="absolute"] a[aria-current="page"] {
    background-color: rgba(30, 64, 175, 0.12); /* primary tint */
    color: var(--text-dark);
    font-weight: 600;
}

/* Add indicator for items with children: place chevron at end of the anchor so it's in-row */
.nav-menu-bar .group > div[class*="absolute"] .group > a::after {
    content: '›';
    font-size: 1rem;
    line-height: 1;
    margin-left: 12px;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-menu-bar .group > div[class*="absolute"] .group:hover > a::after,
.nav-menu-bar .group > div[class*="absolute"] .group:focus-within > a::after {
    opacity: 1;
}

/* Rotate chevron for nested hover to hint direction */
.nav-menu-bar .group > div[class*="absolute"] .group:hover > a::after,
.nav-menu-bar .group > div[class*="absolute"] .group:focus-within > a::after {
    transform: translateX(2px);
}

/* Nested submenu positioning */
.nav-menu-bar .group > div[class*="absolute"] .group > div[class*="absolute"] {
    left: 100%;
    top: 0;
    margin-left: 0;
    margin-top: -8px;
}

/* Smooth transitions for nested menus */
.nav-menu-bar .group > div[class*="absolute"] {
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Hover state for submenu items */
.nav-menu-bar .group a:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Active/current page indicator */
.nav-menu-bar .group a.active,
.nav-menu-bar .group a[aria-current="page"] {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Remove duplicate block merged above */

/* Submenu item spacing */
.nav-menu-bar .group > div[class*="absolute"] > div {
    padding: 0;
}

.nav-menu-bar .group > div[class*="absolute"] > div > a {
    padding: 8px 12px; /* py-2 px-3 */
    font-size: 0.875rem; /* text-sm */
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reserve space on the right for chevron so text doesn't overlap */
.nav-menu-bar .group > div[class*="absolute"] .group > a {
    padding-right: 28px;
}

/* First and last item styling */
.nav-menu-bar .group > div[class*="absolute"] > div:first-child > a {
    border-radius: 8px 8px 0 0;
}

.nav-menu-bar .group > div[class*="absolute"] > div:last-child > a {
    border-radius: 0 0 8px 8px;
}

/* Separator between submenu items */
.nav-menu-bar .group > div[class*="absolute"] > div {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06); /* slate-200-ish */
}

.nav-menu-bar .group > div[class*="absolute"] > div:last-child {
    border-bottom: none;
}

/* Bilingual text handling */
.nav-menu-bar .group {
    display: inline;
}

.nav-menu-bar .group span.lang-ne.hidden {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .nav-menu-bar .group > div[class*="absolute"] {
        min-width: 180px;
    }

    .nav-menu-bar .group > div[class*="absolute"] > div > a {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }
}

/* Animation for submenu appearance */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-menu-bar .group:hover > div[class*="absolute"],
.nav-menu-bar .group:focus-within > div[class*="absolute"] {
    animation: slideInDown 0.2s ease forwards;
}

/* Nested submenu animation */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-menu-bar .group > div[class*="absolute"] .group:hover > div[class*="absolute"],
.nav-menu-bar .group > div[class*="absolute"] .group:focus-within > div[class*="absolute"] {
    animation: slideInRight 0.2s ease forwards;
}

/* Prevent text selection on menu items */
.nav-menu-bar .group a {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Focus states for accessibility */
.nav-menu-bar .group a:focus {
    outline: 2px solid color-mix(in srgb, var(--secondary-color), white 30%);
    outline-offset: -2px;
}

/* Background already set above to theme primary gradient */

/* Ensure proper stacking context */
.nav-menu-bar .group {
    position: relative;
    z-index: 1;
}

/* Hide submenus by default, show on hover (desktop) */
.nav-menu-bar .group > div[class*="absolute"] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.nav-menu-bar .group:hover > div[class*="absolute"],
.nav-menu-bar .group:focus-within > div[class*="absolute"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-menu-bar .group > div[class*="absolute"] {
    z-index: 50;
}

.nav-menu-bar .group > div[class*="absolute"] .group > div[class*="absolute"] {
    z-index: 51;
}

/* Prevent submenu from being cut off by parent overflow */
.nav-menu-bar {
    overflow: visible;
}

/* Smooth color transitions */
.nav-menu-bar .group a {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Icon styling for items with children (if using icons) */
.nav-menu-bar .group a .icon {
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
}

/* Truncate long menu item text */
.nav-menu-bar .group a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
