/* ==========================================================================
   Players Page Optimized CSS - Mobile First Approach
   FIXED: Force white background + Responsive filters
   ========================================================================== */

/* CSS Variables for better maintenance and consistency */
:root {
    --primary-color: #e74c3c;
    --secondary-color: #667eea;
    --accent-color: #764ba2;
    --gold-color: #ffd700;
    --text-dark: #333;
    --text-light: #666;
    --text-muted: #999;
    --bg-light: #f8f9fa;
    --bg-card: #ffffff;
    --shadow-light: 0 5px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --transition: all 0.3s ease;
    --gradient-primary: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    --gradient-card: linear-gradient(135deg, var(--primary-color), #c0392b);
}

/* ✅ FORCE WHITE BACKGROUND ON ALL DEVICES - Override any dark mode */
html, body {
    background-color: #ffffff !important;
    color: #333 !important;
}

/* Main container always white background */
.players-section {
    background-color: #ffffff !important;
}

/* Reset and base styles */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    /* Optimize image loading */
    image-rendering: optimizeQuality;
    decoding: async;
    opacity: 1;
}

img.loaded {
    opacity: 1;
}

/* Header - Mobile First */
.players-header {
    background: var(--gradient-primary);
    color: white;
    padding: 80px 0 60px;
    text-align: center;
}

.players-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.players-header p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.5;
}

/* Main Section - FORCE WHITE */
.players-section {
    padding: 40px 0;
    background: #ffffff !important; /* Force white background */
}

/* ✅ OPTIMIZED RESPONSIVE FILTERS - Mobile First */
.filters-container {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 100%;
    overflow: hidden;
}

/* Search Bar - Mobile Optimized */
.search-bar {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 12px 45px 12px 16px;
    border: 2px solid #eee;
    border-radius: 25px;
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
    background: #ffffff;
    color: #333;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.1);
}

.search-bar i {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

/* Filters - Mobile First Responsive */
.filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.filter-select {
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--bg-card);
    color: #333;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.1);
}

/* Team Tabs - Mobile First Responsive */
.team-tabs {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 4px;
    box-shadow: var(--shadow-light);
    margin-bottom: 2rem;
    width: 100%;
    overflow: hidden;
}
/* Reset and base styles */
* {
    box-sizing: border-box;
}

/* ✅ KHÓA CUỘN NGANG - Prevent horizontal scroll */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative;
}

body {
    width: 100% !important;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 12px 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    color: var(--text-light);
    flex: 1;
    white-space: nowrap;
    text-align: center;
    min-height: 44px; /* Touch target */
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-button.active {
    background: var(--primary-color);
    color: white;
}

.tab-button:hover:not(.active) {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Team Content */
.team-content {
    display: none;
}

.team-content.active {
    display: block;
}

/* Players Grid - Mobile First Centered */
.players-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    justify-items: center;        
    justify-content: center;      
    padding: 0 1rem;
    max-width: 100%;             
    margin: 0 auto;              
}

/* Player Card - Optimized Mobile First */
.player-card {
    width: 100%;
    max-width: 340px;
    min-height: 460px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.2);
    will-change: transform;
    contain: layout paint;
}

.player-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

