/* Final Mobile Optimizations - Modals & Compatibility */

/* Modal Mobile Optimization */
@media (max-width: 768px) {
    
    /* Modal overlay */
    .modal {
        padding: 0.75rem !important;
        backdrop-filter: blur(15px) !important;
        background: rgba(0, 0, 0, 0.85) !important;
    }
    
    /* Modal content */
    .modal-content {
        width: calc(100vw - 1.5rem) !important;
        max-width: none !important;
        max-height: calc(100vh - 1.5rem) !important;
        margin: 0 !important;
        background: rgba(30, 30, 30, 0.95) !important;
        backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-radius: 12px !important;
        padding: 1.5rem !important;
        overflow-y: auto !important;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6) !important;
    }
    
    /* Modal headers */
    .modal h2 {
        font-size: 1.3rem !important;
        font-weight: 700 !important;
        color: #ffffff !important;
        margin-bottom: 1.5rem !important;
        text-align: center !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding-bottom: 0.75rem !important;
    }
    
    /* Form groups in modals */
    .modal .form-group {
        margin-bottom: 1.25rem !important;
    }
    
    .modal .form-group label {
        display: block !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin-bottom: 0.5rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.3px !important;
    }
    
    /* Form inputs in modals */
    .modal .form-group input,
    .modal .form-group select {
        width: 100% !important;
        padding: 0.9rem 1rem !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-radius: 8px !important;
        background: rgba(0, 0, 0, 0.4) !important;
        color: white !important;
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        min-height: 50px !important;
        font-family: inherit !important;
        backdrop-filter: blur(5px) !important;
        transition: all 0.2s ease !important;
    }
    
    .modal .form-group input:focus,
    .modal .form-group select:focus {
        outline: none !important;
        border-color: rgba(102, 126, 234, 0.8) !important;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2) !important;
        background: rgba(0, 0, 0, 0.6) !important;
    }
    
    .modal .form-group input::placeholder {
        color: rgba(255, 255, 255, 0.5) !important;
        font-weight: 400 !important;
    }
    
    /* Modal actions */
    .modal-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        margin-top: 2rem !important;
        padding-top: 1rem !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
    
    /* Modal buttons */
    .modal .btn {
        width: 100% !important;
        padding: 0.9rem 1.2rem !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 0.9rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        min-height: 52px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3) !important;
        backdrop-filter: blur(10px) !important;
    }
    
    .modal .btn-primary {
        background: linear-gradient(45deg, #667eea, #764ba2) !important;
        color: white !important;
        border: 1px solid rgba(102, 126, 234, 0.5) !important;
    }
    
    .modal .btn-secondary {
        background: rgba(108, 117, 125, 0.8) !important;
        color: white !important;
        border: 1px solid rgba(108, 117, 125, 0.5) !important;
    }
    
    .modal .btn-danger {
        background: linear-gradient(45deg, #dc3545, #c82333) !important;
        color: white !important;
        border: 1px solid rgba(220, 53, 69, 0.5) !important;
    }
}

/* Dark mode adjustments for mobile */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .game-card,
    .stat-card,
    .modal-content,
    .controls {
        background: rgba(0, 0, 0, 0.6) !important;
        border-color: rgba(255, 255, 255, 0.15) !important;
    }
    
    .platform-btn,
    .filter-group select,
    .search-input {
        background: rgba(0, 0, 0, 0.5) !important;
        border-color: rgba(255, 255, 255, 0.2) !important;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Ensure sufficient color contrast */
    .game-title,
    .stat-number,
    .modal h2,
    .control-group h3 {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8) !important;
    }
    
    /* Focus indicators */
    button:focus,
    select:focus,
    input:focus,
    .btn:focus {
        outline: 2px solid #667eea !important;
        outline-offset: 2px !important;
    }
}

/* Final compatibility layer */
@media (max-width: 768px) {
    /* Override any conflicting styles from other CSS files */
    .games-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0.5rem !important;
        margin: 0 !important;
    }
    
    /* Ensure proper stacking context */
    .modal {
        z-index: 9999 !important;
    }
    
    .floating-add-btn {
        z-index: 1000 !important;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden !important;
    }
    
    .container {
        max-width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* Two column layout maintained for small screens */
@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .stats {
        grid-template-columns: 1fr !important;
    }
}
