/* ============================================
   MODERN DROPDOWN NAVIGATION MENU
   Glassmorphism, Smooth Animations, Premium Design
   ============================================ */

.main-nav {
    margin-bottom: 40px;
    position: sticky;
    top: 20px;
    z-index: 1000;
    overflow: visible;
}

.nav-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: visible;
    margin-bottom: var(--spacing-xl);
    font-family: 'JetBrains Mono', monospace;
}



/* Search Bar */
.nav-search-wrapper {
    position: relative;
    width: 100%;
}

.nav-search {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: var(--shadow-inset-light);
}

.nav-search:focus {
    outline: 0;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-inset-light), 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.nav-search::placeholder {
    color: rgba(148, 163, 184, 0.6);
    font-weight: 400;
}

.nav-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.nav-search-clear:hover {
    background: rgba(255, 59, 48, 0.3);
    color: #ff3b30;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}

/* Dropdown Menu Container */
.nav-dropdown-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

/* Dropdown */
.nav-dropdown {
    position: relative;
    z-index: 1;
}

/* Ensure dropdowns don't get cut off */
.nav-wrapper {
    overflow: visible;
}

.nav-dropdown-toggle {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--text-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 600;
    position: relative;
    box-shadow: var(--shadow-sm);
    line-height: 1.5;
    letter-spacing: 0.02em;
}

.nav-dropdown-toggle::before {
    content: '> ';
    color: var(--primary-color);
    font-weight: bold;
}

.nav-dropdown-toggle:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-color);
    border-left-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.2);
    transform: translateX(4px);
}

