/* ===== NIRIV MOBILE-FIRST NAVIGATION SYSTEM ===== */
/* Inspired by Naver's mobile navigation design principles */
/* Progressive enhancement from mobile to desktop */

/* ===== NAVIGATION VARIABLES ===== */
:root {
    /* Touch-friendly sizing */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
    --touch-target-large: 56px;
    
    /* Navigation spacing */
    --nav-padding-mobile: 0.75rem;
    --nav-padding-tablet: 1rem;
    --nav-padding-desktop: 1.25rem;
    
    /* Navigation heights */
    --header-height-mobile: 60px;
    --header-height-desktop: 70px;
    --footer-nav-height: 64px;
    
    /* Animation timing */
    --nav-transition-fast: 0.2s ease-out;
    --nav-transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Touch feedback colors */
    --touch-feedback-bg: rgba(59, 130, 246, 0.1);
    --touch-active-bg: rgba(59, 130, 246, 0.15);
    --nav-border-color: rgba(229, 231, 235, 0.8);
    
    /* Naver-inspired colors */
    --naver-green: #03c75a;
    --naver-green-hover: #02b351;
    --naver-bg: #f8f9fa;
    --naver-border: #e9ecef;
}

/* ===== MOBILE-FIRST HEADER NAVIGATION ===== */
.niriv-mobile-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--nav-border-color);
    height: var(--header-height-mobile);
    transition: all var(--nav-transition-smooth);
}

.niriv-mobile-header.scrolled {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

/* Mobile header content */
.niriv-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 var(--nav-padding-mobile);
    max-width: 100%;
}

/* Logo/Brand */
.niriv-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.niriv-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.niriv-brand-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    display: none; /* Hidden on mobile */
}

/* Mobile menu toggle */
.niriv-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-comfortable);
    height: var(--touch-target-comfortable);
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--nav-transition-fast);
    color: #374151;
}

.niriv-menu-toggle:hover {
    background: var(--touch-feedback-bg);
}

.niriv-menu-toggle:active {
    background: var(--touch-active-bg);
    transform: scale(0.95);
}

/* Desktop navigation menu (hidden on mobile) */
.niriv-desktop-nav {
    display: none;
}

/* ===== MOBILE NAVIGATION MENU ===== */
.niriv-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--nav-transition-smooth);
}

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

.niriv-mobile-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: white;
    transform: translateX(-100%);
    transition: transform var(--nav-transition-smooth);
    overflow-y: auto;
}

.niriv-mobile-menu.active .niriv-mobile-menu-content {
    transform: translateX(0);
}

/* Mobile menu header */
.niriv-mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--nav-padding-mobile);
    border-bottom: 1px solid var(--naver-border);
    background: var(--naver-bg);
}

.niriv-mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--nav-transition-fast);
}

.niriv-mobile-menu-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Mobile menu navigation */
.niriv-mobile-nav {
    padding: var(--nav-padding-mobile);
}

.niriv-mobile-nav-section {
    margin-bottom: 2rem;
}

.niriv-mobile-nav-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.niriv-mobile-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.niriv-mobile-nav-item {
    margin-bottom: 0.25rem;
}

.niriv-mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    transition: all var(--nav-transition-fast);
    min-height: var(--touch-target-comfortable);
}

.niriv-mobile-nav-link:hover {
    background: var(--touch-feedback-bg);
    color: #1f2937;
}

.niriv-mobile-nav-link:active {
    background: var(--touch-active-bg);
    transform: scale(0.98);
}

.niriv-mobile-nav-icon {
    width: 20px;
    height: 20px;
    color: #6b7280;
    flex-shrink: 0;
}

/* ===== TABLET BREAKPOINT (640px+) ===== */
@media (min-width: 640px) {
    .niriv-header-content {
        padding: 0 var(--nav-padding-tablet);
    }
    
    .niriv-brand-text {
        display: block;
    }
    
    .niriv-mobile-menu-content {
        width: 75%;
        max-width: 400px;
    }
}

