/* Enhanced Header & Navigation Styles */
header {
    background-color: rgba(14, 14, 14, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 15px 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: var(--z-header);
    transition: var(--transition-smooth);
    border-bottom: 1px solid rgba(196, 30, 30, 0.1);
    will-change: transform, background-color;
}

header.scrolled {
    background-color: rgba(10, 10, 10, 0.98);
    padding: 10px 0;
    border-bottom: 1px solid rgba(196, 30, 30, 0.2);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 2;
}

.logo img {
    height: 50px;
    transition: var(--transition-smooth);
    will-change: height;
}

header.scrolled .logo img {
    height: 45px;
}

/* Main Navigation */
.main-nav {
    display: flex;
    align-items: center;
}

.nav-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 1rem 0;
    position: relative;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--accent-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav-link:hover::after,
.nav-item.current .nav-link::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Dropdown Styles */
.dropdown {
    position: relative;
}

.dropdown-trigger {
    cursor: pointer;
}

.dropdown-icon {
    margin-left: 8px;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* Limit rotation to top-level dropdown arrow only */
.nav-item.dropdown:hover > a .dropdown-icon,
.nav-item.dropdown.active > a .dropdown-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--secondary-color);
    min-width: 280px;
    box-shadow: var(--shadow-strong);
    border-radius: 8px;
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    border: 1px solid rgba(196, 30, 30, 0.2);
    z-index: 1000;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu li a {
    display: block;
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    transition: var(--transition-smooth);
    font-size: 0.95rem;
    position: relative;
    border-left: 3px solid transparent;
}

.dropdown-menu li a:hover {
    background: rgba(196, 30, 30, 0.1);
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    transform: translateX(5px);
}

.dropdown-menu li a::after {
    display: none;
}

/* Nested submenu and two-column layout */
.dropdown-submenu {
    position: relative;
}

@media (min-width: 769px) {
    .dropdown-submenu > .dropdown-menu {
        top: 0;
        left: 100%;
        margin-left: 6px;
        min-width: 280px;
    }

    .dropdown-menu.menu-2col {
        display: block;
        padding: 0.75rem 1rem;
    }

    .dropdown-menu.menu-2col li a {
        padding: 0.6rem 0.75rem;
    }
}

@media (max-width: 768px) {
    .dropdown-menu.menu-2col {
        display: block;
        padding: 0;
    }
}

/* Enhanced Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.75rem;
    gap: 5px;
    z-index: 1001;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    border-radius: 8px;
    position: relative;
}


.mobile-menu-toggle span {
    width: 28px;
    height: 3px;
    background: var(--text-color);
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    border-radius: 2px;
    transform-origin: center;
    position: relative;
    z-index: 1;
}

.mobile-menu-toggle:hover {
    background: rgba(196, 30, 30, 0.1);
}

.mobile-menu-toggle:hover span {
    background: var(--accent-color);
    transform: scale(1.1);
}

.mobile-menu-toggle.active {
    background: rgba(196, 30, 30, 0.1);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
    background: var(--accent-color);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-30px) scale(0);
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -7px);
    background: var(--accent-color);
}

/* Mobile toggle animation enhancement */
@media (max-width: 1100px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .mobile-menu-toggle:focus {
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }
}

/* Header Contact */
.header-contact {
    display: flex;
    align-items: center;
    color: var(--text-color);
    margin-left: 2rem;
}

.contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.contact-icon i {
    color: var(--accent-color);
    font-size: 1.2rem;
}

.contact-text {
    display: flex;
    flex-direction: column;
}

.contact-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.contact-text a {
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition-smooth);
    font-weight: 500;
    font-size: 0.95rem;
}

.contact-text a:hover {
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .nav-menu {
        gap: 1.5rem;
    }

    .header-contact {
        margin-left: 1rem;
    }
}

@media (max-width: 991px) {
    .header-contact {
        display: none;
    }

    .nav-menu {
        gap: 1rem;
    }
}

@media (max-width: 1100px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: linear-gradient(135deg, rgba(14, 14, 14, 0.98) 0%, rgba(20, 20, 20, 0.95) 100%);
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
        z-index: 999;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-nav.active {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 6rem 0 2rem;
        justify-content: flex-start;
        align-items: stretch;
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        position: relative;
    }

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

    .nav-link {
        padding: 1.5rem 2rem;
        justify-content: space-between;
        font-size: 1.2rem;
        font-weight: 500;
        color: var(--text-color);
        position: relative;
        transition: all 0.3s ease;
        border-left: 4px solid transparent;
    }

    .nav-link:hover {
        background: rgba(196, 30, 30, 0.1);
        color: var(--accent-color);
        border-left-color: var(--accent-color);
        transform: translateX(8px);
    }

    .nav-link::after {
        display: none;
    }

    /* Enhanced Mobile Dropdowns */
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.4);
        margin: 0;
        border-radius: 0;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        max-height: 0;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
        padding: 0;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .dropdown.active .dropdown-menu {
        max-height: 500px;
        padding: 1.5rem 0;
    }

    .dropdown-menu li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .dropdown-menu li:last-child {
        border-bottom: none;
    }

    .dropdown-menu li a {
        padding: 1.2rem 3rem;
        color: rgba(255, 255, 255, 0.85);
        font-size: 1.1rem;
        border-left: none;
        border-bottom: none;
        position: relative;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .dropdown-menu li a:hover {
        background: rgba(196, 30, 30, 0.15);
        color: var(--accent-color);
        transform: translateX(12px);
        padding-left: 3.5rem;
    }

    .dropdown-menu li a::before {
        content: '→';
        position: absolute;
        left: 2rem;
        opacity: 0;
        transform: translateX(-10px);
        transition: all 0.3s ease;
        color: var(--accent-color);
    }

    .dropdown-menu li a:hover::before {
        opacity: 1;
        transform: translateX(0);
    }

    /* Nested submenu styling for mobile */
    .dropdown-submenu .dropdown-menu {
        background: rgba(0, 0, 0, 0.6);
        margin-left: 1rem;
        border-left: 2px solid rgba(196, 30, 30, 0.3);
        border-radius: 0 8px 8px 0;
    }

    .dropdown-submenu .dropdown-menu li a {
        padding-left: 2.5rem;
        font-size: 1rem;
        color: rgba(255, 255, 255, 0.75);
    }

    /* Prevent body scroll when menu is open */
    body.nav-open {
        overflow: hidden;
    }

}

