/**
 * Tournament Bracket Styles
 * CTF Tournament Bracket Visualization CSS
 */

/* Theme colors */
:root {
    --cctf-dark: #375d6f;
    --cctf-darker: #274553;
    --cctf-gold: #f59e0b;
    --match-bg: #1f2937;
    --match-border: #374151;
    --winner-bg: #065f46;
    --pending-bg: #374151;
    --in-progress-bg: #1e40af;
}

/* Bracket scroll container */
.bracket-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2rem 0;
    margin: 0 -1rem;
    position: relative;
}

.bracket-scroll-container::-webkit-scrollbar {
    height: 8px;
}

.bracket-scroll-container::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 4px;
}

.bracket-scroll-container::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

.bracket-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Bracket tree grid */
.bracket-grid {
    display: flex;
    gap: 3rem;
    min-width: max-content;
    padding: 0 1rem;
}

/* Round column */
.bracket-round {
    display: flex;
    flex-direction: column;
    min-width: 240px;
    max-width: 280px;
}

.bracket-round-header {
    text-align: center;
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.75rem;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    border-radius: 0.375rem;
    border: 1px solid #3b82f6;
}

.bracket-round-header h3 {
    margin-bottom: 0;
    color: white;
    font-weight: bold;
    font-size: 0.9375rem;
}

/* Matches container */
.bracket-matches {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    justify-content: space-evenly;
}

/* Match card */
.match-card {
    background: var(--match-bg);
    border: 2px solid var(--match-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: var(--cctf-dark);
}

/* User's match highlight */
.match-card.user-match {
    border-color: var(--cctf-gold);
    background: linear-gradient(135deg, var(--match-bg) 0%, rgba(245, 158, 11, 0.1) 100%);
}

.match-card.user-match::before {
    content: '★';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: var(--cctf-gold);
    font-size: 1.25rem;
}

/* Match status variations */
.match-card.match-pending {
    opacity: 0.7;
}

.match-card.match-in_progress,
.match-card.match-in-progress {
    border-color: #3b82f6;
    animation: pulse-border 2s ease-in-out infinite;
}

.match-card.match-completed {
    border-color: #10b981;
}

.match-card.match-walkover {
    border-color: #f59e0b;
    opacity: 0.8;
}

@keyframes pulse-border {
    0%, 100% {
        border-color: #3b82f6;
    }
    50% {
        border-color: #60a5fa;
    }
}

/* Player container */
.match-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.375rem;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
}

.match-player.winner {
    background: var(--winner-bg);
    border: 1px solid #10b981;
}

.match-player.pending {
    opacity: 0.5;
}

/* Player avatar */
.player-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #4b5563;
}

.match-player.winner .player-avatar {
    border-color: #10b981;
}

/* Player info */
.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-weight: 600;
    color: white;
    font-size: 0.8125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.player-score {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 0.125rem;
    line-height: 1;
}

.match-player.winner .player-score {
    color: #34d399;
    font-weight: 600;
}

/* Winner badge */
.winner-badge {
    font-size: 1.25rem;
    line-height: 1;
}

/* VS separator */
.match-vs {
    text-align: center;
    color: #6b7280;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0;
    margin: 0.125rem 0;
}

/* Match status badge */
.match-status-badge {
    position: absolute;
    bottom: 0.375rem;
    right: 0.375rem;
    font-size: 0.5625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.1875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.match-status-badge.match-pending {
    background: #374151;
    color: #9ca3af;
}

.match-status-badge.match-in_progress,
.match-status-badge.match-in-progress {
    background: #1e40af;
    color: #93c5fd;
}

.match-status-badge.match-completed {
    background: #065f46;
    color: #6ee7b7;
}

.match-status-badge.match-walkover {
    background: #92400e;
    color: #fbbf24;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-gray {
    background: #374151;
    color: #9ca3af;
}

.badge-blue {
    background: #1e40af;
    color: #93c5fd;
}

.badge-green {
    background: #065f46;
    color: #6ee7b7;
}

.badge-yellow {
    background: #92400e;
    color: #fbbf24;
}

/* Score update animation */
@keyframes scoreUpdate {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #10b981;
    }
}

.score-update-animation {
    animation: scoreUpdate 0.5s ease-in-out;
}

/* Highlight pulse */
@keyframes highlightPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(245, 158, 11, 0);
    }
}

.highlight-pulse {
    animation: highlightPulse 1s ease-in-out 2;
}

/* List View Styles */
.round-list-section {
    background: var(--match-bg);
    border: 1px solid var(--match-border);
    border-radius: 0.75rem;
    overflow: hidden;
}

.round-list-header {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--cctf-darker);
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.round-list-header:hover {
    background: var(--cctf-dark);
}

.round-list-matches {
    padding: 1rem;
}

.match-list-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--match-border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.match-list-item:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--cctf-dark);
}

.match-list-item.user-match {
    border-color: var(--cctf-gold);
    background: rgba(245, 158, 11, 0.1);
}

.player-item {
    color: #d1d5db;
    padding: 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
}

.player-item.winner {
    background: var(--winner-bg);
    color: white;
    font-weight: 600;
}

.player-item .score {
    float: right;
    color: #9ca3af;
}

.player-item.winner .score {
    color: #6ee7b7;
}

.match-list-status {
    margin-left: 1rem;
}

/* Modal styles */
#matchModal.hidden {
    display: none !important;
}

#matchModal {
    backdrop-filter: blur(8px);
}

.player-detail {
    background: rgba(31, 41, 55, 0.8);
    border: 2px solid var(--match-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.player-detail.winner-detail {
    background: rgba(6, 95, 70, 0.3);
    border-color: #10b981;
}

/* Loader */
.loader {
    border: 3px solid #374151;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Responsive adjustments */
@media (max-width: 1024px) {
    .bracket-grid {
        gap: 2rem;
    }

    .bracket-round {
        min-width: 240px;
    }

    .match-card {
        padding: 0.75rem;
    }
}

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

    .match-card {
        padding: 0.75rem;
    }

    .player-avatar {
        width: 2rem;
        height: 2rem;
    }

    .player-name {
        font-size: 0.8rem;
    }

    .player-score {
        font-size: 0.7rem;
    }
}

/* Print styles */
@media print {
    .bracket-scroll-container {
        overflow: visible;
    }

    .bracket-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .match-card {
        break-inside: avoid;
    }

    button {
        display: none;
    }
}

/* Connection lines (optional - can be complex) */
.bracket-round::after {
    content: '';
    position: absolute;
    right: -1.5rem;
    top: 50%;
    width: 1.5rem;
    height: 2px;
    background: var(--match-border);
    display: none; /* Enable if you want connecting lines */
}

/* Dark mode optimizations */
@media (prefers-color-scheme: dark) {
    .bracket-scroll-container {
        background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.2) 100%);
    }
}

/* Accessibility */
.match-card:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.match-card:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom scrollbar for modal */
#modalContent {
    max-height: 80vh;
    overflow-y: auto;
    color: white;
}

#modalContent::-webkit-scrollbar {
    width: 6px;
}

#modalContent::-webkit-scrollbar-track {
    background: #1f2937;
}

#modalContent::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

#modalContent::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
