/* ranking.css v2 */

:root {
    --navy: #0d1a2f;
    --blue: #3498db;
    --win: #2ecc71;
    --lose: #e74c3c;
    --gold: #f1c40f;
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-border: rgba(255, 255, 255, 0.4);
    --text-dark: #0d1a2f;
    --text-muted: #666;
}

/* =============================================
   1. 히어로 배너
============================================= */
.ranking-hero {
    padding: 140px 0 60px;
    text-align: center;
    color: #fff;
}
.ranking-hero h1 {
    font-size: 3rem;
    font-weight: 900;
    margin: 0 0 10px;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.6);
    letter-spacing: -1px;
}
.ranking-hero p {
    font-size: 1.1rem;
    opacity: 0.85;
    margin: 0;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}

/* =============================================
   2. 요약 카드
============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 28px 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    transition: transform 0.25s, box-shadow 0.25s;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(0,0,0,0.15);
}
.stat-icon  { font-size: 2rem; margin-bottom: 10px; }
.stat-value {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--navy);
    line-height: 1;
    margin-bottom: 4px;
}
.stat-value.win-rate  { color: var(--win); }
.stat-value.top-name  { font-size: 1.4rem; color: #e67e22; }
.stat-sub   { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.stat-label { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; }

/* =============================================
   3. 섹션 공통
============================================= */
.ranking-section {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    margin-bottom: 40px;
    overflow: hidden;
}
.section-header {
    padding: 24px 28px 0;
    border-bottom: 1px solid #e8edf2;
}
.section-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--navy);
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =============================================
   4. 테이블 공통
============================================= */
.table-wrapper { overflow-x: auto; padding: 0 0 8px; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

thead th {
    background: #f4f7fb;
    color: var(--navy);
    font-weight: 700;
    padding: 14px 16px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid #dde3ec;
    transition: background 0.2s;
}
thead th:hover       { background: #e8edf5; }
thead th .sort-icon  { margin-left: 6px; opacity: 0.4; font-size: 0.8rem; }
thead th.sorted .sort-icon { opacity: 1; color: var(--blue); }

tbody tr {
    border-bottom: 1px solid #eef1f6;
    transition: background 0.15s;
    cursor: pointer;
}
tbody tr:hover    { background: #f8fafd; }
tbody tr.expanded { background: #f0f7ff; }
tbody td {
    padding: 13px 16px;
    color: var(--text-dark);
    vertical-align: middle;
}

/* =============================================
   5. 대회 테이블 셀
============================================= */
.date-cell    { color: var(--text-muted); font-size: 0.88rem; white-space: nowrap; }
.title-cell   { font-weight: 700; }
.rank-cell    { text-align: center; }
.members-cell { white-space: nowrap; }
.win-rate-cell { text-align: center; }

.expand-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-right: 6px;
    transition: transform 0.3s;
    display: inline-block;
}
tbody tr.expanded .expand-icon { transform: rotate(90deg); }

/* 등수 칩 */
.rank-chip {
    display: inline-block;
    padding: 4px 12px;
    background: #fef9e7;
    color: #b7770d;
    border: 1.5px solid #f9e09b;
    border-radius: 14px;
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

/* 참여 멤버 요약 */
.members-summary { font-size: 0.92rem; font-weight: 600; color: var(--navy); }
.member-rate     { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; margin-left: 3px; }

/* 승률 배지 */
.rate-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}
.rate-badge.high { background: #eafaf1; color: #1a8a4a; }
.rate-badge.mid  { background: #fef9e7; color: #b7770d; }
.rate-badge.low  { background: #fdf0ef; color: #c0392b; }

/* 영상 링크 */
.soop-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--blue);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 5px 12px;
    border: 1.5px solid var(--blue);
    border-radius: 20px;
    transition: all 0.2s;
    white-space: nowrap;
}
.soop-link:hover { background: var(--blue); color: #fff; }
.no-link { color: #bbb; font-size: 0.85rem; }

/* 메모 */
.notes-cell {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* =============================================
   6. 펼치기 상세
============================================= */
.games-row td {
    padding: 0;
    background: #f7fbff;
    border-bottom: 2px solid #ddeeff;
}
.expand-detail {
    padding: 16px 24px 16px 36px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.expand-block { display: flex; flex-direction: column; gap: 8px; }
.expand-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.games-list  { display: flex; flex-wrap: wrap; gap: 8px; }

/* 게임 칩 */
.game-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 18px;
    font-size: 0.87rem;
    font-weight: 600;
    border: 1.5px solid;
}
.game-chip.win     { background: #eafaf1; color: #1a8a4a; border-color: #a9dfc0; }
.game-chip.lose    { background: #fdf0ef; color: #c0392b; border-color: #f5b7b1; }
.game-chip.neutral { background: #f4f7fb; color: #555;    border-color: #dde3ec; }
.chip-icon { font-size: 0.95rem; }

/* 멤버 칩 */
.member-chip {
    display: inline-block;
    padding: 4px 12px;
    background: #eef4fb;
    color: #2c5f8a;
    border: 1.5px solid #c3d9f0;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* =============================================
   7. 참여자별 승률 테이블
============================================= */
.member-rank-cell { text-align: center; font-size: 1.1rem; width: 56px; }
.member-name-cell { font-weight: 700; color: var(--navy); }
.attend-cell      { min-width: 180px; }

.attend-bar-wrap {
    width: 100%;
    height: 6px;
    background: #e8edf5;
    border-radius: 4px;
    margin-bottom: 4px;
    overflow: hidden;
}
.attend-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #00c6ff);
    border-radius: 4px;
    transition: width 0.6s ease;
}
.attend-text    { font-size: 0.85rem; color: var(--text-muted); }
.stat-detail-cell { font-size: 0.88rem; color: var(--text-muted); }

/* =============================================
   8. 그래프 탭
============================================= */
.chart-tabs {
    display: flex;
    padding: 0 28px;
    border-bottom: 1px solid #e8edf2;
    overflow-x: auto;
}
.chart-tab {
    padding: 14px 22px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.chart-tab:hover  { color: var(--navy); }
.chart-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.chart-panels     { padding: 28px; }
.chart-panel      { display: none; }
.chart-panel.active { display: block; }
.chart-panel canvas { max-height: 340px; width: 100% !important; }

/* =============================================
   9. 빈 상태 / 로딩
============================================= */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon  { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { margin: 0; font-size: 1rem; }

.loading-wrap { text-align: center; padding: 60px; color: var(--text-muted); }
.spinner {
    width: 40px; height: 40px;
    border: 4px solid #e0e7ef;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   10. 반응형
============================================= */
@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .stats-grid    { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-value    { font-size: 1.7rem; }
    .stat-value.top-name { font-size: 1.1rem; }
    .ranking-hero h1 { font-size: 2rem; }
    .section-header  { padding: 18px 16px 0; }
    .chart-panels    { padding: 16px; }
    .expand-detail   { padding: 12px 12px 12px 20px; }
    .chart-tabs      { padding: 0 8px; }
    .chart-tab       { padding: 12px 14px; font-size: 0.85rem; }
    tbody td, thead th { padding: 11px 10px; }
    .notes-cell { max-width: 70px; }
}

/* 상세 링크 & 영상 수 태그 */
.detail-link {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    background: var(--navy);
    color: #fff;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    transition: background 0.2s;
}
.detail-link:hover { background: var(--blue); }

.video-count-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #eef4fb;
    color: #2c5f8a;
    border: 1.5px solid #c3d9f0;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    vertical-align: middle;
}
