/* =================================================
   NAVIGATION CSS - Desktop and Mobile Menus
   Professional navigation system
   ================================================= */

/* Navigation Variables */
:root {
    --nav-bg: rgba(255, 255, 255, 0.98);
    --nav-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --nav-text: #2d3436;
    --nav-hover: #667eea;
    --nav-height: 70px;
}

/* Main Navigation Container */
.main-navigation {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    box-shadow: var(--nav-shadow);
    z-index: 1000;
    height: var(--nav-height);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Logo/Brand */
.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--nav-text);
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-logo-img {
    width: 40px;
    height: 40px;
    margin-right: 10px;
    vertical-align: middle;
}

/* Logo text colors and font */
.logo-mathe {
    color: #3b82f6;
    font-family: 'Lekton', monospace;
}

.logo-lernweg {
    color: #22c55e;
    font-family: 'Lekton', monospace;
}

/* Desktop Navigation */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 10px;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--nav-hover);
    transform: translateY(-2px);
}

.nav-link .nav-icon {
    margin-right: 8px;
    font-size: 1.1rem;
}

/* Search Button - reset button styles */
button.nav-link,
button.search-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

/* Dropdown Menu */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--nav-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    padding: 10px;
    min-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 10px;
}

.nav-item:hover .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-link {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.dropdown-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--nav-hover);
    transform: translateX(5px);
}

.dropdown-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 10px 0;
}

/* ===== MEGA DROPDOWN ===== */
.nav-item.has-mega {
    position: static;
}

.mega-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--nav-bg);
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    padding: 25px 30px;
    display: flex;
    gap: 30px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    margin-top: 10px;
    min-width: 500px;
}

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

.mega-column {
    min-width: 140px;
}

.mega-header {
    font-weight: 700;
    color: #667eea;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 0.95em;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.mega-link {
    display: block;
    padding: 10px 12px;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.mega-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--nav-hover);
    transform: translateX(5px);
}

/* User Menu (right side) */
.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.1);
}

/* User Avatar Image in Navigation */
.user-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #667eea 0%, #764ba2 100%) border-box;
}

.user-avatar-img:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.nav-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.nav-item.has-dropdown .user-avatar-img + .dropdown {
    right: 0;
    left: auto;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 10000;
    position: fixed !important;
    top: 15px !important;
    right: 15px !important;
    left: auto !important;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
}

/* Mobile Navigation - Fullscreen Overlay
   Hinweis: Position/Display wird via Inline-Styles gesteuert */
.mobile-nav {
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Mobile Overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.mobile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Items */
.mobile-menu {
    list-style: none;
    padding: 10px 15px 20px;
    margin: 0;
}

.mobile-menu-item {
    margin-bottom: 2px;
}

.mobile-menu-link {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: var(--nav-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 1rem;
    min-height: 44px;
}

.mobile-menu-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--nav-hover);
}

.mobile-menu-link .nav-icon {
    margin-right: 12px;
    font-size: 1.1rem;
}

/* Mobile Submenu */
.mobile-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mobile-submenu.active {
    max-height: 1000px;
}

.mobile-submenu-item {
    padding-left: 20px;
}