.nav-dropdown-toggle.active {
    background: var(--primary-light);
    border-color: var(--primary-color);
    border-left-color: var(--secondary-color);
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.nav-dropdown-icon {
    font-size: 1.4em;
    filter: grayscale(70%) brightness(0.9);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

.nav-dropdown-toggle:hover .nav-dropdown-icon,
.nav-dropdown-toggle.active .nav-dropdown-icon {
    filter: grayscale(0%);
}

.nav-dropdown-text {
    flex: 1;
    text-align: left;
    position: relative;
    z-index: 1;
    transition: color 0.15s ease-in-out;
}

.nav-dropdown-toggle:hover .nav-dropdown-text,
.nav-dropdown-toggle.active .nav-dropdown-text {
    color: var(--primary-color);
}

.nav-dropdown-arrow {
    font-size: 0.875rem;
    transition: transform 0.15s ease-in-out;
    position: relative;
    z-index: 1;
    color: var(--text-secondary);
    font-weight: normal;
}

.nav-dropdown-toggle:hover .nav-dropdown-arrow {
    color: var(--primary-color);
}

.nav-dropdown-toggle.active .nav-dropdown-arrow {
    transform: rotate(180deg);
    color: var(--primary-color);
}

/* Dropdown Content */
.nav-dropdown-content {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    width: 100%;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: all 0.15s ease-in-out;
    z-index: 10000;
    display: block;
    pointer-events: none;
}

.nav-dropdown.active .nav-dropdown-content {
    max-height: 600px;
    padding: 12px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Dropdown Items */
.nav-dropdown-item {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    text-align: left;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.nav-dropdown-item::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform 0.2s ease;
    transform-origin: bottom;
}

.nav-dropdown-item:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.nav-dropdown-item:hover::before {
    opacity: 1;
}

.nav-dropdown-item:hover::after {
    transform: scaleY(1);
    transform-origin: top;
}

.nav-dropdown-item.active {
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
    box-shadow: var(--shadow-md);
    color: var(--primary-color);
}

.nav-dropdown-item.active::before {
    opacity: 1;
}

.nav-dropdown-item.active::after {
    transform: scaleY(1);
    width: 4px;
}

.nav-dropdown-item .nav-icon {
    font-size: 1.25em;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.nav-dropdown-item .nav-text {
    flex: 1;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.nav-dropdown-item:hover .nav-text,
.nav-dropdown-item.active .nav-text {
    color: var(--primary-color);
}

/* Tooltip */
.nav-dropdown-item[data-title]:hover::after {
    content: attr(data-title) '\A' attr(data-desc);
    position: absolute;
    left: calc(100% + 15px);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    white-space: pre-line;
    text-align: left;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    pointer-events: none;
    z-index: 1001;
    box-shadow: var(--shadow-lg);
    max-width: 220px;
    line-height: 1.5;
    font-weight: 500;
}

.nav-dropdown-item[data-title]:hover::before {
    content: '';
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--border-color);
    z-index: 1002;
}

/* Hidden items (for search filter) */
.nav-dropdown-item.hidden {
    display: none;
}

.nav-dropdown.hidden {
    display: none;
}

/* No Results Message */
.nav-no-results {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: #94a3b8;
    font-size: 1em;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 2px dashed rgba(148, 163, 184, 0.3);
}

.nav-no-results-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.6;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* ============================================
   RESPONSIVE MODERN NAVIGATION
   ============================================ */

/* Tablet */
@media screen and (max-width: 1024px) {
    .main-nav {
        margin-bottom: 30px;
        top: 10px;
    }

    .nav-wrapper {
        padding: 16px;
        gap: 14px;
    }

    .nav-dropdown-menu {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .nav-dropdown-toggle {
        padding: 14px 18px;
        font-size: 0.9em;
    }

    .nav-dropdown-content {
        max-height: 500px;
    }

    .nav-dropdown-item {
        padding: 12px 14px;
        font-size: 0.85em;
    }
}

/* Mobile Landscape */
@media screen and (max-width: 768px) {
    .main-nav {
        position: relative;
        top: 0;
        margin-bottom: var(--spacing-lg);
        overflow: visible;
    }

    .nav-wrapper {
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
        border-radius: var(--radius-md);
        overflow: visible;
    }

    .nav-search {
        padding: 0.875rem 2.5rem 0.875rem 1rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .nav-dropdown-menu {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .nav-dropdown {
        overflow: visible;
    }

    .nav-dropdown-toggle {
        padding: 1rem;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .nav-dropdown-content {
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 0;
        right: 0;
        margin-top: 0;
        max-height: 400px;
        overflow-y: auto;
        border-radius: var(--radius-md);
        padding: var(--spacing-sm);
    }

    .nav-dropdown-item {
        padding: 1rem;
        font-size: 0.95rem;
        min-height: 48px;
    }

    .nav-dropdown-content::-webkit-scrollbar {
        width: 6px;
    }

    .nav-dropdown-content::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 3px;
    }

    .nav-dropdown-content::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 3px;
    }

    .nav-dropdown-content::-webkit-scrollbar-thumb:hover {
        background: var(--primary-color);
    }

    /* Hide tooltips on mobile */
    .nav-dropdown-item[data-title]:hover::after,
    .nav-dropdown-item[data-title]:hover::before {
        display: none;
    }
}

/* Mobile Portrait */
@media screen and (max-width: 480px) {
    .nav-wrapper {
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .nav-search {
        padding: 0.75rem 2.5rem 0.75rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
    }

    .nav-dropdown-toggle {
        padding: 0.875rem;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .nav-dropdown-icon {
        font-size: 1.25em;
    }

    .nav-dropdown-arrow {
        font-size: 0.75em;
    }

    .nav-dropdown-content {
        max-height: 350px;
        padding: var(--spacing-xs);
        border-radius: var(--radius-md);
    }

    .nav-dropdown-item {
        padding: 0.875rem;
        font-size: 0.9rem;
        gap: 0.75rem;
        min-height: 44px;
    }

    .nav-dropdown-item .nav-icon {
        font-size: 1.2em;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .nav-dropdown-toggle {
        min-height: 50px;
    }

    .nav-dropdown-item {
        min-height: 50px;
    }

    .nav-dropdown-toggle:hover {
        transform: none;
    }

    .nav-dropdown-item:hover {
        transform: none;
    }

    .nav-dropdown-toggle:active {
        transform: scale(0.98);
        background: var(--primary-light);
    }

    .nav-dropdown-item:active {
        transform: scale(0.98);
        background: var(--primary-light);
    }
}

/* Dark Mode Enhancements */
@media (prefers-color-scheme: dark) {
    .nav-wrapper {
        background: var(--card-bg);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .nav-dropdown-toggle,
    .nav-dropdown-item {
        border-width: 3px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .nav-dropdown-toggle,
    .nav-dropdown-item,
    .nav-dropdown-content,
    .nav-dropdown-arrow {
        transition: none;
    }
    
    .nav-dropdown-toggle:hover,
    .nav-dropdown-item:hover {
        transform: none;
    }
}
