/* tournament-bracket.css
 * Shared CSS for tournament bracket modal
 * Used by both dashboard and live pages
 */

.tournament-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #ffb300;
    border-radius: 15px;
    overflow: hidden;
}

.tournament-modal .modal-header {
    background: linear-gradient(90deg, #ffb300 0%, #ff6a00 100%);
    color: #23234a;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.tournament-modal .modal-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.tournament-modal .close-btn {
    background: none;
    border: none;
    color: #23234a;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.tournament-modal .close-btn:hover {
    background-color: rgba(35, 35, 74, 0.2);
}

.tournament-body {
    padding: 0;
    height: calc(100% - 60px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

/* Tournament Bracket Styles */
.tournament-bracket {
    padding: 20px;
    min-height: 100%;
    box-sizing: border-box;
}

.tournament-rounds {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: center;
    min-height: 100%;
}

.tournament-round {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 280px;
    justify-content: center;
}

/* Tournament bracket specific styles - scoped to tournament modal */
.tournament-modal .round-header,
.tournament-bracket .round-header {
    background: linear-gradient(90deg, #2a5298 0%, #1e3c72 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tournament-modal .winner-round .round-header,
.tournament-bracket .winner-round .round-header {
    background: linear-gradient(90deg, #ffb300 0%, #ff6a00 100%);
    color: #23234a;
}

.round-matches {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

/* Tournament bracket specific match styles - scoped to tournament modal */
.tournament-modal .tournament-match,
.tournament-bracket .tournament-match {
    background: linear-gradient(135deg, #23234a 0%, #2a2a5a 100%);
    border: 2px solid #444;
    border-radius: 10px;
    padding: 15px;
    min-width: 250px;
    transition: all 0.3s ease;
    position: relative;
}

.tournament-modal .tournament-match.pending,
.tournament-bracket .tournament-match.pending {
    border-color: #ff9800;
    opacity: 0.7;
}

.tournament-modal .tournament-match.p1-winner,
.tournament-bracket .tournament-match.p1-winner {
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

.tournament-modal .tournament-match.p2-winner,
.tournament-bracket .tournament-match.p2-winner {
    border-color: #4CAF50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

/* Completed matches should always have grey border, even if they have winner classes */
.tournament-modal .tournament-match.completed,
.tournament-bracket .tournament-match.completed,
.tournament-modal .tournament-match.completed.p1-winner,
.tournament-bracket .tournament-match.completed.p1-winner,
.tournament-modal .tournament-match.completed.p2-winner,
.tournament-bracket .tournament-match.completed.p2-winner {
    border-color: #7b7b8b;
    box-shadow: 0 0 10px rgba(123, 123, 139, 0.3);
}

.tournament-modal .match-header,
.tournament-bracket .match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.match-id {
    color: #ffb300;
    font-weight: 600;
    font-size: 0.9rem;
}

.match-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.match-status.completed {
    background: #7b7b8b;
    color: white;
}

.match-status.pending {
    background: #ff9800;
    color: white;
}

/* Tournament bracket specific player styles - scoped to tournament modal */
.tournament-modal .match-players,
.tournament-bracket .match-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tournament-modal .match-players .player,
.tournament-bracket .match-players .player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    position: relative;
    transition: all 0.2s ease;
}

.tournament-modal .match-players .player.winner,
.tournament-bracket .match-players .player.winner {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4CAF50;
}

.player-name {
    color: #e0e6ed;
    font-weight: 600;
    flex: 1;
}

.winner-card {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.winner-name {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tournament-match-clickable {
    cursor: pointer;
    transition: box-shadow 0.2s, border 0.2s, transform 0.1s;
}

.tournament-match-clickable:hover,
.tournament-match-clickable:focus {
    box-shadow: 0 0 24px 4px #ffb30088, 0 2px 8px #0008;
    border-color: #ffb300;
    transform: translateY(-2px) scale(1.02);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .tournament-bracket {
        padding: 15px;
        padding-bottom: 30px;
    }

    .tournament-rounds {
        flex-direction: column;
        gap: 20px;
    }

    .tournament-round {
        min-width: 100%;
        margin-bottom: 10px;
    }

    .tournament-modal .tournament-match,
    .tournament-bracket .tournament-match {
        min-width: 100%;
        margin-bottom: 10px;
    }

    .winner-card {
        min-width: 100%;
        margin-bottom: 10px;
    }

    .tournament-modal .round-header,
    .tournament-bracket .round-header {
        margin-bottom: 15px;
    }
}

@media (max-width: 700px) {
    #tournamentModal .modal {
        padding: 0 !important;
    }

    #tournamentBracket {
        padding: 0 !important;
    }

    .tournament-body {
        padding: 0 !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .tournament-bracket {
        padding: 0 !important;
        padding-bottom: 40px !important;
        min-height: auto;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    .tournament-modal .modal-body {
        padding: 0 !important;
        overflow-x: auto !important;
        overflow-y: auto !important;
    }

    .tournament-modal .modal-content {
        overflow: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .tournament-modal {
        overflow: hidden !important;
    }

    .tournament-modal .modal-header {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .bracket-grid-wrapper,
    .tournament-rounds {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        width: max-content !important;
        min-width: 100% !important;
        max-width: none !important;
        padding-bottom: 20px !important;
        gap: 15px !important;
        box-sizing: border-box;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .tournament-round {
        min-width: 80vw;
        max-width: 80vw;
        margin: 0;
        flex: 0 0 80vw;
        box-sizing: border-box;
    }

    .bracket-grid-wrapper > .tournament-round:first-child,
    .tournament-rounds > .tournament-round:first-child {
        margin-left: 15px;
        padding-left: 0;
    }

    .bracket-grid-wrapper > .tournament-round:last-child,
    .tournament-rounds > .tournament-round:last-child {
        margin-right: 15px;
        padding-right: 0;
    }


    .bracket-header-label,
    .tournament-modal .round-header,
    .tournament-bracket .round-header {
        min-width: 80vw;
        max-width: 80vw;
        text-align: center;
        box-sizing: border-box;
        margin-bottom: 15px;
    }

    .tournament-modal .tournament-match,
    .tournament-bracket .tournament-match {
        margin-bottom: 15px;
    }

    .winner-card {
        margin-bottom: 15px;
        min-width: 80vw;
        max-width: 80vw;
        box-sizing: border-box;
    }

    .bracket-left-spacer {
        display: none !important;
    }
}

.tournament-modal .match-players .player.winner {
    position: relative;
}

