/* Tournament Team Details Page Styles */

/* Page Container */
.page-container {
    padding: 2rem 1.5rem;
}

@media (max-width: 768px) {
    .page-container {
        padding: 1rem;
    }
}

/* Visual base styles shared via .animated-gradient-header in common.css */
.team-header-section {
    position: relative; /* needed for .team-header-banner absolute positioning */
}

.team-header-banner {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.team-header-banner-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.18;
}

.team-header-section .team-title-row {
    position: relative;
    z-index: 1;
}

.team-title-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .team-title-row {
        align-items: flex-start;
    }
}

.team-icon {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.team-icon svg {
    stroke: white;
}

.team-title-info h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
    font-weight: 700;
    color: white;
}

.team-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.team-stats-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    color: white;
    opacity: 0.95;
    font-size: 0.95rem;
}

.team-stats-inline .stat-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.team-stats-inline .stat-item strong {
    font-weight: 700;
    font-size: 1.1em;
}

.team-stats-inline .stat-item svg {
    stroke: white;
    opacity: 0.9;
}

.team-stats-inline .meta-separator {
    opacity: 0.5;
    color: white;
}

.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-position {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.badge-eliminated {
    background: #f44336;
    color: white;
}

/* Tabs */
.content-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.tab-button {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.05);
}

.tab-button.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

