/* =================================================================
   NAVIGATION COMPONENTS - VELTECHLAB
   ================================================================= */

/* =================================================================
   HEADER NAVIGATION
   ================================================================= */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1020;
    /* iPhone с „notch“: съдържанието не влиза под статус лентата */
    padding-top: env(safe-area-inset-top, 0px);
    background-color: rgba(18, 18, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: visible;
}

/* Градиентна линия + „glow“ под навигацията (визуално подравнена с разделителите между секции) */
.header::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    z-index: 0;
    width: var(--section-divider-max-width, min(94%, 1080px));
    height: var(--nav-accent-glow-height, 26px);
    transform: translate(-50%, 52%);
    pointer-events: none;
    background: radial-gradient(
        ellipse 88% 58% at 50% 0%,
        rgba(96, 165, 250, 0.34) 0%,
        rgba(59, 130, 246, 0.14) 45%,
        transparent 78%
    );
}

.header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    z-index: 1;
    width: var(--section-divider-max-width, min(94%, 1080px));
    height: var(--nav-accent-line-height, 4px);
    border-radius: var(--section-divider-radius, 999px);
    transform: translate(-50%, 0);
    pointer-events: none;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(59, 130, 246, 0.18) 6%,
        rgba(96, 165, 250, 0.58) 22%,
        rgba(147, 197, 253, 0.98) 50%,
        rgba(45, 212, 191, 0.68) 78%,
        rgba(96, 165, 250, 0.55) 94%,
        transparent 100%
    );
    box-shadow:
        0 0 1px rgba(255, 255, 255, 0.14),
        0 0 22px rgba(59, 130, 246, 0.38),
        0 0 40px rgba(59, 130, 246, 0.16);
}

