/* Essence Wars Report Styles */

:root {
    /* Dark theme (default) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-hover: #1f4287;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a4e;
    --accent: #e94560;
    --success: #00d26a;
    --warning: #ffc107;
    --danger: #dc3545;

    /* Faction colors */
    --argentum: #D4AF37;
    --symbiote: #7FFF00;
    --obsidion: #00FFFF;
    --neutral: #B87333;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #e8e8e8;
    --text-primary: #1a1a2e;
    --text-secondary: #666666;
    --border-color: #dddddd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.report-header {
    background: var(--bg-secondary);
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.5rem;
    color: var(--accent);
    font-weight: 700;
}

.report-type {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 1rem;
}

.header-meta {
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.header-meta .run-id {
    display: block;
    font-family: monospace;
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    background: var(--bg-secondary);
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 1rem 1.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Content */
.content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
}

.metric-card.wide {
    grid-column: span 2;
    justify-content: center;
}

.metric-icon {
    font-size: 2rem;
    color: var(--accent);
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.metric-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.metric-card.status-success .metric-value { color: var(--success); }
.metric-card.status-warning .metric-value { color: var(--warning); }
.metric-card.status-balanced .metric-value { color: var(--success); }

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card, .chart-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.chart-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.chart-container {
    min-height: 300px;
}

/* Warnings */
.warnings-section {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid var(--warning);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.warnings-section h3, .warnings-section h4 {
    color: var(--warning);
    margin-bottom: 1rem;
}

.warning-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 193, 7, 0.2);
}

.outlier-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.outlier-item {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.outlier-item.high { border-left: 3px solid var(--danger); }
.outlier-item.low { border-left: 3px solid var(--warning); }

/* Tables */
.table-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.table-section h3 {
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
}

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

.deck-table th, .deck-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.deck-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.deck-table tr:hover {
    background: var(--bg-hover);
}

.deck-cell .commander-name {
    font-weight: 600;
    display: block;
}

.deck-cell .deck-id {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Faction badges */
.faction-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.faction-argentum { background: rgba(212, 175, 55, 0.2); color: var(--argentum); }
.faction-symbiote { background: rgba(127, 255, 0, 0.2); color: var(--symbiote); }
.faction-obsidion { background: rgba(0, 255, 255, 0.2); color: var(--obsidion); }
.faction-neutral { background: rgba(184, 115, 51, 0.2); color: var(--neutral); }

/* Indicators */
.indicator {
    font-weight: bold;
    margin-right: 0.5rem;
}

.indicator.high { color: var(--danger); }
.indicator.low { color: var(--warning); }
.indicator.balanced { color: var(--success); }

/* Matchup cells */
.matchup-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.matchup-good { color: var(--success); }
.matchup-bad { color: var(--danger); }
.matchup-rate {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Run info */
.run-info {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.run-info h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.run-info p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.run-info strong {
    color: var(--text-primary);
}

/* Footer */
.report-footer {
    background: var(--bg-secondary);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

/* Persistent outliers section */
.persistent-outliers {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.persistent-outliers h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.persistent-outliers p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.persistent-outliers ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.persistent-outliers li {
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border-left: 3px solid var(--accent);
}

/* Status colors for table cells */
.status-success { color: var(--success); font-weight: 600; }
.status-warning { color: var(--warning); font-weight: 600; }
.status-danger { color: var(--danger); font-weight: 600; }

/* Links in tables */
.deck-table a {
    color: var(--accent);
    text-decoration: none;
}

.deck-table a:hover {
    text-decoration: underline;
}

/* Tuning tab styles */
.experiment-selector {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.experiment-selector label {
    margin-right: 0.5rem;
    color: var(--text-secondary);
}

.experiment-selector select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

.experiment-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.experiment-panel {
    margin-bottom: 2rem;
}

.experiment-header {
    margin-bottom: 1rem;
}

.experiment-header h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.experiment-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.mode-badge {
    background: var(--accent);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.version {
    font-family: monospace;
    color: var(--text-secondary);
}

.chart-card.full-width {
    grid-column: span 2;
}

.convergence-analysis {
    margin: 1rem 0;
}

.convergence-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.convergence-status.converged {
    background: rgba(0, 210, 106, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.convergence-status.in-progress {
    background: rgba(255, 193, 7, 0.15);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.experiment-results {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

.experiment-results h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.results-grid {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.result-item {
    display: flex;
    flex-direction: column;
}

.result-item .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.result-item .value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comparison-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.comparison-section h3 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.experiments-table-container {
    margin-top: 1.5rem;
}

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

.data-table th, .data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    cursor: pointer;
}

.data-table th:hover {
    color: var(--text-primary);
}

.data-table tr:hover {
    background: var(--bg-hover);
}

.tag-cell {
    font-family: monospace;
    font-size: 0.85rem;
}

.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* ELO tab styles */
.chart-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.trend-up { color: var(--success); font-weight: bold; }
.trend-down { color: var(--danger); font-weight: bold; }
.trend-stable { color: var(--text-secondary); }

.form-win { color: var(--success); font-weight: 600; margin: 0 1px; }
.form-loss { color: var(--danger); font-weight: 600; margin: 0 1px; }
.form-draw { color: var(--warning); font-weight: 600; margin: 0 1px; }

.history-section {
    margin-top: 2rem;
}

.history-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.history-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.history-header .deck-name {
    font-weight: 600;
    color: var(--text-primary);
}

.history-header .current-rating {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.history-item.history-win {
    background: rgba(0, 210, 106, 0.1);
}

.history-item.history-loss {
    background: rgba(220, 53, 69, 0.1);
}

.history-item.history-draw {
    background: rgba(255, 193, 7, 0.1);
}

.history-item .opponent {
    color: var(--text-secondary);
}

.history-item .delta {
    font-weight: 600;
}

.history-win .delta { color: var(--success); }
.history-loss .delta { color: var(--danger); }
.history-draw .delta { color: var(--warning); }

/* Research tab styles */
.research-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.research-tab {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.research-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.research-tab.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}

.research-panels {
    margin-top: 1rem;
}

.research-panel {
    display: none;
}

.research-panel.active {
    display: block;
}

.win-rate.balanced { color: var(--success); }
.win-rate.warning { color: var(--warning); }
.win-rate.imbalanced { color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
    .report-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-meta {
        text-align: center;
    }

    .tabs {
        overflow-x: auto;
        padding: 0 1rem;
    }

    .tab-btn {
        padding: 0.75rem 1rem;
        white-space: nowrap;
    }

    .content {
        padding: 1rem;
    }

    .metric-card.wide {
        grid-column: span 1;
    }
}
