/* Mobile Navigation Styles - Updated for tablet portrait support */

/* Base mobile menu styles */
@media (max-width: 1024px) {
    /* Fix for top white space - Complete removal of padding/margin */
    body {
        padding-top: 0 !important; /* Force remove padding */
        margin-top: 0 !important; /* Force remove margin */
    }
    
    /* Header adjustments */
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        height: 70px;
    }
    
    /* Main content needs top padding to account for fixed header */
    #main-content, 
    .content-area {
        padding-top: 70px !important; /* Add padding to content, not body */
    }
    
    .header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        position: relative;
        width: 100%;
        height: 70px;
    }
    
    /* WHITE HAMBURGER MENU IN TOP LEFT */
    .menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        order: 1;
        margin-right: auto;
        position: relative;
    }
    
    /* Site branding in center */
    .site-branding {
        order: 2;
        flex: 1;
        display: flex;
        justify-content: center;
        z-index: 1000;
    }
    
    .site-branding .site-title a {
        color: #ffffff;
    }
    
    /* Main navigation hidden by default */
    .main-navigation {
        order: 3;
        flex: none;
        width: 0;
    }
    
    /* WHITE HAMBURGER LINES */
    .hamburger-line {
        width: 24px;
        height: 3px;
        background: #ffffff !important;
        border-radius: 2px;
        transition: all 0.3s ease;
        margin: 2px 0;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Hamburger animation - keep white color */
    .menu-toggle.active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
        background: #ffffff !important;
    }
    
    .menu-toggle.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    
    .menu-toggle.active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
        background: #ffffff !important;
    }
    
    /* Mobile navigation container */
    .nav-menu-wrapper {
        position: fixed;
        top: 70px;
        left: 0;
        width: 280px;
        height: calc(100vh - 70px);
        background: #ffffff;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        visibility: hidden;
    }
    
    /* Show mobile menu when active */
    .menu-open .nav-menu-wrapper,
    .mobile-menu-active .nav-menu-wrapper {
        transform: translateX(0);
        visibility: visible;
    }
    
    /* Mobile menu list */
    .nav-menu {
        list-style: none;
        margin: 0;
        padding: 20px 0;
        display: flex !important;
        flex-direction: column;
        gap: 0;
        width: 100%;
    }
    
    /* Primary menu items */
    .nav-menu > li {
        display: block !important;
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
    }
    
    .nav-menu > li:last-child {
        border-bottom: none;
    }
    
    /* Clean primary menu links */
    .nav-menu > li > a {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important; /* Changed from space-between to flex-start */
        padding: 16px 24px;
        color: #2c3e50;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        transition: all 0.3s ease;
        border: none !important;
        background: transparent !important;
        position: relative;
        width: 100%;
        box-sizing: border-box;
        cursor: pointer;
    }
    
    /* Menu items with children need dropdown indicator */
    .nav-menu > li.menu-item-has-children > a,
    .nav-menu > li.has-dropdown > a {
        padding-right: 50px !important;
    }
    
    /* FIX: Triangle positioned directly after menu text */
    .nav-menu > li.menu-item-has-children > a::after,
    .nav-menu > li.has-dropdown > a::after {
        content: '' !important;
        position: relative !important; /* Changed from absolute to relative */
        display: inline-block !important;
        margin-left: 10px !important; /* Add margin to separate from text */
        right: auto !important; /* Remove fixed right positioning */
        top: 0 !important; /* Reset top value */
        transform: none !important; /* Reset transform */
        width: 0 !important;
        height: 0 !important;
        border-left: 6px solid transparent !important;
        border-right: 6px solid transparent !important;
        border-top: 8px solid #000000 !important; /* Changed color to black */
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        opacity: 1 !important;
        pointer-events: none !important; /* Prevent interference with clicks */
        vertical-align: middle !important; /* Align with text */
    }
    
    /* Rotate and change color when submenu is open */
    .nav-menu > li.menu-item-has-children.submenu-open > a::after,
    .nav-menu > li.has-dropdown.submenu-open > a::after {
        transform: rotate(180deg) !important; /* Remove translateY, just rotate */
        border-top-color: #007cba !important;
    }
    
    /* Clean hover states for primary items */
    .nav-menu > li > a:hover {
        background: #f8f9fa !important;
        color: #007cba;
        transform: none;
    }
    
    /* Current menu item styling */
    .nav-menu .current-menu-item > a,
    .nav-menu .current-menu-parent > a,
    .nav-menu .current-menu-ancestor > a {
        background: #e8f4f8 !important;
        color: #007cba;
        font-weight: 600;
    }
    
    /* IMPROVED submenu/dropdown handling with smooth animations */
    .nav-menu ul,
    .nav-menu .dropdown-menu,
    .nav-menu ul ul {
        position: static !important;
        box-shadow: none !important;
        background: #f8f9fa !important;
        border: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow: hidden !important;
        max-height: 0 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        list-style: none !important;
        transform: translateY(-10px) !important;
    }
    
    /* Show submenu when parent is open with smooth animation */
    .nav-menu > li.submenu-open > ul,
    .nav-menu > li.submenu-open > .dropdown-menu {
        max-height: 500px !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }
    
    /* Nested menu items styling with improved animation */
    .nav-menu ul li,
    .nav-menu .dropdown-menu li {
        display: block !important;
        width: 100% !important;
        border-bottom: 1px solid #e8e8e8 !important;
        background: #f8f9fa !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
        opacity: 0 !important;
        transform: translateX(-20px) !important;
        transition: all 0.3s ease !important;
        animation: slideInFromLeft 0.3s ease forwards !important;
    }
    
    /* FIX: Ensure submenu items are visible when parent is opened */
    .nav-menu > li.submenu-open ul li,
    .nav-menu > li.submenu-open .dropdown-menu li {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateX(0) !important;
    }
    
    /* Staggered animation for menu items */
    .nav-menu > li.submenu-open ul li:nth-child(1) { animation-delay: 0.1s !important; }
    .nav-menu > li.submenu-open ul li:nth-child(2) { animation-delay: 0.15s !important; }
    .nav-menu > li.submenu-open ul li:nth-child(3) { animation-delay: 0.2s !important; }
    .nav-menu > li.submenu-open ul li:nth-child(4) { animation-delay: 0.25s !important; }
    .nav-menu > li.submenu-open ul li:nth-child(5) { animation-delay: 0.3s !important; }
    
    @keyframes slideInFromLeft {
        to {
            opacity: 1 !important;
            transform: translateX(0) !important;
        }
    }
    
    .nav-menu ul li:last-child,
    .nav-menu .dropdown-menu li:last-child {
        border-bottom: none !important;
    }
    
    /* FIX: Submenu links styling with improved visible text */
    .nav-menu ul a,
    .nav-menu .dropdown-menu a {
        display: block !important;
        padding: 14px 24px 14px 40px !important;
        color: #000000 !important; /* Keep black for better visibility */
        font-size: 15px !important;
        background: transparent !important;
        text-decoration: none !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border: none !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: relative !important;
        font-weight: 400 !important;
        opacity: 1 !important; /* Ensure visibility */
        visibility: visible !important; /* Ensure visibility */
    }
    
    .nav-menu ul a:hover,
    .nav-menu .dropdown-menu a:hover {
        background: #e8f4f8 !important;
        color: #007cba !important;
        transform: translateX(8px) !important;
    }
    
    /* Third level menus (if any) - black text color */
    .nav-menu ul ul a {
        padding-left: 60px !important;
        color: #000000 !important; /* Changed to black for consistency */
        font-size: 14px !important;
    }
    
    /* Remove any unwanted pseudo-elements */
    .nav-menu a::before,
    .nav-menu ul a::before,
    .nav-menu ul a::after {
        display: none !important;
        content: none !important;
    }
    
    /* Clean focus states */
    .nav-menu a:focus {
        outline: 2px solid #007cba;
        outline-offset: -2px;
        background: #e8f4f8 !important;
    }
    
    /* Screen reader text */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
        white-space: nowrap;
        border: 0;
    }
    
    /* Body scroll lock when menu is open */
    .menu-open,
    .mobile-menu-active {
        overflow: hidden;
    }
    
    /* Clean overlay with improved animation */
    .menu-open::before,
    .mobile-menu-active::before {
        content: '';
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        background: rgba(0,0,0,0.3);
        z-index: 998;
        opacity: 0;
        animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }
    
    @keyframes fadeIn {
        to {
            opacity: 1;
        }
    }
}