@media (max-width: 480px) {
    .header-container {
        padding: 0 1rem;
    }

    .logo img {
        height: 40px;
    }

    header.scrolled .logo img {
        height: 35px;
    }

    .nav-menu {
        padding: 5rem 1rem 2rem;
    }

    .nav-link {
        font-size: 1.1rem;
        padding: 1.25rem 1.5rem;
    }

    .dropdown-menu li a {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    .dropdown-submenu .dropdown-menu li a {
        padding-left: 2rem;
        font-size: 0.95rem;
    }

    /* Better touch targets for mobile */
    .mobile-menu-toggle {
        padding: 1rem;
        min-width: 44px;
        min-height: 44px;
    }

    .nav-link {
        min-height: 60px;
        display: flex;
        align-items: center;
    }

    .dropdown-menu li a {
        min-height: 50px;
        display: flex;
        align-items: center;
    }
}

/* Mobile-specific enhancements */
@media (max-width: 1100px) {
    /* Smooth scrolling for mobile menu */
    .main-nav {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Enhanced mobile menu backdrop */
    .main-nav.active::before {
        background: linear-gradient(180deg, 
            rgba(196, 30, 30, 0.15) 0%, 
            rgba(196, 30, 30, 0.05) 30%, 
            transparent 60%, 
            rgba(0, 0, 0, 0.4) 100%);
    }

    /* Mobile menu scroll indicator */
    .main-nav::-webkit-scrollbar {
        width: 4px;
    }

    .main-nav::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }

    .main-nav::-webkit-scrollbar-thumb {
        background: var(--accent-color);
        border-radius: 2px;
    }

    /* Mobile menu item animations */
    .nav-item {
        animation: slideInFromLeft 0.5s ease forwards;
        opacity: 0;
        transform: translateX(-20px);
    }

    .nav-item:nth-child(1) { animation-delay: 0.1s; }
    .nav-item:nth-child(2) { animation-delay: 0.15s; }
    .nav-item:nth-child(3) { animation-delay: 0.2s; }
    .nav-item:nth-child(4) { animation-delay: 0.25s; }
    .nav-item:nth-child(5) { animation-delay: 0.3s; }

    @keyframes slideInFromLeft {
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* Mobile dropdown arrow animations */
    .dropdown-icon {
        transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .dropdown.active .dropdown-icon {
        transform: rotate(180deg);
        color: var(--accent-color);
    }

    /* Mobile menu loading state */
    .main-nav.loading {
        opacity: 0.7;
        pointer-events: none;
    }

    /* Mobile menu search functionality (if needed) */
    .mobile-search {
        padding: 1rem 2rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 1rem;
    }

    .mobile-search input {
        width: 100%;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        padding: 0.75rem 1rem;
        color: var(--text-color);
        font-size: 1rem;
    }

    .mobile-search input::placeholder {
        color: rgba(255, 255, 255, 0.5);
    }

    .mobile-search input:focus {
        outline: none;
        border-color: var(--accent-color);
        background: rgba(255, 255, 255, 0.15);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .nav-link::after,
    .dropdown-menu,
    .mobile-menu-toggle span,
    .nav-item {
        transition: none;
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nav-link {
        border: 1px solid transparent;
    }

    .nav-link:focus {
        border-color: var(--accent-color);
        outline: 2px solid var(--accent-color);
        outline-offset: 2px;
    }

    .mobile-menu-toggle:focus {
        outline: 3px solid var(--accent-color);
        outline-offset: 3px;
    }
}

/* Dark mode optimizations for mobile */
@media (max-width: 1100px) and (prefers-color-scheme: dark) {
    .main-nav {
        background: linear-gradient(135deg, rgba(5, 5, 5, 0.98) 0%, rgba(10, 10, 10, 0.95) 100%);
    }

    .dropdown-menu {
        background: rgba(0, 0, 0, 0.6);
    }

    .dropdown-submenu .dropdown-menu {
        background: rgba(0, 0, 0, 0.8);
    }
}

/* Submenu trigger arrow placement and independent rotation */
.dropdown-menu .dropdown-submenu > a.nav-link {
    justify-content: space-between;
    width: 100%;
}

.dropdown-menu .dropdown-submenu > a .dropdown-icon {
    margin-left: 12px;
    transform: rotate(0deg);
    transition: transform 0.25s ease;
}

.dropdown-submenu:hover > a .dropdown-icon,
.dropdown-submenu:focus-within > a .dropdown-icon {
    transform: rotate(180deg);
}