/* ==========================================================================
 * tournaments/team_stats.css — วิเคราะห์ผลการแข่งของทีม (ใช้ร่วม: popup ใน index.php + หน้า team_stats.php)
 * สีกราฟ: ชุดสีที่ผ่านการตรวจตาบอดสีแล้ว (blue #2a78d6 / orange #eb6834 · diverging blue ↔ red #e34948)
 * ========================================================================== */
.t-ts {
    --ts-ink: var(--t-ink, #0f172a);
    --ts-muted: var(--t-muted, #64748b);
    --ts-line: var(--t-line, #e2e8f0);
    --ts-navy: var(--t-navy-2, #12305c);
    --ts-win: var(--t-green, #16a34a);
    --ts-pos: #2a78d6;      /* แต้มได้ / ชนะห่าง */
    --ts-neg: #e34948;      /* แพ้ห่าง (ขั้วตรงข้ามของ diverging) */
    --ts-lost: #eb6834;     /* แต้มเสีย */
    --ts-grid: #eef0f3;
    --ts-axis: #c3c2b7;
    display: flex; flex-direction: column; gap: 16px; color: var(--ts-ink);
}
.t-ts-loading, .t-ts-empty { padding: 30px 10px; text-align: center; color: var(--ts-muted); font-size: .9rem; }

/* นักกีฬาในทีม: คนที่ 1 ซ้าย / คนที่ 2 ขวา */
.t-ts-team { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; gap: 10px; }
.t-ts-team.is-single { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 6px; }
.t-ts-teamname { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: 84px; text-align: center; }
.t-ts-teamname b { font-size: 1.1rem; line-height: 1.3; color: var(--ts-navy); overflow-wrap: anywhere; }
.t-ts-level { display: inline-flex; padding: 2px 12px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: .76rem; font-weight: 600; }
.t-ts-team.is-single .t-ts-teamname { min-height: 0; }
.t-ts-person { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; text-align: center; color: inherit; text-decoration: none; }
.t-ts-person .t-ts-ava { position: relative; display: flex; align-items: center; justify-content: center; width: 84px; height: 84px; border-radius: 50%; overflow: hidden;
    background: #e2e8f0; color: #94a3b8; font-size: 2rem; border: 3px solid #fff; box-shadow: 0 6px 16px rgba(15, 23, 42, .14); }
.t-ts-person .t-ts-ava img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.t-ts-person b { font-size: .9rem; line-height: 1.3; overflow-wrap: anywhere; }
.t-ts-person small { font-size: .76rem; color: var(--ts-muted); }
a.t-ts-person:hover b { color: #2563eb; text-decoration: underline; }

.t-ts-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.t-ts-tile { padding: 10px 8px; border: 1px solid var(--ts-line); border-radius: 12px; text-align: center; background: #f8fafc; }
.t-ts-tile b { display: block; font-size: 1.25rem; line-height: 1.2; }
.t-ts-tile small { display: block; margin-top: 2px; font-size: .72rem; color: var(--ts-muted); }
.t-ts-tile.is-win b { color: var(--ts-win); }
.t-ts-rate { display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--ts-muted); }
.t-ts-rate b { color: var(--ts-ink); }
.t-ts-meter { flex: 1; height: 8px; border-radius: 99px; background: var(--ts-line); overflow: hidden; }
.t-ts-meter i { display: block; height: 100%; border-radius: 99px; background: var(--ts-win); }

.t-ts-insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.t-ts-insight { padding: 10px 12px; border-radius: 12px; font-size: .8rem; line-height: 1.45; background: #eff6ff; color: #1e3a8a; }
.t-ts-insight.is-close { background: #fff7ed; color: #9a3412; }
.t-ts-insight strong { display: block; font-size: .74rem; opacity: .8; }

/* ---- กราฟ ---- */
.t-ts-chart { position: relative; padding: 12px 12px 6px; border: 1px solid var(--ts-line); border-radius: 12px; background: #fff; }
.t-ts-chart h4, .t-ts-list h4 { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 6px; font-size: .9rem; color: var(--ts-navy); }
.t-ts-chart h4 small { font-weight: 400; font-size: .74rem; color: var(--ts-muted); }
.t-ts-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-left: auto; font-size: .74rem; font-weight: 400; color: var(--ts-muted); }
.t-ts-legend span { display: inline-flex; align-items: center; gap: 5px; }
.t-ts-legend i { position: relative; width: 16px; height: 2px; border-radius: 2px; }
.t-ts-legend i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: inherit; transform: translate(-50%, -50%); }
.t-ts-svg { display: block; width: 100%; height: auto; overflow: visible; }
.t-ts-svg text { font-family: inherit; font-size: 11px; fill: var(--ts-muted); font-variant-numeric: tabular-nums; }
.t-ts-svg text.t-ts-vlabel { fill: var(--ts-ink); font-weight: 600; }
.t-ts-svg .t-ts-hit { fill: transparent; cursor: pointer; outline: none; }
.t-ts-svg .t-ts-hit:hover, .t-ts-svg .t-ts-hit:focus { fill: rgba(15, 23, 42, .05); }
.t-ts-tip { position: absolute; z-index: 5; min-width: 150px; max-width: 240px; padding: 8px 10px; border-radius: 10px; background: #0f172a; color: #fff;
    font-size: .76rem; line-height: 1.45; pointer-events: none; box-shadow: 0 8px 20px rgba(15, 23, 42, .25); opacity: 0; transition: opacity .1s; }
.t-ts-tip.show { opacity: 1; }
.t-ts-tip b { display: block; font-size: .8rem; }
.t-ts-tip span { color: #cbd5e1; }

/* ---- ผลทุกนัด (ตารางคู่กับกราฟ) ---- */
.t-ts-match { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--ts-line); }
.t-ts-res { display: inline-flex; align-items: center; justify-content: center; width: 44px; padding: 4px 0; border-radius: 8px; font-size: .74rem; font-weight: 700; }
.t-ts-res.win { background: #dcfce7; color: #15803d; }
.t-ts-res.loss { background: #fee2e2; color: #b91c1c; }
.t-ts-res.draw, .t-ts-res.bye { background: #f1f5f9; color: #64748b; }
.t-ts-info { min-width: 0; }
.t-ts-round, .t-ts-note { font-size: .72rem; color: var(--ts-muted); }
.t-ts-opp { font-size: .88rem; font-weight: 600; overflow-wrap: anywhere; }
.t-ts-opp small { display: block; font-weight: 400; font-size: .74rem; color: var(--ts-muted); }
.t-ts-sets { display: flex; gap: 4px; }
.t-ts-set { min-width: 46px; padding: 3px 6px; border-radius: 6px; font-size: .78rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; background: #f1f5f9; color: #475569; }
.t-ts-set.won { background: #dcfce7; color: #15803d; }

@media (max-width: 520px) {
    .t-ts-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .t-ts-insights { grid-template-columns: 1fr; }
    .t-ts-match { grid-template-columns: 44px minmax(0, 1fr); }
    .t-ts-sets { grid-column: 2; }
    .t-ts-person .t-ts-ava { width: 64px; height: 64px; font-size: 1.5rem; }
    .t-ts-teamname { min-height: 64px; }
    .t-ts-teamname b { font-size: .95rem; }
}
