/* =====================================================
   EPL NEWS HUB - MASTER MOBILE OPTIMIZATION STYLESHEET
   ===================================================== */

/* ==================== FOUNDATION ==================== */

/* Viewport and Base Settings */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* Prevent horizontal overflow globally */
html {
    overflow-x: hidden !important;
    width: 100% !important;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: pan-y;
}

/* Box sizing for all elements */
*, *::before, *::after {
    box-sizing: border-box !important;
}

/* ==================== MOBILE BREAKPOINTS ==================== */

/* Small Mobile (320px - 480px) */
@media (max-width: 480px) {
    body {
        font-size: 14px !important;
    }
    
    .container, .main-content, .content-wrapper {
        padding: 10px !important;
        margin: 0 !important;
    }
}

/* Standard Mobile (481px - 768px) */
@media (max-width: 768px) {
    
    /* ========== TYPOGRAPHY ========== */
    body {
        font-size: 16px !important;
        line-height: 1.6 !important;
    }
    
    h1 {
        font-size: 1.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 15px !important;
        word-wrap: break-word !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        line-height: 1.3 !important;
        margin-bottom: 10px !important;
    }
    
    h4 {
        font-size: 1.1rem !important;
    }
    
    p {
        font-size: 1rem !important;
        line-height: 1.6 !important;
        margin-bottom: 12px !important;
    }
    
    /* ========== LAYOUT CONTAINERS ========== */
    .main-content,
    .content-wrapper,
    .container,
    .page-container {
        width: 100% !important;
        max-width: 100vw !important;
        padding: 15px !important;
        margin: 0 auto !important;
        overflow-x: hidden !important;
    }
    
    /* Remove side margins on mobile */
    .section, .article, .widget {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* ========== NAVIGATION ========== */
    .site-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 9999 !important;
        background: white !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }
    
    .header-content {
        padding: 10px 15px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .logo {
        max-width: 150px !important;
    }
    
    .logo img {
        height: 40px !important;
        width: auto !important;
    }
    
    .logo h1 {
        font-size: 1.2rem !important;
    }
    
    /* Hide desktop navigation */
    .main-nav, 
    .desktop-nav,
    .nav-links:not(.mobile-nav-links) {
        display: none !important;
    }
    
    /* Mobile menu button */
    .menu-btn, .mobile-menu-toggle {
        display: block !important;
        font-size: 1.5rem !important;
        padding: 10px !important;
        background: none !important;
        border: none !important;
        cursor: pointer !important;
    }
    
    /* ========== FORMS & INPUTS ========== */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        width: 100% !important;
        padding: 12px 15px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border: 2px solid #e0e0e0 !important;
        border-radius: 8px !important;
        margin-bottom: 15px !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    /* Better touch targets */
    input, select, textarea, button, a {
        min-height: 44px !important;
        touch-action: manipulation !important;
    }
    
    /* ========== BUTTONS ========== */
    button,
    .btn,
    .button,
    [type="submit"],
    [type="button"] {
        width: 100% !important;
        min-height: 48px !important;
        padding: 12px 20px !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        touch-action: manipulation !important;
        margin-bottom: 10px !important;
        display: block !important;
        text-align: center !important;
        transition: all 0.3s ease !important;
    }
    
    /* Button hover states for touch */
    button:active,
    .btn:active {
        transform: scale(0.98) !important;
        opacity: 0.9 !important;
    }
    
    /* ========== GRIDS & CARDS ========== */
    .grid,
    .tools-grid,
    .features-grid,
    .news-grid,
    .player-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 0 !important;
    }
    
    .card,
    .tool-card,
    .player-card,
    .news-card,
    .feature-card {
        width: 100% !important;
        margin-bottom: 15px !important;
        padding: 15px !important;
        border-radius: 12px !important;
    }
    
    /* Two column grids on larger phones */
    @media (min-width: 480px) and (max-width: 768px) {
        .grid-2col {
            grid-template-columns: repeat(2, 1fr) !important;
            gap: 10px !important;
        }
    }
    
    /* ========== TABLES ========== */
    table {
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -15px !important;
        padding: 0 15px !important;
    }
    
    /* Make tables scrollable with indicator */
    .table-scroll-container {
        position: relative !important;
        overflow-x: auto !important;
    }
    
    .table-scroll-container::after {
        content: '→' !important;
        position: absolute !important;
        right: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        background: rgba(255,255,255,0.9) !important;
        padding: 10px !important;
        font-size: 1.5rem !important;
        color: #666 !important;
        pointer-events: none !important;
    }
    
    /* Responsive table cells */
    th, td {
        padding: 8px !important;
        font-size: 0.875rem !important;
        white-space: nowrap !important;
    }
    
    /* ========== IMAGES & MEDIA ========== */
    img {
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
    }
    
    .hero-image,
    .featured-image,
    .article-image {
        width: 100% !important;
        height: auto !important;
        margin-bottom: 15px !important;
    }
    
    /* Lazy loading placeholder */
    img[loading="lazy"] {
        background: #f0f0f0 !important;
    }
    
    /* ========== MODALS & POPUPS ========== */
    .modal,
    .popup,
    .dialog {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px auto !important;
        padding: 20px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
    
    .modal-content,
    .popup-content {
        padding: 15px !important;
    }
    
    /* ========== SIDEBARS ========== */
    .sidebar,
    .aside,
    .widget-area {
        width: 100% !important;
        margin-top: 30px !important;
        padding: 0 !important;
    }
    
    /* Stack sidebars below main content */
    .content-with-sidebar {
        flex-direction: column !important;
    }
    
    .main-column {
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    /* ========== FOOTER ========== */
    .site-footer,
    footer {
        padding: 20px 15px !important;
    }
    
    .footer-columns {
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .footer-column {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* ========== SPECIFIC COMPONENTS ========== */
    
    /* Newsletter forms */
    .newsletter-form {
        flex-direction: column !important;
    }
    
    .newsletter-form input {
        width: 100% !important;
        margin-bottom: 10px !important;
    }
    
    /* Search bars */
    .search-container {
        width: 100% !important;
    }
    
    .search-input {
        width: 100% !important;
    }
    
    /* Social media icons */
    .social-icons {
        justify-content: center !important;
        gap: 15px !important;
    }
    
    .social-icon {
        font-size: 1.5rem !important;
        padding: 10px !important;
    }
    
    /* ========== FPL TOOLS SPECIFIC ========== */
    
    /* FPL Tool Containers */
    .fpl-container,
    .ai-container,
    .predictor-container,
    .simulator-container {
        padding: 15px !important;
        border-radius: 12px !important;
        margin: 10px 0 !important;
    }
    
    /* Player cards in FPL tools */
    .player-item,
    .squad-player {
        padding: 10px !important;
        margin-bottom: 10px !important;
        font-size: 0.9rem !important;
    }
    
    .player-stats {
        flex-wrap: wrap !important;
        gap: 5px !important;
    }
    
    .stat-item {
        min-width: 45% !important;
        padding: 5px !important;
        font-size: 0.8rem !important;
    }
    
    /* FPL formation display */
    .formation-display {
        transform: scale(0.8) !important;
        margin: 0 -20px !important;
    }
    
    /* Transfer simulator */
    .transfer-panel {
        flex-direction: column !important;
    }
    
    .squad-section,
    .market-section {
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    /* ========== PERFORMANCE OPTIMIZATIONS ========== */
    
    /* Reduce animations on mobile */
    * {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
    
    /* Disable hover effects on touch devices */
    @media (hover: none) {
        *:hover {
            transform: none !important;
            box-shadow: none !important;
        }
    }
    
    /* Hardware acceleration for smooth scrolling */
    .scrollable {
        -webkit-overflow-scrolling: touch !important;
        will-change: transform !important;
    }
    
    /* ========== UTILITY CLASSES ========== */
    
    /* Hide on mobile */
    .desktop-only,
    .hide-mobile {
        display: none !important;
    }
    
    /* Show on mobile */
    .mobile-only,
    .show-mobile {
        display: block !important;
    }
    
    /* Text alignment */
    .mobile-center {
        text-align: center !important;
    }
    
    /* Spacing helpers */
    .mobile-mt-0 { margin-top: 0 !important; }
    .mobile-mb-0 { margin-bottom: 0 !important; }
    .mobile-pt-0 { padding-top: 0 !important; }
    .mobile-pb-0 { padding-bottom: 0 !important; }
    
    /* Full width on mobile */
    .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ==================== TABLET OPTIMIZATION (769px - 1024px) ==================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95% !important;
        padding: 20px !important;
    }
    
    .grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    .sidebar {
        width: 300px !important;
    }
}

/* ==================== LANDSCAPE MOBILE ==================== */
@media (max-width: 768px) and (orientation: landscape) {
    .header-content {
        padding: 5px 15px !important;
    }
    
    .logo img {
        height: 30px !important;
    }
    
    .modal {
        max-height: 80vh !important;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .no-print,
    .navigation,
    .sidebar,
    .footer,
    .ads,
    button {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
    }
}

/* ==================== ACCESSIBILITY ==================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-width: 2px !important;
    }
    
    button, .btn {
        border: 2px solid currentColor !important;
    }
}

/* ==================== iOS SPECIFIC FIXES ==================== */
@supports (-webkit-touch-callout: none) {
    /* iOS Only */
    input, textarea, select {
        font-size: 16px !important; /* Prevent zoom */
    }
    
    /* Fix iOS bounce scrolling */
    .scrollable {
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Fix position fixed on iOS */
    .fixed-element {
        position: -webkit-sticky !important;
        position: sticky !important;
    }
}

/* ==================== ANDROID SPECIFIC FIXES ==================== */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Android browser specific */
    select {
        background-image: url('data:image/svg+xml;...') !important;
        background-position: right 10px center !important;
        background-repeat: no-repeat !important;
    }
}