/* MOBILE-FIRST CSS FOR IPHONE COMPATIBILITY */
/* This file completely overrides desktop styles on mobile */

@media (max-width: 768px) {
    /* RESET AND BASE */
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    
    html {
        font-size: 14px; /* Base font size for mobile */
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        font-size: 1rem; /* Use rem for scalability */
        line-height: 1.5;
        background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%) !important;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
        -webkit-font-smoothing: antialiased;
        width: 100vw;
        min-height: 100vh;
    }
    
    /* CONTAINER */
    .container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 12px;
        box-sizing: border-box;
    }
    
    /* HEADER - Fix oversized header */
    .header, header {
        width: 100% !important;
        margin: 0 !important;
        padding: 20px 15px !important;
        text-align: center;
        background: linear-gradient(135deg, #1a2332 0%, #2d4a3e 100%) !important;
        border-radius: 0 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
        margin-bottom: 20px !important;
    }
    
    .header h1 {
        font-size: 1.8rem !important;
        margin: 0 0 8px 0 !important;
        color: white;
        font-weight: 700;
        line-height: 1.2;
    }
    
    .subtitle {
        font-size: 1rem !important;
        margin: 0 !important;
        color: rgba(255,255,255,0.8);
        font-weight: 400;
        line-height: 1.3;
        margin: 0;
    }
    
    /* TAB NAVIGATION - Fix oversized tabs */
    .tab-navigation {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
        margin: 0 0 20px 0 !important;
        padding: 0 10px !important;
    }
    
    .tab-button {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 12px 8px !important;
        margin: 0 !important;
        font-size: 0.85rem !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        background: transparent !important;
        border: 2px solid #4CAF50 !important;
        color: white !important;
        font-weight: 600 !important;
        letter-spacing: 0.5px !important;
        transition: all 0.3s ease !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    .tab-button.active {
        background: #4CAF50 !important;
        color: white !important;
        box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4) !important;
    }
    
    .tab-button:hover, .tab-button:active {
        background: rgba(76, 175, 80, 0.2) !important;
        transform: none !important; /* Disable transform on mobile */
    }
    
    .tab-button.active {
        background: rgba(76, 175, 80, 0.3) !important;
        border-color: #66BB6A !important;
    }
    
    .tab-button:hover {
        background: rgba(255,255,255,0.1) !important;
    }
    
    /* CARDS */
    .card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 15px 0 !important;
        padding: 12px !important;
        background: rgba(255,255,255,0.95) !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
        box-sizing: border-box;
    }
    
    .card h2, .card h3 {
        font-size: 1.1rem !important;
        margin: 0 0 10px 0 !important;
        color: #333;
    }
    
    /* BUTTONS */
    .btn, button, input[type="submit"] {
        width: 100% !important;
        padding: 12px 16px !important;
        margin: 5px 0 !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
        border-radius: 8px !important;
        border: none !important;
        background: #4CAF50 !important;
        color: white !important;
        text-align: center !important;
        cursor: pointer;
        transition: background 0.2s ease;
        box-sizing: border-box;
        -webkit-appearance: none;
        appearance: none;
        touch-action: manipulation;
    }
    
    .btn:hover, button:hover {
        background: #45a049 !important;
    }
    
    .btn.secondary {
        background: #666 !important;
    }
    
    .btn.danger {
        background: #f44336 !important;
    }
    
    /* FORM INPUTS */
    input, select, textarea {
        width: 100% !important;
        padding: 12px !important;
        margin: 5px 0 !important;
        font-size: 16px !important; /* Prevents iOS zoom */
        min-height: 44px !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        background: white !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    input:focus, select:focus, textarea:focus {
        border-color: #4CAF50 !important;
        outline: none !important;
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.3) !important;
    }
    
    /* FORM GROUPS */
    .form-group {
        width: 100% !important;
        margin: 0 0 15px 0 !important;
    }
    
    .form-group label {
        display: block !important;
        margin: 0 0 5px 0 !important;
        font-weight: 600 !important;
        color: #333 !important;
        font-size: 0.9rem !important;
    }
    
    /* GRID LAYOUTS */
    .form-grid, .stats-grid, .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    /* TABLES */
    table {
        width: 100% !important;
        font-size: 0.8rem !important;
        border-collapse: collapse !important;
        margin: 10px 0 !important;
    }
    
    table th, table td {
        padding: 8px 4px !important;
        text-align: left !important;
        border-bottom: 1px solid #ddd !important;
    }
    
    table th {
        background: #f5f5f5 !important;
        font-weight: 600 !important;
    }
    
    /* MODALS */
    .modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0,0,0,0.8) !important;
        z-index: 1000 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 10px !important;
        box-sizing: border-box;
    }
    
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90% !important;
        background: white !important;
        border-radius: 8px !important;
        padding: 15px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
        position: relative !important;
    }
    
    .modal h3 {
        font-size: 1.1rem !important;
        margin: 0 0 15px 0 !important;
    }
    
    /* MOBILE MODAL CLOSE BUTTON */
    .close, .modal .close {
        position: absolute !important;
        top: 10px !important;
        right: 15px !important;
        font-size: 28px !important;
        font-weight: bold !important;
        color: #666 !important;
        cursor: pointer !important;
        z-index: 1001 !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(0,0,0,0.1) !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    }
    
    .close:hover, .modal .close:hover {
        background: rgba(0,0,0,0.2) !important;
        color: #000 !important;
    }
    
    /* MOBILE MODAL BACKDROP CLOSE */
    .modal {
        cursor: pointer !important;
    }
    
    .modal-content {
        cursor: default !important;
    }
    
    /* COMPETITION SECTION */
    .competition-section {
        width: 100% !important;
        margin: 10px 0 !important;
        padding: 10px !important;
        background: rgba(255,255,255,0.1) !important;
        border-radius: 8px !important;
    }
    
    .competition-section h3 {
        font-size: 1rem !important;
        color: white !important;
        margin: 0 0 10px 0 !important;
    }
    
    /* STATISTICS CARDS */
    .stats-card, .summary-card {
        width: 100% !important;
        margin: 5px 0 !important;
        padding: 10px !important;
        background: white !important;
        border-radius: 6px !important;
        text-align: center !important;
    }
    
    .stats-card h4, .summary-card h4 {
        font-size: 0.8rem !important;
        margin: 0 0 5px 0 !important;
        color: #666 !important;
    }
    
    .stats-card .value, .summary-card .value {
        font-size: 1.2rem !important;
        font-weight: 700 !important;
        color: #333 !important;
    }
    
    /* HIDE DESKTOP-ONLY ELEMENTS */
    .desktop-only {
        display: none !important;
    }
    
    /* UTILITY CLASSES */
    .text-center { text-align: center !important; }
    .text-left { text-align: left !important; }
    .text-right { text-align: right !important; }
    .mb-10 { margin-bottom: 10px !important; }
    .mb-15 { margin-bottom: 15px !important; }
    .p-10 { padding: 10px !important; }
    .w-100 { width: 100% !important; }
    
    /* SPECIFIC MOBILE FIXES */
    .tab-content {
        width: 100% !important;
        padding: 0 !important;
    }
    
    .section {
        margin: 0 0 20px 0 !important;
        padding: 0 !important;
    }
    
    /* PREVENT HORIZONTAL SCROLL */
    body, html, .container, .tab-content {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* TOUCH IMPROVEMENTS */
    button, .btn, .tab-button {
        -webkit-tap-highlight-color: rgba(76, 175, 80, 0.3) !important;
        user-select: none;
    }

    /* GOALS & ASSISTS MOBILE LAYOUT */
    .goals-assists-section {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        margin-top: 15px !important;
    }

    .goals-assists-section > div {
        width: 100% !important;
        margin: 0 !important;
        padding: 15px !important;
        border-radius: 8px !important;
    }

    /* LEADERBOARD MOBILE STYLING */
    #goals-assists-leaderboard > div {
        padding: 12px !important;
        margin-bottom: 8px !important;
        border-radius: 8px !important;
        font-size: 0.9rem !important;
    }

    #goals-assists-leaderboard .medal {
        font-size: 20px !important;
        min-width: 30px !important;
    }

    /* FORM INPUTS IN GOALS SECTION */
    .goals-assists-section input,
    .goals-assists-section select,
    .goals-assists-section button {
        width: 100% !important;
        margin: 5px 0 !important;
        padding: 10px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
    }

    /* STATISTICS GRID MOBILE */
    .goals-assists-section .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
    }

    .goals-assists-section .stats-card {
        padding: 8px !important;
        text-align: center !important;
        background: white !important;
        border-radius: 6px !important;
        font-size: 0.8rem !important;
    }

    /* VIDEO SECTION MOBILE */
    .video-library-container {
        padding: 10px !important;
    }

    #video-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
        gap: 8px !important;
    }

    .video-card {
        border-radius: 6px !important;
        overflow: hidden !important;
    }

    /* CHARTS MOBILE */
    .chart-container {
        width: 100% !important;
        height: 250px !important;
        margin: 10px 0 !important;
    }

    /* TRAINING/MATCH SECTIONS MOBILE */
    .tab-content > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* HIDE COMPLEX LAYOUTS ON MOBILE */
    @media (max-width: 480px) {
        .desktop-complex {
            display: none !important;
        }
        
        /* Simplify headers */
        h1 { font-size: 1.5rem !important; }
        h2 { font-size: 1.3rem !important; }
        h3 { font-size: 1.1rem !important; }
        h4 { font-size: 1rem !important; }
    }
}