.tab-content {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Overview Section */
.overview-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

.stat-box {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Guard: other page stylesheets define a generic `.stat-box { display: flex }`
   (e.g. tournament-stages-consolidated.css). The mobile app loads every page's
   CSS globally, so that flex leaks in and collapses these cards into a row.
   Scope to this page's grid so it wins in the bundle without affecting others. */
.stats-grid .stat-box {
    display: block;
}

.stat-box h3 {
    margin: 0 0 1rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-name {
    font-weight: 500;
    color: #666;
}

.stat-val {
    font-weight: 700;
    color: #333;
}

.recent-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.form-indicator {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: white;
}

.form-indicator.result-win {
    background: #4CAF50;
}

.form-indicator.result-loss {
    background: #f44336;
}

.form-indicator.result-draw {
    background: #9e9e9e;
}

/* Chart Section */
.chart-section {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-section h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
}

.score-chart {
    overflow-x: auto;
    padding: 1rem 0;
}

.score-trend-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    height: 250px;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 8px;
    position: relative;
}

.trend-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.trend-bar-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.trend-bar {
    width: 100%;
    background: linear-gradient(to top, #2196F3, #64B5F6);
    border-radius: 4px 4px 0 0;
    transition: all 0.3s ease;
    position: relative;
    min-height: 20px;
}

.trend-bar:hover {
    background: linear-gradient(to top, #1976D2, #2196F3);
    transform: translateY(-4px);
}

.bar-tooltip {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.trend-bar:hover .bar-tooltip {
    opacity: 1;
}

.trend-bar-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.round-label {
    font-weight: 600;
    color: #666;
}

.score-label {
    font-weight: 700;
    color: #2196F3;
    font-size: 0.875rem;
}

.average-line-container {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.average-line {
    position: absolute;
    left: 1rem;
    right: 1rem;
    height: 2px;
    background: #ff9800;
    border: 1px dashed #ff9800;
}

.average-label {
    position: absolute;
    right: 1.5rem;
    top: -12px;
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Matches Section */
.matches-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.match-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.match-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #2196F3;
}

.match-card.upcoming {
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.match-info {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.match-stage, .match-round, .match-location {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e3f2fd;
    color: #2196F3;
}

.match-date {
    font-size: 0.875rem;
    color: #666;
}

.match-teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.team-name {
    font-weight: 600;
    font-size: 1.125rem;
    color: #333;
}

.team-name.opponent {
    text-align: right;
}

.match-score {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    min-width: 3rem;
    text-align: center;
}

.score-value.result-win {
    color: #4CAF50;
}

.score-separator {
    font-size: 1.5rem;
    color: #999;
}

.match-status-pending {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ff9800;
}

.match-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f5f5f5;
}

.result-badge {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.875rem;
}

.result-badge.result-win {
    background: #e8f5e9;
    color: #2e7d32;
}

.result-badge.result-loss {
    background: #ffebee;
    color: #c62828;
}

.result-badge.result-draw {
    background: #f5f5f5;
    color: #616161;
}

.points-breakdown {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.points-earned {
    color: #4CAF50;
}

.points-lost {
    color: #f44336;
}

/* Match Games */
.match-games {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f5f5f5;
}

.match-games summary {
    cursor: pointer;
    font-weight: 600;
    color: #2196F3;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.match-games summary::-webkit-details-marker {
    display: none;
}

.match-games summary::before {
    content: "▶";
    display: inline-block;
    transition: transform 0.2s;
}

.match-games[open] summary::before {
    transform: rotate(90deg);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.game-card {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
}

.game-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.game-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2196F3;
    text-transform: uppercase;
}

.game-player {
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
}

.game-scores {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.score-item.total {
    padding-top: 0.5rem;
    border-top: 1px solid #e0e0e0;
    font-weight: 700;
}

.score-label {
    color: #666;
}

.score-value {
    font-weight: 600;
    color: #333;
}

/* Players Section */
.players-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.player-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-name-cell.clickable-player {
    cursor: pointer;
    transition: all 0.2s ease;
}

.player-name-cell.clickable-player:hover {
    color: #667eea;
}

.player-name-cell.clickable-player:hover .player-name {
    color: #667eea;
    text-decoration: underline;
}

.player-gender-icon {
    flex-shrink: 0;
}

.player-gender-icon.female {
    stroke: #e91e63;
}

.player-gender-icon.male {
    stroke: #2196F3;
}

.player-name {
    font-weight: 600;
    color: #333;
}

/* Guard: tournament-player-details.css defines a generic `.player-name` at
   2.25rem for the player-profile hero. The mobile app loads it globally, so it
   leaks onto this roster's names. Scope to the roster cell so the table font
   size wins in the bundle (no visual change in the Public app, where that file
   is not co-loaded on this page). */
.player-name-cell .player-name {
    font-size: inherit;
}

.text-center {
    text-align: center !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.inactive {
    background: #f5f5f5;
    color: #616161;
}

/* Performance Section */
.performance-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.points-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.points-box {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.points-box:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.points-box.earned {
    border-left: 4px solid #4CAF50;
}

.points-box.lost {
    border-left: 4px solid #f44336;
}

.points-box.net {
    border-left: 4px solid #2196F3;
}

.points-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.points-box.earned .points-icon {
    background: #e8f5e9;
}

.points-box.earned .points-icon svg {
    stroke: #4CAF50;
}

.points-box.lost .points-icon {
    background: #ffebee;
}

.points-box.lost .points-icon svg {
    stroke: #f44336;
}

.points-box.net .points-icon {
    background: #e3f2fd;
}

.points-box.net .points-icon svg {
    stroke: #2196F3;
}

.points-content {
    flex: 1;
}

.points-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.points-label {
    font-size: 0.875rem;
    color: #666;
}

.points-distribution {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}

.points-distribution-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.points-distribution h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1f2937;
}

.points-distribution-count {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    white-space: nowrap;
}

.points-match-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.points-match-row {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.points-match-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.points-match-main {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.points-match-opponent {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
}

.points-match-meta {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.points-match-metrics {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    border: 1px solid transparent;
}

.metric-pill-label {
    opacity: 0.88;
    font-weight: 600;
}

.metric-pill-value {
    font-weight: 800;
}

.metric-pill.earned {
    color: #047857;
    background: #ecfdf3;
    border-color: #a7f3d0;
}

.metric-pill.lost {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.metric-pill.net.positive {
    color: #0f766e;
    background: #f0fdfa;
    border-color: #99f6e4;
}

.metric-pill.net.negative {
    color: #9f1239;
    background: #fff1f2;
    border-color: #fecdd3;
}

.metric-pill.net.neutral {
    color: #475569;
    background: #f8fafc;
    border-color: #e2e8f0;
}

.points-split-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: #eef2f7;
    display: flex;
    overflow: hidden;
}

.points-split-fill {
    height: 100%;
    transition: width 0.3s ease-in-out;
}

.points-split-fill.earned {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.points-split-fill.lost {
    background: linear-gradient(90deg, #f43f5e 0%, #fb7185 100%);
}

.points-split-fill.neutral {
    background: linear-gradient(90deg, #94a3b8 0%, #cbd5e1 100%);
}

/* Responsive Design */
@media (max-width: 768px) {
    .team-header-section {
        padding: 1.5rem;
    }

    .team-title-info h1 {
        font-size: 1.5rem;
    }

    .team-quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .match-teams {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .team-name.opponent {
        text-align: center;
    }

    .match-score {
        order: -1;
    }

    .points-breakdown-grid {
        grid-template-columns: 1fr;
    }

    .points-distribution-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .tab-button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .team-header-section {
        padding: 0.875rem;
        border-radius: 10px;
        margin-bottom: 1rem;
    }

    .team-title-row {
        gap: 0.625rem;
        margin-bottom: 0.625rem;
    }

    .team-icon {
        padding: 0.5rem;
        border-radius: 8px;
    }

    .team-icon svg {
        width: 32px;
        height: 32px;
    }

    .team-title-info h1 {
        font-size: 1.125rem;
    }
}

/* Loading & Error States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 10px;
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #c62828;
}

.error-message svg {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    stroke: #c62828;
}

.btn-back {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-back:hover {
    background: #1976D2;
}

.text-muted {
    color: #666;
    font-style: italic;
}
