/**
 * Navbar Enhanced Styles
 * Responsive navigation with mobile support
 */

/* ========================================
   GLASS EFFECT & BASE STYLES
   ======================================== */

.glass-effect {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

[data-theme="dark"] .glass-effect {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Sticky navbar enhancement */
nav.scrolled {
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] nav.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========================================
   LOGO STYLES
   ======================================== */

.logo-container {
    transition: all 0.3s ease;
}

.logo-container a {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s ease;
}

.logo-container a:hover {
    transform: scale(1.05);
}

/* Responsive logo sizing */
@media (max-width: 640px) {
    .logo-container {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 480px) {
    .logo-container {
        font-size: 1.25rem !important;
    }
}

/* ========================================
   NAVIGATION LINKS
   ======================================== */

.nav-link {
    position: relative;
    transition: color 0.2s ease;
    text-decoration: none;
}

.nav-link.active {
    color: var(--text-primary);
    font-weight: 600;
}

/* Underline effect */
.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0;
    height: 2px;
    background-color: var(--text-primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link:focus::after {
    width: 100%;
}

/* Active link styling */
.nav-link.active::after {
    width: 100%;
}

/* ========================================
   DROPDOWN MENUS
   ======================================== */

.dropdown-menu {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* Let JavaScript handle all dropdown behavior */

/* Dropdown menu items */
.dropdown-menu a,
.dropdown-menu button {
    transition: all 0.2s ease;
}

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

/* Dropdown animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-menu.active {
    animation: slideDown 0.2s ease;
}

/* ========================================
   FULLSCREEN MOBILE MENU - NEW DESIGN
   ======================================== */

.fullscreen-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    background: var(--bg-primary);
    display: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.fullscreen-mobile-menu.active {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mobile Menu Container */
.mobile-menu-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    max-height: 100vh;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Ensure fullscreen menu is always on top */
.fullscreen-mobile-menu {
    isolation: isolate;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100vh !important;
}

/* Mobile Menu Header */
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.site-logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.close-menu-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--hover-bg);
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-menu-btn:hover {
    background: var(--border-color);
    transform: rotate(90deg);
}

.close-menu-btn:active {
    transform: rotate(90deg) scale(0.95);
}

/* Mobile Menu Content */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 1;
}

.mobile-menu-content::-webkit-scrollbar {
    width: 6px;
}

.mobile-menu-content::-webkit-scrollbar-track {
    background: transparent;
}

.mobile-menu-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.mobile-menu-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* User Section */
.user-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--hover-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-avatar-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.user-details h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.user-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Login Section */
.login-section {
    margin-bottom: 2rem;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.login-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-primary);
    transform: translateY(-2px);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn i {
    font-size: 1.25rem;
    color: #4285F4;
}

/* Mobile Navigation */
.mobile-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--text-primary);
    transform: scaleY(0);
    transition: transform 0.2s ease;
    border-radius: 0 4px 4px 0;
}

.nav-item:hover {
    background: var(--hover-bg);
}

.nav-item:hover::before {
    transform: scaleY(1);
}

.nav-item:active {
    transform: scale(0.98);
}

.nav-item i {
    font-size: 1.125rem;
    width: 24px;
    text-align: center;
    color: var(--text-secondary);
}

.nav-item.logout {
    color: #ef4444;
    margin-top: 1rem;
}

.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

.nav-item.logout i {
    color: #ef4444;
}

/* Dropdown Navigation */
.nav-dropdown {
    display: flex;
    flex-direction: column;
}

.dropdown-trigger {
    width: 100%;
    justify-content: space-between;
}

.nav-item-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dropdown-icon {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.dropdown-trigger.active .dropdown-icon {
    transform: rotate(180deg);
}

.dropdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-left: 1rem;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin: 0.25rem 0;
}

.dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    transform: translateX(4px);
}

.dropdown-item i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Mobile Menu Footer */
.mobile-menu-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.theme-toggle-btn:active {
    transform: translateY(0);
}

.theme-toggle-btn i {
    font-size: 1.125rem;
}

/* ========================================
   ADDITIONAL ENHANCEMENTS
   ======================================== */

/* Backdrop blur for fullscreen menu */
@supports (backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px)) {
    .fullscreen-mobile-menu.active {
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }

    [data-theme="light"] .fullscreen-mobile-menu.active {
        background: rgba(255, 255, 255, 0.98);
    }

    [data-theme="dark"] .fullscreen-mobile-menu.active {
        background: rgba(0, 0, 0, 0.98);
    }
}

