/* ============================================
   Tournament Management & Round Pages
   ============================================ */

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #2c1810;
    background: #f5f5f5;
}

.tab-btn.active {
    color: #2c1810;
    border-bottom-color: #d4af37;
    font-weight: bold;
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddd;
}

.section-header h3 {
    margin: 0;
    color: #2c1810;
}

.section-header .actions {
    display: flex;
    gap: 10px;
}

/* Tournament Info Card */
.tournament-info-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item .label {
    font-size: 14px;
    color: #666;
}

.info-item .value {
    font-size: 18px;
    font-weight: bold;
    color: #2c1810;
}

.info-item .value.status-ongoing {
    color: #28a745;
}

.info-item .value.status-completed {
    color: #666;
}

.info-item .value.status-registration_open {
    color: #007bff;
}

/* Participants Table */
.participants-table {
    overflow-x: auto;
}

.participant-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.badge.status-confirmed {
    background: #28a745;
    color: white;
}

.badge.status-registered {
    background: #007bff;
    color: white;
}

.badge.status-withdrawn {
    background: #dc3545;
    color: white;
}

/* Standings Table */
.standings-table tr.rank-1 {
    background: #ffd70020;
    font-weight: bold;
}

.standings-table tr.rank-2 {
    background: #c0c0c020;
}

.standings-table tr.rank-3 {
    background: #cd7f3220;
}

/* Rounds */
.rounds-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.round-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.round-card h4 {
    margin: 0 0 15px 0;
    color: #2c1810;
}

/* Pairings Grid */
.pairings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.pairing-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.pairing-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.pairing-card.live {
    border: 2px solid #dc3545;
    background: #fff5f5;
}

.pairing-card.finished {
    opacity: 0.8;
}

.pairing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.board-number {
    font-weight: bold;
    color: #2c1810;
}

.live-badge {
    background: #dc3545;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    animation: pulse 2s infinite;
}

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

.finished-badge {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.players {
    margin: 15px 0;
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin: 5px 0;
    border-radius: 8px;
    transition: all 0.3s;
}

.player.white-side {
    background: #f8f8f8;
}

.player.black-side {
    background: #f0f0f0;
}

.player-color {
    font-size: 24px;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: bold;
    color: #2c1810;
}

.player-rating {
    font-size: 14px;
    color: #666;
}

.player-team {
    font-size: 12px;
    color: #999;
}

.vs-divider {
    text-align: center;
    font-weight: bold;
    color: #999;
    margin: 10px 0;
}

.result-badge {
    font-size: 20px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 5px;
}

.result-badge.win {
    background: #28a745;
    color: white;
}

.result-badge.draw {
    background: #ffc107;
    color: #333;
}

.result-badge.loss {
    background: #dc3545;
    color: white;
}

.pairing-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.pairing-notes {
    margin-top: 10px;
    padding: 10px;
    background: #fffbea;
    border-left: 3px solid #d4af37;
    font-size: 14px;
    color: #666;
}

/* Live Matches */
.live-matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.live-match-card {
    background: white;
    border: 2px solid #dc3545;
    border-radius: 10px;
    padding: 15px;
    position: relative;
}

.live-indicator {
    position: absolute;
    top: -10px;
    right: 10px;
    background: #dc3545;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

/* Round Page */
.round-page {
    max-width: 1400px;
    margin: 0 auto;
}

.round-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.info-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.info-card .label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.info-card .value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #2c1810;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-spinner {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2c1810;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-top: 0;
    color: #2c1810;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .pairings-grid {
        grid-template-columns: 1fr;
    }

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

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .pairing-actions {
        flex-direction: column;
    }

    .pairing-actions .btn {
        width: 100%;
    }
}

/* ============================================
   Mobile-specific fixes for tournaments
   ============================================ */
@media (max-width: 768px) {
    /* Board inputs - stack them vertically */
    .tournament-details [style*="display:flex"][style*="gap:5px"] {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .tournament-details [style*="display:flex"][style*="gap:5px"] input,
    .tournament-details [style*="display:flex"][style*="gap:5px"] select {
        width: 100% !important;
        min-width: 100% !important;
    }
    
    /* Board display - stack player names */
    .tournament-details [style*="flex-wrap:wrap"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 5px !important;
    }
    
    /* Round selector dropdown */
    .results-input select {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }
    
    /* Round tabs */
    .tournament-details .tabs {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tournament-details .tabs::-webkit-scrollbar {
        display: none;
    }
    
    /* Fixtures match cards */
    .tournament-details [style*="background:#fff"][style*="border-radius"] {
        padding: 10px !important;
        margin-bottom: 8px !important;
    }
    
    /* Team names and scores */
    .tournament-details [style*="justify-content:space-between"] {
        flex-direction: column;
        gap: 5px;
    }
    
    /* Watch button */
    .tournament-details button[onclick*="showBoardModal"],
    .tournament-details button[onclick*="showPairingModal"] {
        width: 100%;
        margin-top: 5px;
    }
}
