/* ==============================================
   SOIKEOPRO - MOBILE HAMBURGER MENU
   Week 2 - Task 7: Mobile Navigation
   Responsive hamburger menu for mobile devices
   ============================================== */

/* ========================================
   HAMBURGER BUTTON
   ======================================== */

.mobile-menu-button {
    display: none; /* Hidden on desktop */
    position: relative;
    z-index: 60;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
}

/* Hamburger icon lines */
.hamburger-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 18px;
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background-color: currentColor;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

/* Animated hamburger -> X transformation */
.mobile-menu-button.active .hamburger-line:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.mobile-menu-button.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.mobile-menu-button.active .hamburger-line:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ========================================
   MOBILE MENU OVERLAY
   ======================================== */

.mobile-menu-overlay {
    display: block !important; /* Always available for fade effect */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    opacity: 0 !important; /* Hidden by default with opacity */
    visibility: hidden; /* Extra layer: hidden until active */
    transition: opacity 0.3s ease;
    pointer-events: none !important; /* Prevent interaction when hidden */
}

.mobile-menu-overlay.active {
    opacity: 1 !important;
    visibility: visible; /* Show when active */
    pointer-events: auto !important;
}

/* ========================================
   MOBILE MENU CONTAINER
   ======================================== */

.mobile-menu {
    display: block !important; /* Always available, but positioned off-screen */
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background-color: var(--color-bg-primary);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 55;
    overflow-y: auto;
    transition: transform 0.3s ease;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%) !important; /* Hidden off-screen by default */
    visibility: hidden; /* Extra layer: hidden until active */
    will-change: transform;
    pointer-events: none !important; /* Prevent interaction when hidden */
}

.mobile-menu.active {
    transform: translateX(0) !important;
    visibility: visible; /* Show when active */
    pointer-events: auto !important; /* Enable interaction when visible */
}

/* Dark mode adjustments */
.dark .mobile-menu {
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

/* ========================================
   MOBILE MENU HEADER
   ======================================== */

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-border-primary);
    position: sticky;
    top: 0;
    background-color: var(--color-bg-primary);
    z-index: 10;
}

.mobile-menu-logo {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--color-text-primary);
}

.mobile-menu-close {
    width: 44px;
    height: 44px;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background-color 0.15s ease, color 0.15s ease;
    touch-action: manipulation;
}

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

.mobile-menu-close:active {
    /* ❌ REMOVED: transform: scale(0.95); - causes jank */
    opacity: 0.8;
}

/* ========================================
   MOBILE MENU CONTENT
   ======================================== */

.mobile-menu-content {
    padding: var(--space-lg);
}

/* ========================================
   ❌ REMOVED: User info section

   REASON: User info is ONLY in header dropdown
   Mobile menu contains ONLY navigation items

   User actions are in header top:
   - Avatar dropdown (Trang cá nhân, Lịch sử, Cài đặt, Đăng xuất)
   - Notification bell
   - Theme toggle

   Mobile sidebar contains ONLY:
   - Menu Chính (Trang chủ, Lịch thi đấu, Tỷ lệ kèo...)
   - Khác (Giới thiệu, Liên hệ...)
   ======================================== */

/* Menu sections */
.mobile-menu-section {
    margin-bottom: var(--space-2xl);
}

.mobile-menu-section-title {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
    padding: 0 var(--space-sm);
}

/* Menu items */
.mobile-menu-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.mobile-menu-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    min-height: 44px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: var(--font-medium);
    transition: background-color 0.15s ease, color 0.15s ease;
    touch-action: manipulation;
}

.mobile-menu-item:hover {
    background-color: var(--color-bg-secondary);
    color: var(--color-brand-primary);
}

.mobile-menu-item:active {
    /* ❌ REMOVED: transform: scale(0.98); - causes jank */
    opacity: 0.8;
}

/* Active menu item */
.mobile-menu-item.active {
    background-color: var(--color-bg-secondary);
    color: var(--color-brand-primary);
    font-weight: var(--font-semibold);
}

.mobile-menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background-color: var(--color-brand-primary);
    border-radius: 0 2px 2px 0;
}

/* Menu item icon */
.mobile-menu-item-icon {
    flex-shrink: 0;
    color: var(--color-text-secondary);
}

.mobile-menu-item:hover .mobile-menu-item-icon,
.mobile-menu-item.active .mobile-menu-item-icon {
    color: var(--color-brand-primary);
}

/* Menu item badge (for notifications, new, etc.) */
.mobile-menu-item-badge {
    margin-left: auto;
    padding: 2px 8px;
    background-color: var(--color-error);
    color: white;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    border-radius: var(--radius-full);
}

/* ========================================
   MOBILE MENU FOOTER
   ======================================== */

.mobile-menu-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--color-border-primary);
    background-color: var(--color-bg-secondary);
}

.mobile-menu-footer-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.mobile-menu-footer-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mobile-menu-footer-item:hover {
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

/* Social links */
.mobile-menu-social {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-primary);
}

