/* Tshwane Chess Ratings - Brand Aligned Styles */
:root {
    /* Tshwane Chess Brand Colors */
    --primary-color: #2A4B7C;        /* Deep Navy Blue - main brand color */
    --primary-dark: #1E3A6F;         /* Darker navy for hover states */
    --secondary-color: #3B2F6B;      /* Purple accent from tournament cards */
    --accent-color: #E53E3E;         /* Red accent for highlights */
    --success-color: #48BB78;        /* Green for active status */
    --warning-color: #ED8936;        /* Orange for warnings */
    --error-color: #E53E3E;          /* Red for errors */
    
    --text-primary: #2D3748;         /* Dark gray for primary text */
    --text-secondary: #4A5568;       /* Medium gray for secondary text */
    --text-muted: #718096;           /* Light gray for muted text */
    --text-white: #FFFFFF;           /* White text for dark backgrounds */
    
    --bg-primary: #FFFFFF;           /* Pure white backgrounds */
    --bg-secondary: #F7FAFC;         /* Very light blue-gray */
    --bg-muted: #EDF2F7;             /* Light gray for subtle backgrounds */
    --bg-navy: #2A4B7C;              /* Navy background for headers */
    --bg-gradient: linear-gradient(135deg, #3B2F6B 0%, #2A4B7C 100%); /* Purple to navy gradient */
    
    --border-color: #E2E8F0;         /* Light border color */
    --border-radius: 12px;           /* Rounded corners like the website */
    --border-radius-sm: 8px;         /* Smaller radius for buttons */
    
    /* Shadows matching the website's card style */
    --shadow-sm: 0 1px 3px 0 rgba(42, 75, 124, 0.1);
    --shadow-md: 0 4px 12px 0 rgba(42, 75, 124, 0.15);
    --shadow-lg: 0 10px 25px 0 rgba(42, 75, 124, 0.2);
    --shadow-card: 0 2px 8px 0 rgba(42, 75, 124, 0.12);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
    font-size: 14px;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(42, 75, 124, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(59, 47, 107, 0.03) 0%, transparent 50%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header with Chess Piece Background Effect */
.header {
    background: var(--bg-gradient);
    border-bottom: 3px solid var(--accent-color);
    padding: 2rem 0;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50" font-size="30" fill="white" opacity="0.05">♚♛♜♝♞♟</text></svg>');
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-10px); }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.logo h1 {
    color: var(--text-white);
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.logo .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.875rem;
    font-weight: 400;
    margin-top: 0.25rem;
}

.header-stats {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.stat {
    text-align: center;
    color: var(--text-white);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Search Section */
.search-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    padding: 2rem;
    margin-bottom: 2rem;
    border-left: 4px solid var(--accent-color);
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 75, 124, 0.1);
}

.search-btn {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
}

.search-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 75, 124, 0.1);
}

.clear-btn {
    padding: 0.75rem 1.5rem;
    background: var(--accent-color);
    color: var(--text-white);
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.clear-btn:hover {
    background: #D53535;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Stats Section with Circular Icons */
.stats-section {
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 45deg, transparent, rgba(42, 75, 124, 0.03), transparent);
    animation: rotate 8s linear infinite;
    z-index: 0;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card h3 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.stat-content {
    position: relative;
    z-index: 1;
}

.player-name {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.player-rating {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.big-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Results Section */
.results-section {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border-left: 4px solid var(--primary-color);
}

.results-header {
    background: var(--bg-gradient);
    padding: 1.5rem 2rem;
    color: var(--text-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.results-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.results-info span {
    font-size: 0.9rem;
    opacity: 0.9;
}

.export-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: var(--text-white);
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.export-btn:hover {
    background: #D53535;
    transform: translateY(-1px);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin: 0;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--primary-color);
}

.results-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.results-table th.sortable:hover {
    background: rgba(42, 75, 124, 0.05);
}

.results-table th.asc::after {
    content: '▲';
    position: absolute;
    right: 0.5rem;
    color: var(--primary-color);
    font-size: 0.7rem;
}

.results-table th.desc::after {
    content: '▼';
    position: absolute;
    right: 0.5rem;
    color: var(--primary-color);
    font-size: 0.7rem;
}

.results-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.results-table tbody tr {
    transition: all 0.3s ease;
}

.results-table tbody tr:hover {
    background: rgba(42, 75, 124, 0.03);
}

.results-table tbody tr:nth-child(even) {
    background: rgba(247, 250, 252, 0.5);
}

.results-table tbody tr:nth-child(even):hover {
    background: rgba(42, 75, 124, 0.05);
}

/* Loading and States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2rem;
    gap: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.page-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: var(--text-white);
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.page-btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

#pageInfo {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 1rem;
}

/* Footer */
.footer {
    background: var(--bg-gradient);
    color: var(--text-white);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

.footer p {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.footer a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.footer a:hover {
    color: var(--text-white);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-stats {
        flex-direction: row;
        gap: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-select {
        min-width: auto;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .results-table {
        font-size: 0.8rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 0.5rem 0.4rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .pagination {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 1rem 0;
    }
    
    .search-section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .results-header {
        padding: 1rem 1.5rem;
    }
}

/* Special Effects for Active Status */
.results-table td:nth-child(7) {
    font-weight: 600;
}

/* Chess piece icons in headers */
.results-header::before {
    content: '♚';
    font-size: 1.5rem;
    opacity: 0.3;
    margin-right: 0.5rem;
}