.header.scrolled {
    background-color: rgba(18, 18, 26, 0.98);
    backdrop-filter: blur(30px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    height: 70px;
    position: relative;
    z-index: 2;
}

@media (min-width: 640px) {
    .header-container {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .header-container {
        padding: 0 2rem;
    }
}

/* Logo Section */
.logo-section {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
    transition: all 0.3s ease;
}

.logo:hover {
    color: var(--accent-primary);
    transform: scale(1.02);
}

.logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.logo:hover .logo-img {
    transform: rotate(5deg);
}

.logo-text {
    font-family: var(--font-primary);
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Main Navigation */
.main-nav {
    display: none;
}

@media (min-width: 768px) {
    .main-nav {
        display: block;
    }
}

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

.nav-item {
    position: relative;
    z-index: 1;
}

.nav-item.active {
    z-index: 1051;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.nav-link:hover {
    color: var(--accent-primary);
    background-color: rgba(96, 165, 250, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--accent-primary);
    background-color: rgba(96, 165, 250, 0.1);
    font-weight: 600;
}

.nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: var(--accent-primary);
    border-radius: 50%;
}

/* Dropdown Navigation */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1050;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

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

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.dropdown-menu a:hover {
    background-color: var(--bg-hover);
    color: var(--accent-primary);
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-outline {
    background: transparent;
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background: rgba(96, 165, 250, 0.14);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    color: var(--bg-primary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.38);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* =================================================================
   LANGUAGE SWITCHER
   ================================================================= */

.language-switcher {
    position: relative;
    z-index: 100;
}

.language-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 0.5rem;
    color: rgba(226, 232, 240, 0.9);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.language-btn:hover {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(30, 41, 59, 0.95);
}

.language-btn:focus {
    outline: 2px solid rgba(96, 165, 250, 0.5);
    outline-offset: 2px;
}

.language-btn .lang-icon {
    color: #60a5fa;
    font-size: 0.9rem;
}

.language-btn .lang-code {
    font-weight: 600;
    color: rgba(248, 250, 252, 0.95);
}

.language-btn .lang-arrow {
    font-size: 0.6rem;
    color: rgba(148, 163, 184, 0.8);
    transition: transform 0.3s ease;
}

.language-switcher.open .lang-arrow {
    transform: rotate(180deg);
}

/* Language Dropdown */
.language-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 150px;
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 0.75rem;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(96, 165, 250, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    padding: 0.375rem;
}

.language-switcher.open .language-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Language Options */
.language-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    color: rgba(226, 232, 240, 0.9);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
}

.language-option:hover {
    background: rgba(96, 165, 250, 0.1);
    color: rgba(248, 250, 252, 1);
}

.language-option.active {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.language-option .flag-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.language-option .lang-name {
    flex: 1;
}

.language-option .lang-check {
    color: #7dd3fc;
    font-size: 0.75rem;
    display: none;
}

.language-option.active .lang-check {
    display: inline;
}

/* Mobile Language Switcher */
.mobile-language-switcher {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.mobile-language-switcher .language-switcher {
    width: 100%;
}

.mobile-language-switcher .language-btn {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem 1rem;
}

.mobile-language-switcher .language-dropdown {
    position: relative;
    top: 0;
    margin-top: 0.5rem;
    width: 100%;
    opacity: 0;
    max-height: 0;
    visibility: hidden;
    transform: none;
    overflow: hidden;
    transition: all 0.3s ease;
}

.mobile-language-switcher .language-switcher.open .language-dropdown {
    opacity: 1;
    max-height: 200px;
    visibility: visible;
}

/* Responsive */
@media (max-width: 767px) {
    .header .language-switcher {
        display: none;
    }
}

@media (min-width: 768px) {
    .mobile-language-switcher {
        display: none;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    /* Минимум ~48px зона за докосване (Google / WCAG) */
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1030;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-toggle:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none;
    }
}

.mobile-menu-toggle span {
    width: 22px;
    height: 3px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* =================================================================
   MOBILE NAVIGATION
   ================================================================= */

.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    background: var(--bg-secondary);
    z-index: 1020;
    transition:
        right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.3s ease,
        opacity 0.3s ease;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    overflow-x: hidden;
    visibility: hidden;
    opacity: 0;
    display: flex;
    flex-direction: column;
}

/* Hide mobile nav on desktop and tablet */
@media (min-width: 768px) {
    .mobile-nav {
        display: none !important;
    }

    .mobile-nav-backdrop {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: none !important;
    }
}

.mobile-nav.active {
    right: 0;
    visibility: visible;
    opacity: 1;
}

.mobile-nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1010;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: none;
    background: var(--bg-tertiary);
    position: relative;
    overflow: visible;
}

.mobile-nav-header::before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    z-index: 0;
    width: min(92%, 420px);
    height: calc(var(--nav-accent-glow-height, 26px) * 0.92);
    transform: translate(-50%, 48%);
    pointer-events: none;
    background: radial-gradient(
        ellipse 90% 60% at 50% 0%,
        rgba(96, 165, 250, 0.28) 0%,
        rgba(59, 130, 246, 0.1) 48%,
        transparent 80%
    );
}

.mobile-nav-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    z-index: 1;
    width: min(92%, 420px);
    height: var(--nav-accent-line-height, 4px);
    border-radius: var(--section-divider-radius, 999px);
    transform: translate(-50%, 0);
    pointer-events: none;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(59, 130, 246, 0.16) 8%,
        rgba(96, 165, 250, 0.55) 26%,
        rgba(147, 197, 253, 0.96) 50%,
        rgba(45, 212, 191, 0.62) 74%,
        rgba(96, 165, 250, 0.5) 92%,
        transparent 100%
    );
    box-shadow:
        0 0 1px rgba(255, 255, 255, 0.1),
        0 0 18px rgba(59, 130, 246, 0.32);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mobile-logo-img {
    width: 32px;
    height: 32px;
}

.mobile-logo-text {
    font-weight: 700;
    font-size: 1.125rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-nav-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.mobile-nav-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mobile-nav-menu {
    list-style: none;
    margin: 0;
    padding: 1rem 0;
    padding-top: 2rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.mobile-nav-item {
    border-bottom: 1px solid var(--border-color);
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    min-height: 48px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.mobile-nav-link i {
    width: 20px;
    text-align: center;
    opacity: 0.7;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.mobile-nav-link.active {
    font-weight: 600;
    border-right: 3px solid var(--accent-primary);
}

.mobile-auth-buttons {
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg-secondary);
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin-top: auto;
    flex-shrink: 0;
}

/* =================================================================
   BACK TO TOP BUTTON
   ================================================================= */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    color: var(--bg-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 0 20px var(--accent-glow);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.45);
}

.back-to-top:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* =================================================================
   RESPONSIVE DESIGN
   ================================================================= */

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

    .logo-text {
        display: inline-block;
        font-size: 0.95rem;
        line-height: 1;
    }

    .mobile-nav {
        max-width: 100%;
    }
    
    .mobile-nav-menu {
        padding-top: 3rem;
        padding-bottom: 1rem;
    }
    
    .mobile-auth-buttons {
        padding: 1.25rem 1.5rem;
    }

    .back-to-top {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        right: calc(1rem + env(safe-area-inset-right, 0px));
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        font-size: 1.125rem;
    }
}

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

    .logo-img {
        width: 32px;
        height: 32px;
    }

    .logo-text {
        font-size: 0.86rem;
    }

    .mobile-nav-header {
        padding: 1rem;
        flex-shrink: 0;
    }

    .mobile-nav-link {
        padding: 0.875rem 1rem;
    }

    .mobile-auth-buttons {
        padding: 1.25rem 1rem;
    }
    
    .mobile-nav-menu {
        padding-top: 2.5rem;
        padding-bottom: 0.75rem;
    }
}

/* =================================================================
   ANIMATIONS
   ================================================================= */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */

.nav-link:focus,
.mobile-nav-link:focus,
.btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Skip navigation for screen readers */
.skip-nav {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #3b82f6;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1030;
    transition: top 0.3s ease;
}

.skip-nav:focus {
    top: 6px;
}

/* =================================================================
   HIGH CONTRAST MODE
   ================================================================= */

@media (prefers-contrast: high) {
    .header {
        border-bottom: 2px solid rgba(255, 255, 255, 0.9);
    }

    .nav-link,
    .mobile-nav-link {
        border: 1px solid transparent;
    }

    .nav-link:hover,
    .mobile-nav-link:hover {
        border-color: rgba(255, 255, 255, 0.9);
    }
}

/* =================================================================
   REDUCED MOTION
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
    .header,
    .mobile-nav,
    .back-to-top,
    .nav-link,
    .mobile-nav-link,
    .btn {
        transition: none;
    }

    .mobile-nav {
        right: 0;
    }

    .back-to-top {
        transform: none;
    }
}
