/* AI CONTEXT: Display Page Styles
   PURPOSE: Styles for the display / dashboard page (display.html)
   DEPENDENCIES: common.css
   PATTERNS: Component-scoped CSS */

h1 { text-align: center; color: #1a237e; margin-bottom: 10px; }

/* ── Motor/Rival team-name mapping (top of page) ──────────────────────── */
#team-mapping { max-width: 960px; margin: 0 auto 10px; font-size: 0.9em; }
.team-mapping-row { text-align: center; color: #555; padding: 4px 10px; }
.team-mapping-fallback { color: #c62828; font-weight: 700; background: #fdecea; border: 1px solid #f5c6cb; border-radius: 6px; padding: 8px 12px; }
.team-mapping-ids { text-align: center; color: #888; font-size: 0.85em; font-family: monospace; padding: 2px 10px; }

/* ── Opta match-summary scoreboard (top of page) ──────────────────────── */
#opta-summary { max-width: 960px; margin: 0 auto 16px; }
.opta-summary-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); font-size: 0.92em; }
.opta-summary-table th, .opta-summary-table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid #e6e8f2; }
.opta-summary-table thead th { color: #1a237e; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 2px solid #c5cae9; background: #f3f5ff; }
.opta-summary-table tbody tr:last-child td { border-bottom: none; }
.opta-summary-team { text-align: left; font-weight: 700; }
.opta-summary-team-motor { color: #3f51b5; }
.opta-summary-team-rival { color: #607d8b; }
.opta-summary-empty { text-align: center; color: #888; font-style: italic; margin: 10px 0; }

/* ── Station presence panel (collapsible, top of page) ───────────────── */
.presence-panel { max-width: 960px; margin: 0 auto 16px; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow: hidden; }
.presence-summary { cursor: pointer; padding: 10px 16px; font-weight: 700; color: #1a237e; list-style: none; user-select: none; }
.presence-summary::-webkit-details-marker { display: none; }
.presence-summary::before { content: '▸ '; opacity: 0.6; }
.presence-panel[open] .presence-summary::before { content: '▾ '; }
.presence-body { display: flex; flex-direction: column; padding: 4px 8px 10px; }
.presence-row { display: grid; grid-template-columns: 16px minmax(160px, 1fr) 64px 44px auto; gap: 12px; align-items: center; padding: 7px 10px; border-top: 1px solid #f0f0f0; font-size: 0.92em; }
.presence-dot { width: 10px; height: 10px; border-radius: 50%; }
.presence-row.is-present .presence-dot { background: #2e7d32; box-shadow: 0 0 4px rgba(46,125,50,0.6); }
.presence-row.is-absent  .presence-dot { background: #bdbdbd; }
.presence-row.is-absent { opacity: 0.55; }
.presence-name { font-weight: 600; color: #333; }
.presence-time { font-variant-numeric: tabular-nums; color: #1a237e; font-weight: 600; }
.presence-half { color: #666; font-size: 0.9em; }
.presence-state { color: #777; font-size: 0.85em; }
.presence-row.is-present .presence-state { color: #2e7d32; }

/* ── AI Analysis section ─────────────────────────────────────────────── */
#ai-analysis-section { background: #1a237e; color: #fff; border-radius: 8px; margin: 0 auto 20px; padding: 14px 20px; max-width: 960px; }
#ai-analysis-header { display: flex; align-items: center; justify-content: space-between; }
#ai-analysis-header span { font-size: 1.1em; font-weight: bold; }
#ai-analyze-btn { padding: 6px 18px; background: #fff; color: #1a237e; border: none; border-radius: 16px; cursor: pointer; font-weight: bold; font-size: 0.9em; transition: background 0.2s; }
#ai-analyze-btn:hover { background: #e8eaf6; }
#ai-analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#ai-recommendations { margin-top: 14px; }
#ai-recommendations-text { font-size: 0.97em; line-height: 1.6; white-space: pre-wrap; }
#ai-batch-details { margin-top: 10px; }
#ai-batch-details summary { cursor: pointer; font-size: 0.85em; opacity: 0.8; }
#ai-batch-insights { margin-top: 8px; display: grid; gap: 8px; }
.ai-batch-card { background: rgba(255,255,255,0.1); border-radius: 6px; padding: 10px 14px; font-size: 0.85em; line-height: 1.5; }
.ai-batch-card strong { display: block; margin-bottom: 4px; opacity: 0.85; }
#ai-recommendations-text p, #ai-batch-insights p { margin: 0 0 6px; }
#ai-recommendations-text ul, #ai-batch-insights ul { margin: 4px 0 6px 18px; padding: 0; }
#ai-recommendations-text li, #ai-batch-insights li { margin-bottom: 4px; }
#ai-timestamp { margin-top: 10px; font-size: 0.75em; opacity: 0.6; text-align: right; }
#ai-loading { margin-top: 10px; font-size: 0.9em; opacity: 0.8; }
#ai-error { margin-top: 10px; color: #ff8a80; font-size: 0.9em; }

/* ── Comments summary (glance-value digest, right above the comment feed) ── */
#comments-summary-section { background: #37474f; color: #fff; border-radius: 8px; margin: 10px auto; padding: 12px 20px; max-width: 960px; }
#comments-summary-header { display: flex; align-items: center; justify-content: space-between; }
#comments-summary-header span { font-size: 1em; font-weight: bold; }
#comments-summarize-btn { padding: 6px 18px; background: #fff; color: #37474f; border: none; border-radius: 16px; cursor: pointer; font-weight: bold; font-size: 0.9em; transition: background 0.2s; }
#comments-summarize-btn:hover { background: #eceff1; }
#comments-summarize-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#comments-summary-text { margin: 10px 0 0; font-size: 0.95em; line-height: 1.5; }
#comments-summary-text:empty { display: none; }
#comments-summary-loading { margin-top: 10px; font-size: 0.9em; opacity: 0.8; }
#comments-summary-error { margin-top: 10px; color: #ff8a80; font-size: 0.9em; }
.match-selector-container { text-align: center; margin-bottom: 20px; }
select#match-selector { padding: 8px; font-size: 1rem; border-radius: 4px; border: 1px solid #ccc; min-width: 200px; }

#results-container { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); margin: 20px auto; }

/* ── Comments feed — chronological, bordered by station ──────────────── */
#comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 25px; }
.cm-empty { color: #888; font-style: italic; margin: 0; }
.cm-card {
    padding: 10px 14px;
    background: #fafbff;
    border-left: 4px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cm-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.cm-station { font-weight: 700; color: #1a237e; font-size: 0.9em; }
.cm-time { color: #888; font-size: 0.82em; }
.cm-text { margin: 0; color: #333; white-space: pre-wrap; }

/* ── Table ──────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; font-size: 0.9em; }
th { background: #e8eaf6; color: #1a237e; font-weight: bold; }
tr:nth-child(even) { background: #f9f9f9; }
.event-team-motor { color: #3f51b5; font-weight: bold; }
.event-team-rival { color: #607d8b; font-weight: bold; }

/* ── Controls ───────────────────────────────────────────────────────── */
.controls { text-align: center; margin-bottom: 20px; }
.controls button { padding: 10px 15px; font-size: 1em; border-radius: 5px; cursor: pointer; border: none; color: #fff; background: #2196F3; margin: 0 5px; }
.controls button:hover { background: #1976D2; }

#loading-message, #loading-summary-message, #loading-interval-summaries-message { text-align: center; font-style: italic; color: #555; padding: 10px 0; display: none; }
#status-indicator { text-align: center; font-size: 0.8em; color: #888; margin-top: 5px; }
/* Refresh failed — the board on screen is stale, so this must not read as chrome. */
#status-indicator.status-error { color: #c62828; font-weight: 700; font-size: 0.95em; background: #fdecea; border: 1px solid #f5c6cb; border-radius: 6px; padding: 6px 10px; }

/* ── Station groups — one full-width band per view (like Full-Match Summary) ── */
#station-groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.ds-group {
    padding: 15px;
    background: #e8eaf6;
    border-radius: 8px;
}
.ds-group-title {
    margin: 0 0 12px;
    color: #1a237e;
    font-size: 1.2em;
    font-weight: bold;
    border-bottom: 1px solid #c5cae9;
    padding-bottom: 6px;
}
/* Per-side row header inside a shared view (Motor / Przeciwnik). */
.ds-side-title {
    margin: 14px 0 8px;
    color: #1a237e;
    font-size: 1.02em;
    font-weight: bold;
}
.ds-tile-body { margin-bottom: 6px; }
.ds-tile-body:last-child { margin-bottom: 0; }

/* Sub-grouping inside a single view tile (transitions: PDA / wings / PDO). */
.ds-subgroup { margin-bottom: 12px; }
.ds-subgroup:last-child { margin-bottom: 0; }
.ds-subgroup-title {
    margin: 4px 0 8px;
    color: #3f51b5;
    font-size: 0.95em;
    font-weight: 700;
}

/* Structures: each section on its own white card for table readability. */
.ds-struct-section {
    background: #fff;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.ds-struct-section:last-child { margin-bottom: 0; }

.ds-stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ds-stat {
    flex: 1 1 90px;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}
.ds-stat-icon { display: block; font-size: 2.3em; line-height: 1.1; }
.ds-stat-label { font-size: 1.05em; font-weight: 600; color: #444; }
.ds-stat-value { color: #3f51b5; font-size: 1.35em; }
.ds-stat-note { margin: 4px 0 0; color: #888; font-size: 0.85em; }

.ds-sector-block { margin-top: 8px; }
.ds-sector-block .ds-stat-row { margin-top: 4px; }
.ds-sector-block .ds-stat { flex: 1 1 60px; min-width: 52px; padding: 6px; }

/* ── Entries: collapsible player details (leaderboard per zone) ─────────── */
.ds-entries-details { margin-top: 12px; }
.ds-entries-details > summary {
    cursor: pointer;
    color: #3f51b5;
    font-size: 0.9em;
    font-weight: 600;
    padding: 4px 0;
}
.ds-entries-details > summary:hover { color: #1a237e; }

.ds-zone-panel {
    margin-top: 10px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e6e8f2;
}
.ds-zone-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    background: #3f51b5;
    color: #fff;
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 10px;
}

.ds-lead-group { margin-top: 12px; }
.ds-lead-group:first-of-type { margin-top: 0; }
.ds-lead-title {
    margin: 0 0 6px;
    color: #777;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ds-lead-empty { margin: 0; color: #999; font-style: italic; font-size: 0.85em; }

.ds-lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ds-lead-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; }
.ds-lead-row:nth-child(even) { background: #fafbff; }
.ds-lead-row:first-child { background: #e8eaf6; }

.ds-lead-rank {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #c5cae9;
    color: #1a237e;
    font-size: 0.72em;
    font-weight: 700;
}
.ds-lead-row:first-child .ds-lead-rank { background: #3f51b5; color: #fff; }

.ds-lead-who { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 0.92em; color: #333; }
.ds-lead-player { font-weight: 600; }
.ds-lead-arrow { color: #9fa8da; font-weight: 700; }

.ds-lead-count {
    flex: 0 0 auto;
    min-width: 22px;
    padding: 2px 9px;
    border-radius: 999px;
    background: #1a237e;
    color: #fff;
    font-size: 0.85em;
    font-weight: 700;
    text-align: center;
}
.ds-lead-row:first-child .ds-lead-count { background: #3f51b5; }
