/* Tournament Specific Styles - Extends common.css */

/* Scoring Rules UI */
.rule-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 4px;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 1px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}
.rule-badge.wwcd { background: #ffd700; color: #000; }
.rule-badge.hybrid { background: #ff3e3e; color: #fff; animation: pulseRed 2s infinite; }

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(255, 62, 62, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(255, 62, 62, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 62, 62, 0); }
}

.match-point-eligible {
    background: rgba(255, 62, 62, 0.05) !important;
}
.match-point-eligible td {
    border-top: 1px solid rgba(255, 62, 62, 0.3) !important;
    border-bottom: 1px solid rgba(255, 62, 62, 0.3) !important;
}

/* Scrollbars... */
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #3a4150; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* --- Top Header Info --- */
.tournament-header {
    background-color: var(--bg-panel);
    padding: 30px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.sponsor-box {
    flex: 1;
    height: 100px;
    max-width: 500px;
    display: flex;
    align-items: center;
}

#uiSponsorLeft { justify-content: flex-start; }
#uiSponsorRight { justify-content: flex-end; }

.sponsor-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.sponsor-box img:hover { transform: scale(1.05); }

.tourney-logo {
    width: 80px;
    height: 80px;
    margin-right: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.tourney-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }

.tourney-details h1 {
    font-size: 2.2rem;
    margin: 0 0 10px 0;
    color: #fff;
}

.tourney-meta { display: flex; gap: 30px; }
.meta-item { display: flex; flex-direction: column; }
.meta-value { font-size: 1rem; font-weight: 600; color: var(--text-main); }

/* --- Navigation Tabs --- */
.nav-container {
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
}

.nav-tabs { display: flex; }

.tab {
    padding: 20px 24px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    letter-spacing: 1px;
}

.tab:hover { color: var(--text-main); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.stage-selector-container { display: flex; align-items: center; gap: 15px; }

.stage-select {
    background-color: var(--bg-dropdown) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.stage-select:focus {
    border-color: var(--accent);
}

/* --- Filter System --- */
.filter-bar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 20px 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 10px; }

.multi-select-container {
    position: relative;
    min-width: 220px;
}

.multi-select-display {
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.multi-select-display:hover { border-color: var(--accent); }

.multi-select-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    z-index: 500;
    max-height: 350px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.multi-select-option {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.multi-select-option:hover { background: rgba(255,255,255,0.05); }
.multi-select-option input { cursor: pointer; width: 16px; height: 16px; }

/* --- Leaderboard Grid --- */
.leaderboard-wrapper { max-width: 1400px; margin: 40px auto; padding: 0 20px; }

.grid-layout { 
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
    gap: 30px;
}

/* --- Matrix View --- */
.matrix-container { 
    overflow-x: auto; 
    border-radius: var(--radius-lg); 
    border: 1px solid var(--border); 
    background: var(--bg-panel); 
}

.matrix-table { 
    border-collapse: collapse; /* Better for sticky borders */
    width: 100%; 
}
.matrix-table th, .matrix-table td { 
    border: 1px solid var(--border); 
    white-space: nowrap; 
    text-align: center;
    padding: 10px 15px;
}
.matrix-table th { position: sticky; top: 0; z-index: 10; background: var(--bg-panel); }

/* Sticky Column Background & Alignment Fix */
th[style*="position: sticky"], td[style*="position: sticky"] {
    background-color: #0f1218 !important; 
    background: #0f1218 !important; /* Force solid background */
    z-index: 20;
}

/* Ensure matrix table headers are above body cells */
.matrix-table th[style*="position: sticky"] {
    z-index: 40 !important;
}

.matrix-table td[style*="position: sticky"] {
    z-index: 30 !important;
}

.table-container table th, 
.table-container table td {
    text-align: center; /* Center all stats */
    padding: 12px 15px;
}

/* Exception for Team and Player names */
th[style*="text-align:left"], 
td[style*="text-align:left"],
.team-cell {
    text-align: left !important;
}

.team-cell { display: flex; align-items: center; }
.team-logo { 
    width: 28px; 
    height: 28px; 
    object-fit: contain; 
    margin-right: 14px; 
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rank-1 td:first-child { color: #FFD700; font-weight: 800; }
.rank-2 td:first-child { color: #C0C0C0; font-weight: 800; }
.rank-3 td:first-child { color: #CD7F32; font-weight: 800; }

/* Matrix Rank Highlighting */
.m-r-1 { 
    color: #FFD700 !important; 
    font-weight: 800 !important; 
    background: rgba(255, 215, 0, 0.15) !important; 
}
.m-r-2 { 
    color: #C0C0C0 !important; 
    font-weight: 800 !important; 
    background: rgba(192, 192, 192, 0.1) !important; 
}
.m-r-3 { 
    color: #CD7F32 !important; 
    font-weight: 800 !important; 
    background: rgba(205, 127, 50, 0.1) !important; 
}

/* Sortable Headers */
.sortable { cursor: pointer; transition: var(--transition); }
.sortable:hover { color: #fff; background: rgba(255,255,255,0.05); }

/* Double Scroll Utility */
.double-scroll-wrapper { display: flex; flex-direction: column; width: 100%; }
.top-scrollbar { 
    overflow-x: auto; 
    overflow-y: hidden; 
    height: 12px; 
    width: 100%; 
    background: var(--bg-body); 
    border: 1px solid var(--border); 
    border-bottom: none; 
    border-radius: var(--radius-md) var(--radius-md) 0 0; 
}
.top-scrollbar-inner { height: 12px; }

.table-container {
    overflow-x: auto;
    width: 100%;
}

.mvp-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.mvp-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 30px 24px;
    text-align: center;
    position: relative;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mvp-card:hover { border-color: var(--accent); transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.4); }

.mvp-card.rank-1 { 
    border-color: var(--accent); 
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.05) 0%, var(--bg-panel) 100%); 
}

.mvp-card.rank-1::after { 
    content: 'MVP'; 
    position: absolute; 
    top: 15px; right: 15px; 
    font-size: 0.7rem; 
    color: var(--text-invert); 
    background: var(--accent); 
    padding: 4px 10px; 
    border-radius: var(--radius-sm); 
    font-weight: 800; 
    text-transform: uppercase; 
}

.mvp-card-team { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }

.mvp-name-wrapper {
    position: relative;
    margin-bottom: 20px;
    cursor: pointer;
}

.mvp-card-name { 
    font-size: 1.6rem; 
    color: #fff; 
    font-weight: 800; 
    display: flex;
    align-items: center;
    gap: 8px;
}

.mvp-card-name::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--accent);
    opacity: 0.5;
    transition: var(--transition);
}

.mvp-name-wrapper:hover .mvp-card-name::after {
    opacity: 1;
    transform: translateY(2px);
}

.mvp-hidden-select {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
    appearance: none;
}

.mvp-chart-container {
    width: 100%;
    height: 180px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
}

.mvp-card-stats { 
    display: flex; 
    width: 100%; 
    justify-content: space-between; 
    padding-top: 25px; 
    border-top: 1px solid rgba(255,255,255,0.05);
    gap: 10px;
}

.mvp-stat-item { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    flex: 1;
    background: rgba(255,255,255,0.03);
    padding: 12px 5px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: var(--transition);
}

.mvp-stat-item:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-3px);
    border-color: rgba(var(--accent-rgb), 0.3);
}

.mvp-stat-val { 
    font-size: 1.3rem; 
    color: #fff; 
    font-weight: 800; 
    font-family: 'Oswald', sans-serif;
    line-height: 1;
    margin-bottom: 6px;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.mvp-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mvp-card.rank-1 .mvp-stat-val { 
    color: var(--accent); 
    text-shadow: 0 0 15px rgba(var(--accent-rgb), 0.4);
}

.mvp-card.rank-1 .mvp-stat-item {
    background: rgba(var(--accent-rgb), 0.05);
    border-color: rgba(var(--accent-rgb), 0.1);
}

@media (max-width: 1200px) {
    .grid-layout { grid-template-columns: 1fr; }
}

@media (max-width: 850px) {
    .tournament-header { flex-direction: column; text-align: center; gap: 30px; }
    .header-center { flex-direction: column; order: -1; }
    .tourney-logo { margin-right: 0; margin-bottom: 20px; }
    .sponsor-box { width: 100%; justify-content: center !important; height: auto; }
    .tourney-meta { justify-content: center; flex-wrap: wrap; }
}

@media (max-width: 600px) {
    .nav-container { flex-direction: column; padding: 20px; gap: 20px; }
    .nav-tabs { flex-wrap: wrap; justify-content: center; }
    .tab { padding: 12px 16px; font-size: 0.75rem; }
    .tourney-details h1 { font-size: 1.6rem; }
}
