/**
 * Enhanced Desktop Menu Styles
 * Last updated: 2025-01-27
 * Author: GaryH
 * Related scripts: define_header_main_menu.php, modern_header.css
 * Summary: Modern, responsive desktop navigation menu with enhanced dropdowns and animations
 */

/* Modern Desktop Navigation Base Styles */
.modern-desktop-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    list-style: none;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* Navigation Items */
.modern-desktop-nav .nav-item {
    position: relative;
    margin: 0;
    padding: 0;
}

/* Navigation Links */
.modern-desktop-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 16px 22px;
    color: rgba(255,255,255,0.98);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.2px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 3px solid transparent;
    position: relative;
    white-space: nowrap;
}

.modern-desktop-nav .nav-link i {
    margin-right: 8px;
    font-size: 16px;
    transition: transform 0.3s ease;
}

.modern-desktop-nav .nav-link span {
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Hover Effects */
.modern-desktop-nav .nav-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.15);
    border-bottom-color: #00d4ff;
    transform: translateY(-2px);
}

.modern-desktop-nav .nav-link:hover i {
    transform: scale(1.1);
}

/* Active State */
.modern-desktop-nav .nav-item.active .nav-link {
    color: #ffffff;
    background: rgba(255,255,255,0.2);
    border-bottom-color: #00d4ff;
}

/* Dropdown Arrow */
.dropdown-arrow {
    margin-left: 8px !important;
    margin-right: 0 !important;
    font-size: 12px !important;
    transition: transform 0.3s ease;
}

.has-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

/* Enhanced Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: 480px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}

.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Dropdown Content */
.dropdown-content {
    padding: 0;
}

/* Dropdown Header */
.dropdown-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 16px 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.dropdown-header .view-all {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.dropdown-header .view-all:hover {
    color: #0056b3;
}

.dropdown-header .view-all i {
    margin-left: 6px;
    font-size: 12px;
}

/* Dropdown Grid */
.dropdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    padding: 8px 0;
    max-height: 400px;
    overflow-y: auto;
}

/* Special grid for brands */
.brands-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* Dropdown Items */
.dropdown-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f8f9fa;
    position: relative;
}

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

.dropdown-item i {
    margin-right: 12px;
    font-size: 14px;
    color: #6c757d;
    width: 16px;
    text-align: center;
    transition: color 0.2s ease;
}

.dropdown-item span {
    font-weight: 400;
    font-size: 14px;
    line-height: 1.4;
}

/* Dropdown Item Hover */
.dropdown-item:hover {
    background: #f8f9fa;
    color: #007bff;
    padding-left: 25px;
}

.dropdown-item:hover i {
    color: #007bff;
    transform: scale(1.1);
}

/* Special styling for "More" items */
.dropdown-item.more-items {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1976d2;
    font-weight: 500;
    border-top: 1px solid #e1f5fe;
}

.dropdown-item.more-items:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    color: #0d47a1;
}

/* Home Item Special Styling */
.home-item .nav-link {
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    margin: 4px;
}

.home-item .nav-link:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px) scale(1.05);
}

/* Contact Us Special Styling */
.contact-us .nav-link {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-radius: 6px;
    margin: 4px;
    color: #ffffff !important;
}

.contact-us .nav-link:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-2px) scale(1.05);
    border-bottom-color: transparent;
}

/* Shopping Cart Mobile Only */
.shopping-cart.mobile-only {
    display: none;
}

.shopping-cart .cart-total {
    background: #dc3545;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* Responsive Design */
@media (max-width: 1199px) {
    .modern-desktop-nav {
        flex-direction: column;
        border-radius: 0;
    }
    
    .modern-desktop-nav .nav-item {
        width: 100%;
    }
    
    .modern-desktop-nav .nav-link {
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .dropdown-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
        border-radius: 0;
        margin: 0;
        display: none;
    }
    
    .has-dropdown.active .dropdown-menu {
        display: block;
    }
    
    .shopping-cart.mobile-only {
        display: block;
        border-top: 2px solid rgba(255,255,255,0.2);
    }
}

@media (max-width: 768px) {
    .modern-desktop-nav .nav-link {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .dropdown-grid {
        grid-template-columns: 1fr;
    }
    
    .dropdown-item {
        padding: 14px 16px;
        font-size: 16px;
    }
}

/* Animation for menu appearance */
@keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modern-desktop-nav {
    animation: slideInFromTop 0.5s ease-out;
}

/* Accessibility Improvements */
.modern-desktop-nav .nav-link:focus,
.dropdown-item:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modern-desktop-nav {
        background: #000000;
        border: 2px solid #ffffff;
    }
    
    .modern-desktop-nav .nav-link {
        color: #ffffff;
        border: 1px solid transparent;
    }
    
    .modern-desktop-nav .nav-link:hover {
        border-color: #ffffff;
        background: #333333;
    }
    
    .dropdown-menu {
        background: #ffffff;
        border: 2px solid #000000;
    }
    
    .dropdown-item {
        color: #000000;
        border-bottom: 1px solid #cccccc;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modern-desktop-nav .nav-link,
    .dropdown-menu,
    .dropdown-item {
        transition: none;
    }
    
    .modern-desktop-nav {
        animation: none;
    }
}

/* Integration with existing menu system */
#cssmenu .modern-desktop-nav {
    width: 100%;
    max-width: none;
}

/* Override mobile menu plus signs for enhanced menu */
.modern-desktop-nav .nav-link:after,
.modern-desktop-nav .nav-link:before,
.modern-desktop-nav .nav-item:after,
.modern-desktop-nav .nav-item:before,
.modern-desktop-nav li:after,
.modern-desktop-nav li:before,
.modern-desktop-nav a:after,
.modern-desktop-nav a:before {
    content: none !important;
    display: none !important;
}

/* Prevent submenu buttons from being added to enhanced menu */
.modern-desktop-nav .submenu-button {
    display: none !important;
}

/* Ensure our dropdown arrows are used instead */
.modern-desktop-nav .dropdown-arrow {
    display: inline-block !important;
}

/* Override existing menu styles when using enhanced menu */
.nav-maincontainer .modern-desktop-nav {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 8px;
    margin: 10px 0;
}

/* Ensure compatibility with existing responsive framework */
@media (max-width: 1199px) {
    .nav-maincontainer .modern-desktop-nav {
        margin: 0;
        border-radius: 0;
    }
}

/* Touch device optimizations */
.touch-device .modern-desktop-nav .nav-link {
    padding: 18px 20px;
    min-height: 48px; /* Minimum touch target size */
}

.touch-device .dropdown-item {
    padding: 16px 20px;
    min-height: 48px;
}

.touch-device .modern-desktop-nav .nav-link.touch-active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.98);
}

/* Print styles */
@media print {
    .modern-desktop-nav {
        display: none !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dropdown-menu {
        background: #2c3e50;
        border-color: #34495e;
    }
    
    .dropdown-header {
        background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
        border-bottom-color: #4a5f7a;
    }
    
    .dropdown-header h4 {
        color: #ecf0f1;
    }
    
    .dropdown-item {
        color: #ecf0f1;
        border-bottom-color: #34495e;
    }
    
    .dropdown-item:hover {
        background: #34495e;
        color: #3498db;
    }
}

/* Screen reader accessibility */
.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;
}

/* Focus indicators for better accessibility */
.modern-desktop-nav .nav-link:focus-visible,
.dropdown-item:focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Loading state for dynamic content */
.dropdown-menu.loading {
    opacity: 0.7;
}

.dropdown-menu.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