/* ===== DESKTOP BREAKPOINT (1024px+) ===== */
@media (min-width: 1024px) {
    .niriv-mobile-header {
        height: var(--header-height-desktop);
    }
    
    .niriv-header-content {
        padding: 0 var(--nav-padding-desktop);
        max-width: 1100px;
        margin: 0 auto;
    }
    
    /* Hide mobile menu toggle */
    .niriv-menu-toggle {
        display: none;
    }
    
    /* Show desktop navigation */
    .niriv-desktop-nav {
        display: flex;
        align-items: center;
        gap: 2rem;
    }
    
    .niriv-desktop-nav-list {
        display: flex;
        align-items: center;
        gap: 1.5rem;
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .niriv-desktop-nav-link {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        text-decoration: none;
        color: #374151;
        font-weight: 500;
        transition: all var(--nav-transition-fast);
        min-height: var(--touch-target-min);
    }
    
    .niriv-desktop-nav-link:hover {
        background: var(--touch-feedback-bg);
        color: #1f2937;
    }
    
    .niriv-desktop-nav-icon {
        width: 18px;
        height: 18px;
        color: #6b7280;
    }
    
    /* Hide mobile menu completely */
    .niriv-mobile-menu {
        display: none;
    }
}

/* ===== NAVER-STYLE BOTTOM NAVIGATION (Mobile Only) ===== */
.niriv-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--nav-border-color);
    height: var(--footer-nav-height);
    padding: 0.5rem 0;
}

.niriv-bottom-nav-content {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

.niriv-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 8px;
    text-decoration: none;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all var(--nav-transition-fast);
    min-width: var(--touch-target-comfortable);
    min-height: var(--touch-target-comfortable);
}

.niriv-bottom-nav-item:hover,
.niriv-bottom-nav-item.active {
    color: var(--naver-green);
    background: rgba(3, 199, 90, 0.1);
}

.niriv-bottom-nav-icon {
    width: 20px;
    height: 20px;
}

/* Hide bottom nav on desktop */
@media (min-width: 1024px) {
    .niriv-bottom-nav {
        display: none;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    .niriv-mobile-header,
    .niriv-mobile-menu,
    .niriv-mobile-menu-content,
    .niriv-menu-toggle,
    .niriv-mobile-nav-link,
    .niriv-desktop-nav-link,
    .niriv-bottom-nav-item {
        transition: none !important;
    }
}

/* Focus styles for keyboard navigation */
.niriv-menu-toggle:focus,
.niriv-mobile-menu-close:focus,
.niriv-mobile-nav-link:focus,
.niriv-desktop-nav-link:focus,
.niriv-bottom-nav-item:focus {
    outline: 2px solid #1847ea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .niriv-mobile-header,
    .niriv-mobile-menu-content,
    .niriv-bottom-nav {
        border: 1px solid #000;
    }
    
    .niriv-mobile-nav-link,
    .niriv-desktop-nav-link,
    .niriv-bottom-nav-item {
        border: 1px solid transparent;
    }
    
    .niriv-mobile-nav-link:hover,
    .niriv-desktop-nav-link:hover,
    .niriv-bottom-nav-item:hover {
        border-color: #000;
    }
}
.header-button {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all var(--nav-transition-fast);
    position: relative;
    overflow: hidden;
}

.header-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--touch-feedback-bg);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all var(--nav-transition-fast);
}

.header-button:active::before {
    width: 100%;
    height: 100%;
}

.header-button:hover {
    background: var(--touch-feedback-bg);
    transform: scale(1.02);
}

.header-button:active {
    background: var(--touch-active-bg);
    transform: scale(0.98);
}

/* ===== MOBILE SIDEBAR NAVIGATION ===== */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    background: white;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--nav-transition-smooth);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: all var(--nav-transition-smooth);
}

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

/* Sidebar navigation items */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 1rem var(--nav-padding-mobile);
    min-height: var(--touch-target-comfortable);
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
    transition: all var(--nav-transition-fast);
    position: relative;
}

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

.sidebar-nav-item:active {
    background: var(--touch-active-bg);
    transform: translateX(4px);
}

.sidebar-nav-icon {
    width: 24px;
    height: 24px;
    margin-right: 1rem;
    color: #6b7280;
    transition: color var(--nav-transition-fast);
}

.sidebar-nav-item:hover .sidebar-nav-icon {
    color: #3b82f6;
}

.sidebar-nav-text {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: #374151;
    transition: color var(--nav-transition-fast);
}

.sidebar-nav-item:hover .sidebar-nav-text {
    color: #1f2937;
}

/* ===== HORIZONTAL NAVIGATION (PILLS) ===== */
.nav-pills-container {
    background: white;
    border-bottom: 1px solid var(--nav-border-color);
    padding: 0.5rem 0;
    position: sticky;
    top: var(--header-height-mobile);
    z-index: 40;
}

.nav-pills {
    display: flex;
    gap: 0.5rem;
    padding: 0 var(--nav-padding-mobile);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-pills::-webkit-scrollbar {
    display: none;
}

.nav-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    min-height: 40px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: #64748b;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--nav-transition-fast);
    position: relative;
    overflow: hidden;
}

.nav-pill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.nav-pill:hover::before {
    left: 100%;
}

.nav-pill:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #475569;
    transform: translateY(-1px);
}