/* Fallback for browsers without backdrop-filter */
@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
    [data-theme="light"] .fullscreen-mobile-menu.active {
        background: rgba(255, 255, 255, 1);
    }

    [data-theme="dark"] .fullscreen-mobile-menu.active {
        background: rgba(0, 0, 0, 1);
    }
}

/* Smooth transitions for all interactive elements */
.nav-item,
.dropdown-item,
.login-btn,
.theme-toggle-btn,
.close-menu-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Focus visible styles for better accessibility */
.nav-item:focus-visible,
.dropdown-item:focus-visible,
.login-btn:focus-visible,
.theme-toggle-btn:focus-visible,
.close-menu-btn:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Prevent text selection on interactive elements */
.nav-item,
.dropdown-trigger,
.close-menu-btn,
.theme-toggle-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .mobile-menu-header {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
        padding-top: max(1.5rem, env(safe-area-inset-top));
    }

    .mobile-menu-footer {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}

/* ========================================
   BUTTONS & INTERACTIONS
   ======================================== */

button {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dark mode toggle */
#darkModeToggle,
#darkModeToggleMobile {
    border-radius: 0.5rem;
}

#darkModeToggle:hover,
#darkModeToggleMobile:hover {
    background-color: var(--hover-bg);
}

/* Mobile menu toggle */
#mobileMenuToggle:hover {
    background-color: var(--hover-bg);
    border-radius: 0.5rem;
}

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

.fa-chevron-down {
    transition: transform 0.2s ease;
}

[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}

/* ========================================
   FOCUS STATES (ACCESSIBILITY)
   ======================================== */

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove default focus outline */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    nav .space-x-8 {
        gap: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    nav {
        padding: 0.75rem 0;
    }

    nav .py-4 {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Ensure fullscreen menu works on mobile */
    .fullscreen-mobile-menu {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }

    .mobile-menu-container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .fullscreen-mobile-menu .mobile-menu-container {
        padding: 0;
    }

    nav .px-4 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* iOS Safari specific fixes */
    .fullscreen-mobile-menu {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* Very small screens */
@media (max-width: 375px) {
    .logo-container {
        font-size: 1.125rem !important;
    }

    #darkModeToggleMobile,
    #mobileMenuToggle {
        padding: 0.375rem;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Remove tap highlight on mobile */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling */
.fullscreen-mobile-menu .mobile-menu-content {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Loading state for images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src]) {
    opacity: 1;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .nav-link::after {
        height: 3px;
    }

    .nav-item::before {
        width: 5px;
    }

    .dropdown-menu,
    .fullscreen-mobile-menu {
        border: 2px solid var(--text-primary);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    nav {
        display: none;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* GPU acceleration for animations */
.fullscreen-mobile-menu,
.mobile-menu-container,
.dropdown-menu,
.nav-link::after,
.nav-item::before {
    will-change: transform;
}

/* Remove will-change after animation */
.fullscreen-mobile-menu:not(.active),
.dropdown-menu:not(.active) {
    will-change: auto;
}

/* ========================================
   DARK MODE SPECIFIC ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .fullscreen-mobile-menu {
    background-color: rgba(0, 0, 0, 0.98);
}

[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* ========================================
   LANDSCAPE MOBILE ORIENTATION
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .mobile-menu-header {
        padding: 1rem 1.5rem;
    }

    .mobile-menu-content {
        padding: 1rem 1.5rem;
    }

    .nav-item {
        padding: 0.75rem 1rem;
    }

    .mobile-menu-footer {
        padding: 1rem 1.5rem;
    }
}

