/**
 * TCBCDC 500 Card Game Dashboard Styles
 */

:root {
    --primary: #2c5282;
    --primary-light: #4299e1;
    --secondary: #718096;
    --success: #38a169;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --purple: #805ad5;
    --pink: #d53f8c;
    --bg: #f7fafc;
    --card-bg: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
}

* { 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);
    color: var(--text);
    line-height: 1.6;
}

/* Suit icons */
.suit {
    font-weight: bold;
    margin-right: 2px;
}
.suit.hearts, .suit.diamonds { color: #e53e3e; }
.suit.spades, .suit.clubs { color: #1a202c; }
.suit.notrumps {
    background: linear-gradient(135deg, #e53e3e 50%, #1a202c 50%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 0.75em;
    font-weight: bold;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

.header h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.header p { opacity: 0.9; font-size: 1.1rem; }
.header a { color: white; text-decoration: underline; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.card h3 {
    color: var(--primary);
    margin: 1.5rem 0 0.5rem 0;
    font-size: 1.1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
}

.stat-box {
    background: var(--bg);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
}

.stat-box .value {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-box .label {
    color: var(--text-light);
    font-size: 0.75rem;
    line-height: 1.3;
}

.stat-box.success .value { color: var(--success); }
.stat-box.danger .value { color: var(--danger); }
.stat-box.warning .value { color: var(--warning); }
.stat-box.purple .value { color: var(--purple); }
.stat-box.pink .value { color: var(--pink); }

/* Win Levels */
.win-levels {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.win-level {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.win-level.hands { background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%); }
.win-level.sets { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); }
.win-level.games { background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); }

.win-level .rate { font-size: 2rem; font-weight: bold; }
.win-level .detail { font-size: 0.875rem; opacity: 0.9; }
.win-level .label { font-size: 0.75rem; opacity: 0.8; margin-top: 0.25rem; }

/* Filter Form */
.filter-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-form select, .filter-form button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

.filter-form select:focus { outline: none; border-color: var(--primary-light); }

.filter-form button {
    background: var(--primary);
    color: white;
    border: none;
    transition: background 0.2s;
}

.filter-form button:hover { background: var(--primary-light); }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; }
tr:hover { background: var(--bg); }

/* Progress Bar */
.progress-bar {
    background: var(--border);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar .fill.success { background: var(--success); }
.progress-bar .fill.warning { background: var(--warning); }
.progress-bar .fill.danger { background: var(--danger); }
.progress-bar .fill.primary { background: var(--primary); }

/* Grid Layouts */
.two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

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

/* Instructions */
.instructions {
    background: #ebf8ff;
    border-left: 4px solid var(--primary-light);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0 6px 6px 0;
}

.instructions h3 { margin-top: 0; color: var(--primary); }
.instructions ul { margin: 0.5rem 0 0 1.5rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #c6f6d5; color: #276749; }
.badge-danger { background: #fed7d7; color: #c53030; }
.badge-purple { background: #e9d8fd; color: #553c9a; }
.badge-pink { background: #fed7e2; color: #97266d; }
.badge-warning { background: #fefcbf; color: #975a16; }
.badge-blue { background: #bee3f8; color: #2c5282; }
.badge-secondary { background: #e2e8f0; color: #4a5568; }

/* Fun Stats */
.fun-stat {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.fun-stat .rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    width: 40px;
}

.fun-stat .player {
    font-weight: 600;
    flex: 1;
}

.fun-stat .detail {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Charts */
.chart-container {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 6px;
}

.line-chart {
    position: relative;
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.line-chart .bar {
    flex: 1;
    min-width: 8px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    position: relative;
    cursor: pointer;
    transition: opacity 0.2s;
}

.line-chart .bar:hover { opacity: 0.8; }

.line-chart .bar .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.2s;
}

.line-chart .bar:hover .tooltip { opacity: 1; }

.chart-x-axis {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px; /* Match the .line-chart gap */
    margin-top: 0.25rem;
    overflow: hidden;
    width: 100%;
}

.chart-x-axis .x-label {
    flex: 1;
    min-width: 8px; /* Match the .line-chart .bar min-width */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trend-legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.trend-legend span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.trend-legend .dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Wacky Titles */
.wacky-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wacky-title .emoji { font-size: 1.5rem; }

/* Highlight Box */
.highlight-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 0.5rem;
}

.highlight-box .big { font-size: 2rem; font-weight: bold; }
.highlight-box .label { opacity: 0.9; font-size: 0.875rem; }

/* Explanation */
.explanation {
    background: #fffaf0;
    border-left: 4px solid var(--warning);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .two-col, .three-col { grid-template-columns: 1fr; }
    .header h1 { font-size: 1.5rem; }
    .stat-box .value { font-size: 1.5rem; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-form select, .filter-form button { width: 100%; }
    .win-levels { grid-template-columns: 1fr; }
}