/* Mobile Submenu Groups (für Klassen-Dropdown) */
.mobile-submenu-group {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.mobile-submenu-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.mobile-submenu-header {
    font-weight: 700;
    color: #667eea;
    padding: 6px 15px;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-submenu-group .mobile-submenu-item {
    padding: 8px 15px;
    font-size: 0.95rem;
    min-height: 40px;
}

/* Quick Links Section in Mobile */
.mobile-quick-links {
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.mobile-quick-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #999;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    text-decoration: none;
    color: var(--nav-text);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.quick-link:hover {
    background: var(--nav-hover);
    color: white;
    transform: scale(1.05);
}

.quick-link-number {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 5px;
}

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

    .nav-link {
        padding: 8px 12px;
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    /* Hide desktop menu */
    .nav-menu,
    .nav-user {
        display: none;
    }

    /* Adjust logo size */
    .nav-logo {
        font-size: 1.3rem;
    }
}

/* Adjust main content for fixed nav */
body {
    padding-top: var(--nav-height);
}

/* Scroll padding for anchor links (Platz für sticky Navigation) */
html {
    scroll-behavior: auto;
    scroll-padding-top: var(--nav-height);
}

/* Active state for current page */
.nav-link.active,
.mobile-menu-link.active {
    background: rgba(102, 126, 234, 0.15);
    color: var(--nav-hover);
    font-weight: 600;
}

/* Accessibility */
.nav-link:focus,
.mobile-menu-link:focus,
.mobile-menu-btn:focus {
    outline: 2px solid var(--nav-hover);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .main-navigation,
    .mobile-nav,
    .mobile-overlay {
        display: none;
    }

    body {
        padding-top: 0;
    }
}

/* ===== SEARCH OVERLAY - Modern Glass Design ===== */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8vh;
    overflow-y: auto;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-container {
    width: 92%;
    max-width: 680px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    padding: 0;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    transform: scale(0.95) translateY(-30px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.search-overlay.active .search-container {
    transform: scale(1) translateY(0);
}

/* Search Header mit Gradient */
.search-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 28px 30px 24px;
    position: relative;
}

.search-header h2 {
    color: white;
    font-size: 1.4rem;
    margin: 0;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
}

/* Close Button */
.search-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    z-index: 10;
}

.search-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

/* Search Input Area */
.search-input-wrapper {
    position: relative;
    padding: 35px 25px 20px;
}

.search-input-icon {
    position: absolute;
    left: 45px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    pointer-events: none;
    margin-top: 7px;
}

.search-input {
    width: 100%;
    padding: 20px 24px 20px 60px;
    font-size: 1.15rem;
    font-family: inherit;
    border: none;
    border-radius: 16px;
    outline: none;
    background: #f0f2f5;
    color: #1a1a2e;
    transition: all 0.3s ease;
    box-sizing: border-box;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.search-input:focus {
    background: #fff;
    box-shadow:
        inset 0 0 0 2px #667eea,
        0 8px 25px rgba(102, 126, 234, 0.15);
}

.search-input::placeholder {
    color: #9ca3af;
}

/* Search Results Container */
.search-results {
    max-height: 55vh;
    overflow-y: auto;
    padding: 0 25px 25px;
    scrollbar-width: thin;
    scrollbar-color: #667eea #f0f2f5;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
}

/* Quicklinks Section */
.search-quicklinks h3 {
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
    font-weight: 600;
}

.quicklink-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.quicklink-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 12px;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fc 100%);
    border-radius: 18px;
    text-decoration: none;
    color: #1a1a2e;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    border: 1px solid rgba(102, 126, 234, 0.1);
    position: relative;
    overflow: hidden;
}

.quicklink-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 0;
}

.quicklink-item:hover::before {
    opacity: 1;
}

.quicklink-item:hover {
    transform: translateY(-6px);
    box-shadow:
        0 15px 35px rgba(102, 126, 234, 0.25),
        0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: transparent;
    color: white;
}

.quicklink-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.quicklink-item span:last-child {
    font-size: 0.85rem;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

/* Search Result Items */
.search-result-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-result-item {
    margin-bottom: 10px;
}

.search-result-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fc 100%);
    border-radius: 14px;
    text-decoration: none;
    color: #1a1a2e;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(102, 126, 234, 0.08);
    position: relative;
    overflow: hidden;
}

.search-result-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.search-result-link:hover::before {
    opacity: 1;
}

.search-result-link:hover {
    transform: translateX(8px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
    border-color: transparent;
    color: white;
}

.search-result-icon {
    font-size: 1.6rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    position: relative;
    z-index: 1;
    transition: background 0.3s ease;
}

.search-result-link:hover .search-result-icon {
    background: rgba(255, 255, 255, 0.2);
}

.search-result-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 1rem;
}

.search-result-path {
    font-size: 0.8rem;
    opacity: 0.65;
}

/* No Results State */
.search-no-results {
    text-align: center;
    padding: 45px 20px;
    color: #6b7280;
}

.search-no-results-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-no-results p {
    margin: 0;
    line-height: 1.6;
}

/* Keyboard Hint */
.search-keyboard-hint {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.kbd {
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: monospace;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Mobile Search Adjustments */
@media (max-width: 768px) {
    .search-overlay {
        padding-top: 3vh;
    }

    .search-container {
        width: 96%;
        border-radius: 20px;
    }

    .search-header {
        padding: 22px 20px 20px;
    }

    .search-header h2 {
        font-size: 1.2rem;
        padding-right: 40px;
    }

    .search-input-wrapper {
        padding: 30px 18px 16px;
    }

    .search-input {
        padding: 18px 20px 18px 55px;
        font-size: 1rem;
        border-radius: 14px;
    }

    .search-input-icon {
        left: 38px;
    }

    .search-results {
        padding: 0 18px 20px;
    }

    .quicklink-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .quicklink-item {
        padding: 18px 10px;
        border-radius: 14px;
    }

    .quicklink-icon {
        font-size: 1.8rem;
    }

    .search-close {
        width: 32px;
        height: 32px;
        top: 16px;
        right: 16px;
        font-size: 1.2rem;
    }
}

@media (max-width: 375px) {
    .search-overlay {
        padding: 0;
        align-items: stretch;
    }

    .search-container {
        width: 100%;
        border-radius: 0;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .search-header {
        border-radius: 0;
    }

    .search-header::after {
        display: none;
    }

    .search-input-wrapper {
        padding: 20px 15px 15px;
    }

    .search-results {
        flex: 1;
        max-height: none;
        padding: 0 15px 20px;
    }

    .quicklink-item {
        padding: 16px 8px;
    }

    .quicklink-icon {
        font-size: 1.6rem;
        margin-bottom: 6px;
    }

    .quicklink-item span:last-child {
        font-size: 0.8rem;
    }
}