/* ═══════════════════════════════════════════════════════════
 * MOBILE UI OPTIMIZATION - JavZone
 * Clean, Fast, Professional Mobile Experience
 * ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    
    /* ═══ HEADER OPTIMIZATION ═══ */
    .header {
        padding: 10px 12px !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
    }
    
    .header-content {
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 0 8px !important;
        align-items: center !important;
    }
    
    /* ═══ HAMBURGER MENU - SHOW ON MOBILE ═══ */
    .hamburger-menu-btn {
        display: flex !important;
        flex-shrink: 0 !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Hide regular navigation on mobile */
    .nav {
        display: none !important;
    }
    
    .logo {
        flex-shrink: 1 !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }
    
    .logo img {
        height: 24px !important;
        margin-right: 6px !important;
    }
    
    .logo span {
        font-size: 14px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* ═══ SEARCH BAR - COMPACT ═══ */
    .search-container {
        flex: 1 !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .search-form {
        width: 100% !important;
        border-radius: 20px !important;
        max-width: 100% !important;
    }
    
    .search-input {
        font-size: 13px !important;
        padding: 8px 12px !important;
        border-radius: 20px 0 0 20px !important;
        min-width: 0 !important;
        flex: 1 !important;
    }
    
    .search-input::placeholder {
        font-size: 12px !important;
    }
    
    .search-btn {
        padding: 8px 14px !important;
        font-size: 12px !important;
        border-radius: 0 20px 20px 0 !important;
        min-width: 50px !important;
        min-height: 36px !important;
        flex-shrink: 0 !important;
    }
    
    /* Admin button - Touch friendly */
    .btn.btn-secondary {
        padding: 8px 12px !important;
        font-size: 12px !important;
        min-width: 44px !important;
        min-height: 36px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }
    
    /* Very small screens - hide admin button text */
    @media (max-width: 360px) {
        .btn.btn-secondary {
            padding: 8px !important;
            font-size: 0 !important;
        }
        
        .btn.btn-secondary::before {
            content: "⚙" !important;
            font-size: 16px !important;
        }
        
        .logo span {
            font-size: 12px !important;
        }
        
        .search-btn {
            min-width: 44px !important;
            padding: 8px 10px !important;
        }
    }
    
    /* ═══ HERO SECTION - COMPACT ═══ */
    .hero-section-compact {
        padding: 15px !important;
        margin-bottom: 12px !important;
    }
    
    .site-brief {
        flex-direction: column !important;
        gap: 8px !important;
        text-align: center !important;
    }
    
    .site-name-small {
        font-size: 20px !important;
        line-height: 1.2 !important;
    }
    
    .site-tagline {
        font-size: 12px !important;
    }
    
    .hero-stats {
        justify-content: center !important;
        gap: 6px !important; /* REDUCED: More compact */
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }
    
    .hero-stats span {
        padding: 4px 8px !important; /* REDUCED: More compact */
        font-size: 10px !important; /* REDUCED: Less visual weight */
        border-radius: 4px !important;
        white-space: nowrap !important;
    }
    
    /* Hide less important stats on very small screens */
    @media (max-width: 360px) {
        .hero-stats span:nth-child(n+3) {
            display: none !important;
        }
    }
    
    /* ═══ TRENDING MARQUEE ═══ */
    .trending-marquee {
        padding: 8px 0 !important;
        font-size: 12px !important;
    }
    
    /* ═══ NAVIGATION - HORIZONTAL SCROLL ═══ */
    .nav {
        background: #1a1a1a !important;
        padding: 10px 0 !important;
        margin-bottom: 15px !important;
        position: relative !important;
        overflow: visible !important;
    }
    
    .nav-list {
        display: flex !important;
        gap: 8px !important;
        padding: 0 15px !important;
        min-width: min-content !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        scrollbar-width: thin !important;
        scrollbar-color: #ff6b35 rgba(255, 255, 255, 0.1) !important;
        /* Add gradient fade indicators */
        mask-image: linear-gradient(to right, transparent, black 10px, black calc(100% - 10px), transparent) !important;
        -webkit-mask-image: linear-gradient(to right, transparent, black 10px, black calc(100% - 10px), transparent) !important;
    }
    
    .nav-item {
        flex-shrink: 0 !important;
    }
    
    .nav-link {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 10px 16px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
        border-radius: 20px !important;
        transition: all 0.2s ease !important;
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }
    
    .nav-link.active {
        background: linear-gradient(45deg, #ff6b35, #f7931e) !important;
        color: #fff !important;
        box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3) !important;
    }
    
    /* Show scrollbar on mobile for better UX */
    .nav-list::-webkit-scrollbar {
        height: 4px !important;
        display: block !important;
    }
    
    .nav-list::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05) !important;
        border-radius: 2px !important;
    }
    
    .nav-list::-webkit-scrollbar-thumb {
        background: #ff6b35 !important;
        border-radius: 2px !important;
    }
    
    .nav-list::-webkit-scrollbar-thumb:active {
        background: #e55a2b !important;
    }
    
    /* ═══ HERO CAROUSEL - MOBILE OPTIMIZED ═══ */
    .hero-carousel-section {
        margin-bottom: 20px !important;
    }
    
    .hero-carousel {
        max-height: 200px !important; /* REDUCED: More content visible */
        border-radius: 12px !important;
        overflow: hidden !important;
    }
    
    .hero-slide {
        height: 200px !important; /* REDUCED: Better space efficiency */
    }
    
    .hero-background img {
        object-position: center 20% !important;
    }
    
    .hero-content {
        padding: 15px !important;
        bottom: 0 !important;
    }
    
    .hero-category {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }
    
    .hero-title {
        font-size: 16px !important;
        line-height: 1.3 !important;
        margin: 8px 0 !important;
        max-height: 2.6em !important;
        -webkit-line-clamp: 2 !important;
    }
    
    .hero-description {
        display: none !important; /* Hide on mobile to save space */
    }
    
    .hero-actions {
        margin-top: 10px !important;
        gap: 8px !important;
    }
    
    .hero-btn-primary,
    .hero-btn-secondary {
        padding: 8px 16px !important;
        font-size: 13px !important;
        border-radius: 6px !important;
    }
    
    .hero-dots {
        bottom: 10px !important;
        gap: 6px !important;
    }
    
    .hero-dot {
        width: 6px !important;
        height: 6px !important;
    }
    
    /* ═══ MAIN LAYOUT ═══ */
    .main-layout {
        padding: 0 !important;
    }
    
    .main-content {
        padding: 0 12px 20px !important;
    }
    
    /* ═══ VIDEO GRID - 2 COLUMNS - FIXED OVERLAP! ═══ */
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important; /* Optimized spacing for mobile */
        padding: 0 12px !important; /* Side padding */
        margin-bottom: 30px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .video-item {
        background: #1a1a1a !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
        margin-bottom: 0 !important; /* Grid handles spacing */
        min-height: auto !important; /* Let content determine height */
        position: relative !important;
        width: 100% !important;
        min-width: 0 !important; /* Prevent overflow */
        display: flex !important;
        flex-direction: column !important;
    }
    
    .video-item:active {
        transform: scale(0.95) !important; /* IMPROVED: More noticeable feedback */
        opacity: 0.9 !important; /* ADDED: Visual feedback */
        box-shadow: 0 4px 12px rgba(255,107,53,0.4) !important; /* ADDED: Highlight */
    }
    
    .video-item:hover {
        box-shadow: 0 4px 16px rgba(255,107,53,0.3) !important; /* ADDED: Desktop hover */
    }
    
    .video-thumbnail {
        position: relative !important;
        width: 100% !important;
        aspect-ratio: 16 / 9 !important;
        overflow: hidden !important;
        background: #0a0a0a !important;
        flex-shrink: 0 !important;
        min-height: 0 !important;
    }
    
    .video-thumbnail img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        display: block !important;
        aspect-ratio: 16 / 9 !important;
    }
    
    .video-play-overlay {
        display: none !important; /* Hide to reduce clutter */
    }
    
    .video-duration {
        position: absolute !important;
        bottom: 6px !important;
        right: 6px !important;
        background: rgba(0,0,0,0.85) !important;
        color: #fff !important;
        padding: 3px 6px !important;
        border-radius: 4px !important;
        font-size: 10px !important;
        font-weight: 700 !important;
    }
    
    .video-info {
        padding: 10px !important;
        min-height: auto !important;
        position: relative !important;
        z-index: 2 !important;
        background: #1a1a1a !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        overflow: hidden !important;
        min-width: 0 !important;
    }
    
    .video-title {
        font-size: 13px !important; /* IMPROVED: More readable */
        line-height: 1.4 !important; /* IMPROVED: Better spacing */
        margin-bottom: 4px !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important; /* IMPROVED: More context */
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-height: 54px !important; /* ADJUSTED: For 3 lines */
        color: #fff !important;
        font-weight: 500 !important; /* IMPROVED: Stronger hierarchy */
    }
    
    .video-meta {
        font-size: 10px !important;
        color: #888 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .video-category {
        color: #ff6b35 !important;
        font-weight: 600 !important;
    }
    
    .video-date {
        color: #666 !important;
    }
    
    /* ═══ PAGINATION ═══ */
    .pagination {
        padding: 20px 0 !important;
        gap: 8px !important; /* IMPROVED: Better spacing */
    }
    
    .page-link,
    .page-current {
        padding: 12px 16px !important; /* IMPROVED: iOS 44x44px tap target */
        font-size: 14px !important; /* IMPROVED: More readable */
        min-width: 44px !important; /* IMPROVED: Larger tap target */
        min-height: 44px !important; /* ADDED: iOS guidelines */
        border-radius: 8px !important;
        display: flex !important; /* ADDED: Center content */
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.2s ease !important;
    }
    
    .page-link:active {
        transform: scale(0.95) !important; /* ADDED: Touch feedback */
        background: rgba(255,107,53,0.2) !important;
    }
    
    .pagination-info {
        font-size: 11px !important;
    }
    
    /* ═══ SIDEBAR - HIDE ON MOBILE ═══ */
    .sidebar {
        display: none !important;
    }
    
    /* ═══ ADS - MOBILE OPTIMIZED ═══ */
    .ad-container {
        margin: 15px auto !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    .ad-mobile-300x250,
    .hilltop-mobile-inject {
        max-width: min(300px, calc(100vw - 24px)) !important;
        margin: 0 auto !important;
    }
    
    /* ═══ FOOTER ═══ */
    .footer {
        padding: 20px 15px !important;
        margin-top: 30px !important;
    }
    
    .footer-links {
        flex-wrap: wrap !important;
        gap: 16px !important; /* IMPROVED: Better tap spacing */
        font-size: 13px !important; /* IMPROVED: More readable */
        justify-content: center !important;
    }
    
    .footer-links a {
        padding: 8px 4px !important; /* ADDED: Larger tap area */
        min-width: 60px !important; /* ADDED: Prevent cramping */
        text-align: center !important;
    }
    
    .footer-text {
        font-size: 11px !important;
        line-height: 1.6 !important; /* IMPROVED: Better readability */
        margin-top: 12px !important;
    }
    
    /* ═══ CATEGORY CAROUSEL - HORIZONTAL SCROLL ═══ */
    .category-carousel-section {
        margin-bottom: 20px !important;
    }
    
    .category-carousel-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    
    .category-carousel-container::-webkit-scrollbar {
        display: none !important;
    }
    
    .category-carousel {
        display: flex !important;
        gap: 12px !important;
        padding: 8px 0 !important;
    }
    
    .category-video-item {
        flex: 0 0 140px !important;
        width: 140px !important;
    }
    
    .category-video-thumbnail {
        height: 80px !important;
    }
    
    /* ═══ TOUCH INTERACTIONS & FEEDBACK ═══ */
    * {
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Re-enable tap highlight for interactive elements */
    .video-item,
    .btn,
    .nav-link,
    .mobile-menu-link,
    .hamburger-menu-btn,
    .search-btn,
    .pagination a {
        -webkit-tap-highlight-color: rgba(255, 107, 53, 0.15) !important;
        touch-action: manipulation !important;
    }
    
    /* Touch active state */
    .touch-active {
        opacity: 0.85 !important;
        transform: scale(0.96) !important;
    }
    
    /* Ensure all interactive elements meet 44x44px minimum */
    button,
    a.btn,
    .nav-link,
    .mobile-menu-link,
    .search-btn,
    .hamburger-menu-btn,
    .mobile-menu-close,
    .pagination a,
    .video-item {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Video items - ensure they're easily tappable */
    .video-item {
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(255, 107, 53, 0.2) !important;
    }
    
    img {
        -webkit-user-drag: none !important;
        user-select: none !important;
    }
    
    /* ═══ PERFORMANCE OPTIMIZATIONS ═══ */
    
    /* GPU acceleration for better scroll performance */
    .video-grid,
    .video-item,
    .nav-list,
    .trending-carousel-track,
    .category-carousel-track {
        will-change: transform, scroll-position;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    /* Optimize image loading */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: optimize-quality;
    }
    
    /* Reduce repaints */
    .video-item,
    .video-thumbnail {
        contain: layout style paint;
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth !important;
    }
    
    /* Reduce motion for better performance */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ═══ SMALL PHONES (≤375px) ═══ */
@media (max-width: 375px) {
    .site-name-small {
        font-size: 18px !important;
    }
    
    .video-grid {
        gap: 8px !important;
    }
    
    .video-title {
        font-size: 11px !important;
    }
    
    .video-meta {
        font-size: 9px !important;
    }
    
    .nav-link {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

/* ═══ LANDSCAPE MODE ═══ */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-carousel {
        max-height: 200px !important;
    }
    
    .hero-slide {
        height: 200px !important;
    }
    
    .hero-section-compact {
        padding: 10px 15px !important;
    }
}