/* Captain Badge */
.captain-badge {
    position: absolute;
    top: -5px;
    left: 20px;
    background: linear-gradient(135deg, var(--gold-color), #f39c12);
    color: var(--text-dark);
    padding: 6px 12px;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.captain-badge i {
    font-size: 0.9rem;
    animation: pulse 2s infinite;
}

/* Player Avatar - Optimized */
.player-avatar {
    width: 100%;
    height: 240px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    contain: layout paint;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    opacity: 1;
    image-rendering: optimizeQuality;
    decoding: async;
}

.player-card:hover .player-avatar img {
    transform: scale(1.05);
}

.player-avatar .placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.player-number {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(10px) ;
    backdrop-filter: blur(10px);
    color: white;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 50%;
    min-width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: var(--transition);
}

.player-card:hover .player-number {
    background: rgba(231, 76, 60, 0.9);
    border-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

/* Player Info - Optimized spacing */
.player-info {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.player-header {
    text-align: center;
    border-bottom: 2px solid #f1f1f1;
    padding-bottom: 12px;
    flex-shrink: 0;
}

.player-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.2;
}

.player-position {
    background: var(--gradient-card);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
}

/* Player Stats - Optimized */
.player-stats {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    gap: 8px;
}

.primary-stats {
    flex-direction: column;
}

.stat-item {
    background: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.stat-item:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.height-stat .stat-icon {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.reach-stat .stat-icon {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.stat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.secondary-stats {
    flex-direction: column;
    gap: 6px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-light);
    font-size: 0.8rem;
    transition: var(--transition);
    word-break: break-word;
}

.detail-item:hover {
    background: #e9ecef;
    color: var(--text-dark);
}

.detail-item i {
    color: var(--primary-color);
    width: 12px;
    text-align: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Loading States */
.loading-players {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    font-size: 1rem;
    grid-column: 1 / -1;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
    grid-column: 1 / -1;
}

.no-results i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.no-results h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

/* Optimized fade-in animation */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Modal styles - Optimized */
.player-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    -webkit-backdrop-filter: blur(5px) ;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.player-modal {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-header {
    background: var(--gradient-primary);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
}

.modal-avatar {
    position: relative;
}

.modal-avatar img {
    width: 120px;
    height: 120px;
    border-radius: var(--border-radius);
    object-fit: cover;
}

.modal-number {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary-color);
    color: white;
    padding: 6px 10px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
}

.info-grid {
    display: grid;
    gap: 12px;
    width: 100%;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.info-label {
    font-weight: 600;
    color: var(--text-light);
}

.info-value {
    font-weight: 600;
    color: var(--text-dark);
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES - Mobile First Progressive Enhancement
   ========================================================================== */

/* ✅ iPhone SE, iPhone 12 mini (≥375px) */
@media (min-width: 23.4375em) {
    .tab-button {
        font-size: 1rem;
        padding: 12px 10px;
    }
    
    .search-input {
        font-size: 1rem;
    }
}

/* ✅ Small tablets, large phones landscape (≥576px) */
@media (min-width: 36em) {
    .players-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        justify-content: center;
        padding: 0;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* Filters row layout on small tablets */
    .filters {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .filter-select {
        flex: 1;
        min-width: 140px;
        max-width: 200px;
    }
    
    .filters-container {
        padding: 1.5rem;
    }
    
    .tab-button {
        font-size: 1rem;
        padding: 12px 16px;
    }
}

/* ✅ iPad Portrait, medium tablets (≥768px) */
@media (min-width: 48em) {
    .players-header {
        padding: 100px 0 70px;
    }
    
    .players-header h1 {
        font-size: 2.5rem;
    }
    
    .players-header p {
        font-size: 1.1rem;
    }
    
    .players-section {
        padding: 60px 0;
    }
    
    /* Horizontal filter layout */
    .filters-container {
        flex-direction: row;
        align-items: center;
        gap: 2rem;
        padding: 2rem;
    }
    
    .search-bar {
        flex: 1;
        min-width: 250px;
        max-width: 400px;
    }
    
    .filters {
        flex-direction: row;
        gap: 1rem;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }
    
    .filter-select {
        min-width: 140px;
        max-width: 180px;
        flex: 0 0 auto;
    }
    
    .team-tabs {
        width: fit-content;
        margin-left: auto;
        margin-right: auto;
        max-width: 600px;
    }
    
    .tab-button {
        padding: 15px 20px;
        font-size: 1.1rem;
        min-width: 120px;
    }
    
    .players-grid {
        justify-content: center;
        max-width: 1400px;
    }
    
    .player-card {
        min-height: 500px;
    }
    
    .player-avatar {
        height: 260px;
    }
    
    .primary-stats {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .stat-item {
        flex: 1;
        padding: 14px;
    }
    
    .player-info {
        padding: 18px;
        gap: 16px;
    }
    
    .modal-content {
        flex-direction: row;
        text-align: left;
    }
    
    .modal-avatar img {
        width: 150px;
        height: 150px;
    }
}

/* ✅ iPad Landscape, small laptops (≥1024px) */
@media (min-width: 64em) {
    .players-header {
        padding: 120px 0 80px;
    }
    
    .players-header h1 {
        font-size: 3rem;
    }
    
    .players-header p {
        font-size: 1.2rem;
    }
    
    .players-section {
        padding: 80px 0;
    }
    
    .filters-container {
        max-width: 1200px;
        margin: 0 auto 2rem;
        padding: 2rem 2.5rem;
    }
    
    .search-bar {
        max-width: 500px;
    }
    
    .filter-select {
        min-width: 160px;
        max-width: 200px;
    }
    
    .players-grid {
        grid-template-columns: repeat(auto-fill, minmax(340px, 340px));
        justify-content: center;
        gap: 2rem;
        max-width: 1600px;
        margin: 0 auto;
    }
    
    .player-card {
        width: 340px;
        min-height: 520px;
    }
    
    .player-avatar {
        height: 280px;
    }
    
    .player-info {
        padding: 20px;
        gap: 18px;
    }
    
    .player-stats {
        gap: 16px;
    }
    
    .stat-item {
        padding: 14px;
        gap: 10px;
    }
    
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .player-number {
        font-size: 1.8rem;
        min-width: 60px;
        height: 60px;
    }
}

/* ✅ Large desktop screens (≥1440px) */
@media (min-width: 90em) {
    .filters-container {
        max-width: 1400px;
        padding: 2.5rem 3rem;
    }
    
    .players-grid {
        max-width: 1800px;
        gap: 2.5rem;
    }
}

/* ✅ iPhone Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .players-header {
        padding: 40px 0 30px;
    }
    
    .players-header h1 {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }
    
    .filters-container {
        padding: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .team-tabs {
        margin-bottom: 1.5rem;
    }
    
    .player-modal-overlay {
        padding: 0.5rem;
        align-items: flex-start;
        padding-top: 2rem;
    }
    
    .player-modal {
        max-height: 85vh;
    }
}

/* ==========================================================================
   OVERRIDE DARK MODE - FORCE WHITE BACKGROUND ON ALL DEVICES
   ========================================================================== */

/* ✅ Override dark mode completely */
@media (prefers-color-scheme: dark) {
    html, body {
        background-color: #ffffff !important;
        color: #333 !important;
    }
    
    .players-section {
        background-color: #ffffff !important;
    }
    
    .filters-container,
    .player-card,
    .team-tabs,
    .player-modal {
        background-color: #ffffff !important;
        color: #333 !important;
    }
    
    .search-input,
    .filter-select {
        background-color: #ffffff !important;
        color: #333 !important;
        border-color: #eee !important;
    }
}

/* ✅ Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .captain-badge i {
        animation: none;
    }
}

/* ✅ High contrast support */
@media (prefers-contrast: high) {
    .player-card {
        border: 2px solid var(--text-dark);
    }
    
    .player-position {
        border: 1px solid white;
    }
    
    .search-input,
    .filter-select {
        border-width: 3px;
    }
}
