/* Professional Chess Analytics Dashboard */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables for consistent theming */
:root {
    --primary-green: #22c55e;
    --primary-blue: #3b82f6;
    --primary-purple: #8b5cf6;
    --danger-red: #ef4444;
    --warning-orange: #f59e0b;
    --dark-bg: #0f172a;
    --dark-card: #1e293b;
    --dark-border: #334155;
    --light-gray: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    margin: 0;
    padding: 0;
    color: var(--text-primary);
    line-height: 1.6;
    font-weight: 400;
}

.container-fluid {
    max-width: 1600px;
    margin: 0 auto;
}

/* Dashboard Hero Section */
.dashboard-hero {
    background: var(--gradient-primary);
    color: white;
    border-radius: 2rem;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='m36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    font-weight: 400;
}

.hero-features {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hero-visual {
    position: relative;
    z-index: 2;
}

.stats-preview {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    padding: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.preview-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.preview-stat:last-child {
    margin-bottom: 0;
}

.preview-stat .stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.preview-stat .stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--warning-orange);
}

.preview-stat .stat-label {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Control Panel */
.control-panel {
    background: white;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid #e2e8f0;
}

.control-grid {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: 2.5rem;
    align-items: start;
}

.control-step {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--gradient-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.step-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.input-group.compact {
    display: flex;
    gap: 0.75rem;
}

.input-group.compact input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.input-group.compact input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 1rem;
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.primary-btn {
    padding: 0.75rem 1.5rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--text-secondary);
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover:not(:disabled) {
    background: var(--light-gray);
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

/* Summary Stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: white;
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--gradient-primary);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Analytics Dashboard */
.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.performance-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.performance-card {
    background: white;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: var(--light-gray);
}

.card-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-actions .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.card-content {
    padding: 2rem;
}

/* Rating Performance Card */
.rating-metrics {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.metric {
    text-align: center;
}

.metric-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-value.peak {
    color: var(--primary-green);
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Results Card */
.win-rate-display {
    text-align: center;
}

.win-rate {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-green);
}

.win-rate-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.results-breakdown {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.result-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.result-item.wins .result-dot {
    background: var(--primary-green);
}

.result-item.draws .result-dot {
    background: var(--warning-orange);
}

.result-item.losses .result-dot {
    background: var(--danger-red);
}

.result-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Time Control Analysis */
.time-control-analysis {
    width: 100%;
}

.analysis-card {
    background: white;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.time-control-tabs {
    display: flex;
    gap: 0.5rem;
}

.time-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-tab.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.time-control-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.time-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: 1rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.875rem;
}

.bullet-icon {
    background: var(--danger-red);
}

.bullet-icon::after {
    content: "⚡";
    color: white;
    font-size: 1rem;
}

.blitz-icon {
    background: var(--warning-orange);
}

.blitz-icon::after {
    content: "🔥";
    color: white;
    font-size: 1rem;
}

.rapid-icon {
    background: var(--primary-blue);
}

.rapid-icon::after {
    content: "⏱️";
    color: white;
    font-size: 1rem;
}

.daily-icon {
    background: var(--primary-green);
}

.daily-icon::after {
    content: "📅";
    color: white;
    font-size: 1rem;
}

.stat-data {
    flex: 1;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-games {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Additional Analytics */
.additional-analytics {
    width: 100%;
}

.accuracy-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
}

.accuracy-metric {
    text-align: center;
}

.accuracy-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-purple);
}

.accuracy-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chart Containers */
.chart-container {
    height: 300px;
    position: relative;
}

.chart-container.large {
    height: 400px;
}

/* Status Messages */
.status-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin: 2rem 0;
    background: white;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid #e2e8f0;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination-btn {
    background: white;
    border: 2px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--light-gray);
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

/* Table Styles */
#pgn-container {
    background: white;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin: 2rem 0;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: var(--light-gray);
}

.table-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.table-meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.table-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    font-size: 1rem;
    color: var(--text-secondary);
    visibility: hidden;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-radius: 50%;
    border-top-color: var(--primary-blue);
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    background: var(--light-gray);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-secondary);
    vertical-align: middle;
}

tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

/* Result Indicators */
.result-win {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.result-loss {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.result-draw {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    color: #92400e;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.result-win::before,
.result-loss::before,
.result-draw::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.result-win::before {
    background: var(--primary-green);
}

.result-loss::before {
    background: var(--danger-red);
}

.result-draw::before {
    background: var(--warning-orange);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .performance-grid {
        grid-template-columns: 1fr;
    }
    
    .time-control-stats {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
        flex-direction: column;
        text-align: center;
    }
    
    .control-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .rating-metrics {
        flex-direction: column;
        gap: 1rem;
    }
    
    .results-breakdown {
        flex-direction: column;
        gap: 1rem;
    }
    
    .time-control-stats {
        grid-template-columns: 1fr;
    }
    
    .accuracy-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .table-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    #pgn-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 800px;
    }
}

@media (max-width: 480px) {
    .dashboard-hero {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .control-panel {
        padding: 1rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .metric-value, .stat-value {
        font-size: 1.5rem;
    }
}

/* Loading states and animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.analytics-dashboard > * {
    animation: fadeInUp 0.6s ease forwards;
}

.analytics-dashboard > *:nth-child(2) {
    animation-delay: 0.1s;
}

.analytics-dashboard > *:nth-child(3) {
    animation-delay: 0.2s;
}

.analytics-dashboard > *:nth-child(4) {
    animation-delay: 0.3s;
}