.mobile-menu-social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    transition: background-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
}

.mobile-menu-social-link:hover {
    background-color: var(--color-brand-primary);
    color: var(--color-text-primary);
    /* ❌ REMOVED: transform: translateY(-2px); - causes jank */
}

/* ========================================
   DESKTOP NAVIGATION (HIDE HAMBURGER)
   ======================================== */

/* Desktop navigation links - prevent text wrapping */
.desktop-nav {
    position: relative; /* For absolute pseudo-element */
    overflow-x: auto; /* Allow horizontal scroll if needed */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; /* Firefox - thin scrollbar */
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent; /* Firefox - thumb and track color */
    padding-bottom: 4px; /* Space for scrollbar */

    /* Performance optimization */
    contain: layout style;
}

/* Hide scrollbar by default, show on hover */
.desktop-nav::-webkit-scrollbar {
    height: 4px; /* Thin scrollbar */
}

.desktop-nav::-webkit-scrollbar-track {
    background: transparent;
}

.desktop-nav::-webkit-scrollbar-thumb {
    background: transparent; /* Hidden by default */
    border-radius: 2px;
    transition: background 0.3s ease;
}

/* Show scrollbar when hovering over the nav */
.desktop-nav:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3); /* White with 30% opacity */
}

.desktop-nav:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5); /* Brighter on direct hover */
}

/* Fade in effect for Firefox */
.desktop-nav:hover {
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.desktop-nav a {
    white-space: nowrap;
    flex-shrink: 0; /* Prevent shrinking */
    font-size: 0.9375rem !important; /* 15px - readable size */
    padding: 0.5rem 0; /* Vertical padding for better click area */

    /* CRITICAL: No transform on hover - handled by nav-optimized.css */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Slightly larger on very wide screens */
@media (min-width: 1536px) {
    .desktop-nav a {
        font-size: 1rem !important; /* 16px for 2xl screens */
    }
}

/* Gradient fade effect at the end to indicate more content */
.desktop-nav::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 4px; /* Above scrollbar */
    width: 60px;
    background: linear-gradient(to left, #34d399 0%, rgba(52, 211, 153, 0) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

/* Dark mode gradient */
.dark .desktop-nav::after {
    background: linear-gradient(to left, #172554 0%, rgba(23, 37, 84, 0) 100%);
}

/* Show fade effect when nav is scrollable and not at the end */
.desktop-nav.has-overflow::after {
    opacity: 1;
}

/* Hide fade when scrolled to the end */
.desktop-nav.scrolled-to-end::after {
    opacity: 0;
}

/* Show hamburger button only on mobile */
@media (max-width: 1023px) {
    .mobile-menu-button {
        display: flex !important; /* Show hamburger button */
    }

    /* Ensure menu stays hidden off-screen on mobile */
    .mobile-menu {
        display: block !important;
        transform: translateX(100%) !important;
        visibility: hidden !important;
    }

    .mobile-menu-overlay {
        display: block !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    /* Only show when active class is added */
    .mobile-menu.active {
        transform: translateX(0) !important;
        visibility: visible !important;
    }

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

    /* Hide desktop navigation */
    .desktop-nav {
        display: none !important;
    }
}

/* Hide hamburger on desktop */
@media (min-width: 1024px) {
    .mobile-menu-button,
    .mobile-menu,
    .mobile-menu-overlay {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ========================================
   BODY SCROLL LOCK (when menu open)
   ======================================== */

body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

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

@keyframes slideInRight {
    from {
        right: -100%;
    }
    to {
        right: 0;
    }
}

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

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

/* Focus states for keyboard navigation */
.mobile-menu-button:focus-visible,
.mobile-menu-close:focus-visible,
.mobile-menu-item:focus-visible {
    outline: 3px solid var(--color-brand-primary);
    outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

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

/* GPU acceleration for smooth animations */
.mobile-menu,
.mobile-menu-overlay,
.hamburger-line {
    will-change: transform, opacity;
}

/* Prevent layout shift */
.mobile-menu-button,
.mobile-menu-item {
    -webkit-tap-highlight-color: rgba(52, 211, 153, 0.2);
}

/* ========================================
   DARK MODE
   ======================================== */

.dark .mobile-menu-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

.dark .mobile-menu-item:hover {
    background-color: rgba(52, 211, 153, 0.1);
}

.dark .mobile-menu-footer {
    background-color: rgba(0, 0, 0, 0.2);
}

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

/* Extra small mobile (< 375px) */
@media (max-width: 374px) {
    .mobile-menu {
        width: 90%;
        max-width: none;
    }

    .mobile-menu-header,
    .mobile-menu-content {
        padding: var(--space-md);
    }
}

/* Large mobile (> 640px but < 1024px) */
@media (min-width: 640px) and (max-width: 1023px) {
    .mobile-menu {
        max-width: 360px;
    }
}

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

@media print {
    .mobile-menu-button,
    .mobile-menu,
    .mobile-menu-overlay {
        display: none !important;
    }
}