/* Specific resolution fixes for Laptop and Fold devices */
@media screen and (width: 900px) and (height: 1440px),
       screen and (width: 950px) and (height: 1280px),
       screen and (width: 853px) and (height: 1280px) {
    
    /* Ensure hamburger menu is visible */
    .menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        order: 1;
        margin-right: auto;
        position: relative;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Fixed header positioning */
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        height: 70px !important;
    }
    
    /* Hamburger lines visible */
    .hamburger-line {
        width: 24px !important;
        height: 3px !important;
        background: #ffffff !important;
        border-radius: 2px !important;
        transition: all 0.3s ease !important;
        margin: 2px 0 !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Reset mobile menu to always be in mobile mode */
    .main-navigation {
        order: 3;
        flex: none;
        width: 0;
    }
    
    /* Ensure menu wrapper is properly positioned */
    .nav-menu-wrapper {
        position: fixed !important;
        top: 70px !important;
        left: 0 !important;
        width: 280px !important;
        height: calc(100vh - 70px) !important;
        background: #ffffff !important;
        box-shadow: 2px 0 15px rgba(0,0,0,0.1) !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 999 !important;
        overflow-y: auto !important;
        visibility: hidden !important;
    }

    /* Show mobile menu when active */
    .menu-open .nav-menu-wrapper,
    .mobile-menu-active .nav-menu-wrapper,
    .nav-menu-wrapper.active {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
    
    /* Body scroll lock when menu is open */
    .menu-open,
    .mobile-menu-active {
        overflow: hidden !important;
    }
}

/* Laptop with HiDpi Screen : 900x1440 specific adjustments */
@media screen and (width: 900px) and (height: 1440px) {
    /* Content padding adjustment for HiDPI screen */
    #main-content, 
    .content-area {
        padding-top: 70px !important; 
    }
    
    /* Ensure backdrop filter works on HiDPI */
    .site-header {
        -webkit-backdrop-filter: blur(10px) !important;
        backdrop-filter: blur(10px) !important;
    }
}

/* Laptop with touch: 950x1280 specific adjustments */
@media screen and (width: 950px) and (height: 1280px) {
    /* Improve touch targets for touch screen */
    .nav-menu > li > a {
        padding: 18px 24px !important;
    }
    
    /* Larger dropdown indicator for touch */
    .nav-menu > li.menu-item-has-children > a::after,
    .nav-menu > li.has-dropdown > a::after {
        border-left: 8px solid transparent !important;
        border-right: 8px solid transparent !important;
        border-top: 10px solid #000000 !important;
    }
}

/* Asus Zenbook Fold: 853x1280 specific adjustments */
@media screen and (width: 853px) and (height: 1280px) {
    /* Fold-specific styling */
    .header-container {
        max-width: 100% !important;
        padding: 0 15px !important;
    }
    
    /* Ensure menu animation is smooth on fold */
    .nav-menu-wrapper {
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    /* Improve animation performance on Fold */
    .nav-menu ul li,
    .nav-menu .dropdown-menu li {
        transition: all 0.4s ease !important;
    }
}

/* Desktop Navigation Styles */
@media (min-width: 1025px) {
    /* Hide hamburger menu on desktop */
    .menu-toggle {
        display: none !important;
    }
    
    /* Reset header for desktop */
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        height: 80px;
    }
    
    .header-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        height: 80px;
    }
    
    /* Desktop navigation positioning */
    .site-branding {
        order: 1;
        flex: none;
    }
    
    .site-branding .site-title a {
        color: #2c3e50;
    }
    
    .main-navigation {
        order: 2;
        flex: 1;
        display: flex;
        justify-content: center;
    }
    
    /* Reset navigation wrapper */
    .nav-menu-wrapper {
        position: static;
        width: auto;
        height: auto;
        background: transparent;
        box-shadow: none;
        transform: none;
        transition: none;
        z-index: auto;
        overflow: visible;
        visibility: visible;
        padding: 0;
    }
    
    /* Desktop menu layout */
    .nav-menu {
        display: flex !important;
        flex-direction: row;
        gap: 2rem;
        align-items: center;
        list-style: none;
        margin: 0;
        padding: 0;
    }
    
    .nav-menu li {
        display: block !important;
        width: auto;
        border-bottom: none;
        position: relative;
    }
    
    .nav-menu a {
        display: flex !important;
        align-items: center;
        padding: 12px 16px;
        color: #2c3e50;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        border-radius: 8px;
        transition: all 0.3s ease;
        width: auto;
    }
    
    .nav-menu a:hover {
        color: #3498db;
        background: rgba(52, 152, 219, 0.1);
        transform: translateY(-1px);
    }
    
    /* Desktop dropdown functionality */
    .nav-menu .dropdown-menu,
    .nav-menu ul ul {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 220px;
        background: #000000; /* Changed from #ffffff to black */
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
        border-radius: 12px;
        padding: 8px 0;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        z-index: 1000;
    }
    
    /* Also update submenu link colors since the background is now black */
    .nav-menu .dropdown-menu a,
    .nav-menu ul ul a {
        color: #ffffff; /* Changed text color to white for better contrast */
    }
    
    .nav-menu .dropdown-menu a:hover,
    .nav-menu ul ul a:hover {
        background: rgba(52, 152, 219, 0.2); /* Slightly more visible hover state */
        color: #3498db;
    }
    
    .nav-menu li:hover > ul {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}