/**
 * Cup Bracket Styles
 * Shared between frontend and admin
 */

/* ============================================================
   CONTAINER
   ============================================================ */
.bg-knockout-bracket-container {
    display: flex;
    gap: 48px;
    overflow-x: auto;
    padding: 24px 8px 32px;
    min-height: 400px;
    align-items: stretch;
    scrollbar-width: thin;
    scrollbar-color: #c8d0da #f1f3f5;
}

.bg-knockout-bracket-container::-webkit-scrollbar {
    height: 6px;
}
.bg-knockout-bracket-container::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 3px;
}
.bg-knockout-bracket-container::-webkit-scrollbar-thumb {
    background: #c8d0da;
    border-radius: 3px;
}

/* ============================================================
   ROUND COLUMN
   ============================================================ */
.bg-knockout-round {
    min-width: 210px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}

.bg-round-title {
    text-align: center;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #c82333 0%, #a71d2a 100%);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    flex-shrink: 0;
}

/* ============================================================
   ROUND MATCHES — flex column filling remaining height
   ============================================================ */
.bg-round-matches {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ============================================================
   MATCH PAIR — groups 2 consecutive matches;
   uses flex:1 so all pairs share equal height per round.
   ============================================================ */
.match-pair {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
}

/* Vertical connector between the two matches in a pair
   Runs from center of first match to center of second match
   (top:25% to top:75% of the pair = 50% height) */
.bg-knockout-round:not(:last-child) .match-pair:not(.single)::after {
    content: '';
    position: absolute;
    right: -24px;   /* half of 48px gap */
    top: 25%;
    height: 50%;
    width: 2px;
    background: #c8d0da;
    z-index: 0;
}

/* ============================================================
   MATCH WRAPPER — holds one match card, fills half the pair
   ============================================================ */
.match-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    padding: 5px 0;
}

/* Outgoing horizontal line: right edge of card → midpoint of gap */
.bg-knockout-round:not(:last-child) .match-wrapper::after {
    content: '';
    position: absolute;
    right: -24px;
    top: 50%;
    width: 24px;
    height: 2px;
    background: #c8d0da;
    z-index: 0;
}

/* Incoming horizontal line: midpoint of gap → left edge of card */
.bg-knockout-round:not(:first-child) .match-wrapper::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 50%;
    width: 24px;
    height: 2px;
    background: #c8d0da;
    z-index: 0;
}

/* ============================================================
   MATCH CARD
   ============================================================ */
.bg-knockout-match {
    background: #fff;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    position: relative;
    z-index: 2;
    width: 100%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s, border-color 0.2s;
    overflow: hidden;
}

.bg-knockout-match:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.11);
}

/* Status variants */
.bg-knockout-match.completed {
    border-color: #28a745;
}

.bg-knockout-match.in-progress {
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255,193,7,0.2), 0 2px 6px rgba(0,0,0,0.06);
}

/* ============================================================
   MATCH HEADER (round label inside card + status badge)
   ============================================================ */
.bg-match-header {
    background: #f8f9fa;
    padding: 3px 8px;
    border-bottom: 1px solid #f0f0f1;
    font-size: 10px;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.bg-match-label {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.bg-match-status-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.bg-match-status-badge.badge-pending {
    background: #e9ecef;
    color: #6c757d;
}

.bg-match-status-badge.badge-live {
    background: #fff3cd;
    color: #856404;
    animation: bg-badge-pulse 1.5s ease-in-out infinite;
}

.bg-match-status-badge.badge-done {
    background: #d4edda;
    color: #155724;
}

.bg-match-status-badge.badge-bye {
    background: #e2e3e5;
    color: #495057;
    font-style: italic;
}

@keyframes bg-badge-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ============================================================
   PLAYER ROWS
   ============================================================ */
.bg-match-player {
    padding: 5px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f1;
    font-size: 12px;
    transition: background 0.15s;
    min-height: 28px;
}

.bg-match-player:last-child {
    border-bottom: none;
}

.bg-match-player.winner {
    background: #d4edda;
    font-weight: 700;
    color: #155724;
}

.bg-match-player.loser {
    opacity: 0.45;
}

.bg-match-player-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12.5px;
}

/* Seed/rank badge before the name */
.bg-player-seed {
    display: inline-block;
    background: #e7f1ff;
    color: #1a6ac8;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}

.bg-match-player.winner .bg-player-seed {
    background: #b7dfc5;
    color: #155724;
}

/* Score circle */
.bg-match-player-score {
    font-weight: 800;
    font-size: 13px;
    min-width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    background: #e9ecef;
    color: #333;
    margin-left: 8px;
    flex-shrink: 0;
}

.bg-match-player.winner .bg-match-player-score {
    background: #28a745;
    color: #fff;
}

.bg-match-player.loser .bg-match-player-score {
    background: #dee2e6;
    color: #999;
}

/* TBD / pending player slot */
.bg-match-player.tbd .bg-match-player-name {
    color: #adb5bd;
    font-style: italic;
    font-size: 12px;
}

/* ============================================================
   EMPTY / BYE MATCH
   ============================================================ */
.bg-knockout-match.empty-match {
    border-style: dashed;
    border-color: #dee2e6;
    background: #fafafa;
    padding: 14px;
    text-align: center;
    color: #adb5bd;
    font-size: 12px;
    box-shadow: none;
}

/* ============================================================
   EMPTY STATE (no bracket yet)
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 40px 15px;
    background: #f9f9f9;
    border-radius: 10px;
    margin: 30px 0;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.empty-state-title {
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 8px;
}

.empty-state-text {
    color: #666;
    font-size: 0.9rem;
}

/* ============================================================
   THIRD PLACE MATCH
   ============================================================ */
.bg-third-place-match {
    margin-top: 24px;
    padding: 16px;
    background: #fffdf0;
    border: 2px solid #f0b429;
    border-radius: 10px;
    max-width: 260px;
}

.bg-third-place-match h3 {
    text-align: center;
    color: #7a5c00;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