.nav-pill:active {
    transform: translateY(0) scale(0.98);
}

.nav-pill.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.nav-pill.active:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.nav-pill-icon {
    width: 16px;
    height: 16px;
    transition: transform var(--nav-transition-fast);
}

.nav-pill:hover .nav-pill-icon {
    transform: scale(1.1);
}

/* ===== MOBILE FOOTER NAVIGATION ===== */
.mobile-footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--nav-border-color);
    z-index: 50;
    padding: 0.5rem 0;
}

.footer-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

.footer-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    padding: 0.25rem;
    border-radius: 12px;
    transition: all var(--nav-transition-fast);
    position: relative;
    text-decoration: none;
}

.footer-nav-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--touch-feedback-bg);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all var(--nav-transition-fast);
}

.footer-nav-item:active::before {
    width: 120%;
    height: 120%;
}

.footer-nav-icon {
    width: 24px;
    height: 24px;
    color: #6b7280;
    transition: all var(--nav-transition-fast);
    margin-bottom: 0.125rem;
}

.footer-nav-text {
    font-size: 10px;
    font-weight: var(--font-weight-medium);
    color: #6b7280;
    transition: color var(--nav-transition-fast);
    line-height: 1;
}

.footer-nav-item:hover .footer-nav-icon,
.footer-nav-item:hover .footer-nav-text {
    color: #3b82f6;
}

.footer-nav-item.active .footer-nav-icon,
.footer-nav-item.active .footer-nav-text {
    color: #3b82f6;
}

.footer-nav-item.active .footer-nav-icon {
    transform: scale(1.1);
}

/* Center FAB button */
.footer-nav-fab {
    position: relative;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-radius: 50%;
    width: var(--touch-target-large);
    height: var(--touch-target-large);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
    transition: all var(--nav-transition-bounce);
    margin-top: -8px;
}

.footer-nav-fab:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.5);
}

.footer-nav-fab:active {
    transform: scale(0.95) translateY(0);
}

.footer-nav-fab .footer-nav-icon {
    color: white;
    width: 28px;
    height: 28px;
}

/* ===== RESPONSIVE ENHANCEMENTS ===== */
@media (min-width: 640px) {
    :root {
        --nav-padding-mobile: var(--nav-padding-tablet);
        --header-height-mobile: var(--header-height-desktop);
    }
    
    .mobile-sidebar {
        width: 75vw;
        max-width: 360px;
    }
    
    .nav-pills {
        padding: 0 var(--nav-padding-tablet);
        gap: 0.75rem;
    }
    
    .nav-pill {
        padding: 0.625rem 1.25rem;
        min-height: 44px;
    }
}

@media (min-width: 1024px) {
    .mobile-footer-nav,
    .mobile-sidebar,
    .sidebar-overlay {
        display: none;
    }
    
    .nav-pills-container {
        position: static;
    }
    
    .nav-pills {
        padding: 0 var(--nav-padding-desktop);
        justify-content: center;
        gap: 1rem;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --touch-feedback-bg: rgba(59, 130, 246, 0.2);
        --touch-active-bg: rgba(59, 130, 246, 0.25);
        --nav-border-color: rgba(75, 85, 99, 0.3);
    }
    
    .mobile-header,
    .nav-pills-container,
    .mobile-footer-nav,
    .mobile-sidebar {
        background: rgba(17, 24, 39, 0.95);
        color: #f9fafb;
    }
    
    .nav-pill {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
    
    .nav-pill:hover {
        background: #4b5563;
        border-color: #6b7280;
        color: #f3f4f6;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.mobile-sidebar,
.sidebar-overlay,
.mobile-footer-nav {
    will-change: transform, opacity;
}

.nav-pill,
.footer-nav-item,
.header-button {
    will-change: transform, background-color;
}

/* Prevent layout shift */
.nav-pills-container {
    contain: layout style;
}

.mobile-footer-nav {
    contain: layout style paint;
}

/* ===== TOUCH IMPROVEMENTS ===== */
@media (hover: none) and (pointer: coarse) {
    .header-button:hover,
    .nav-pill:hover,
    .footer-nav-item:hover,
    .sidebar-nav-item:hover {
        transform: none;
        background: var(--touch-feedback-bg);
    }
    
    .footer-nav-fab:hover {
        transform: none;
    }
}

/* Improve scroll performance on mobile */
.nav-pills,
.mobile-sidebar {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Safe area handling for devices with notches */
@supports (padding: max(0px)) {
    .mobile-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .mobile-footer-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    
    .mobile-sidebar {
        padding-left: max(0, env(safe-area-inset-left));
    }
}