/* Tournament Portal Styles - Imports base styles from banlist.css */
@import url('banlist.css');

/* Code Form Section */
.code-section {
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #1a1a1a, #252525);
    min-height: 300px;
}

.code-form {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 40px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.code-form h2 {
    color: #bb86fc;
    margin-bottom: 20px;
    font-size: 1.4rem;
    text-align: center;
}

.code-form p {
    color: #aaa;
    margin-bottom: 24px;
    text-align: center;
    font-size: 0.95rem;
}

.code-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.code-input {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 4px;
    background: #121212;
    border: 2px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.code-input:focus {
    outline: none;
    border-color: #bb86fc;
    box-shadow: 0 0 10px rgba(187, 134, 252, 0.3);
}

.code-input::placeholder {
    color: #666;
    letter-spacing: 2px;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: bold;
    background: #bb86fc;
    border: none;
    border-radius: 8px;
    color: #121212;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

.submit-btn:hover {
    background: #c9a0ff;
    transform: translateY(-2px);
}

.submit-btn:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #444;
}

.auth-divider span {
    padding: 0 16px;
    color: #888;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Discord Login Button */
.discord-login-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: bold;
    background: #5865F2;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background 0.3s, transform 0.2s;
}

.discord-login-btn:hover {
    background: #4752C4;
    transform: translateY(-2px);
}

.discord-login-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

.discord-login-btn img {
    width: 24px;
    height: 24px;
}

/* My Tournaments Section */
.my-tournaments-section {
    padding: 40px 60px;
    animation: fadeIn 0.3s ease-in-out;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #333;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.discord-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #5865F2;
}

#discord-username {
    font-size: 1.2rem;
    color: #e0e0e0;
    font-weight: 500;
}

.user-actions {
    display: flex;
    gap: 12px;
}

.link-guest-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    background: transparent;
    border: 1px solid #5865F2;
    color: #5865F2;
}

.link-guest-btn:hover {
    background: rgba(88, 101, 242, 0.1);
}

.discord-logout-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    background: transparent;
    border: 1px solid #ff5252;
    color: #ff5252;
}

.discord-logout-btn:hover {
    background: rgba(255, 82, 82, 0.1);
}

.tournaments-header {
    margin-bottom: 24px;
}

.tournaments-header h2 {
    color: #bb86fc;
    font-size: 1.5rem;
}

/* Tournament Cards */
.tournaments-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.tournament-card {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.tournament-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: #bb86fc;
}

.tournament-card.active {
    border-color: #81c784;
    box-shadow: 0 0 15px rgba(129, 199, 132, 0.2);
}

.tournament-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.tournament-card-title {
    color: #e0e0e0;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.tournament-card-game {
    color: #aaa;
    font-size: 0.85rem;
    margin-top: 4px;
}

.tournament-card-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.tournament-card-status.inscription {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
}

.tournament-card-status.en-cours {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.tournament-card-status.termine {
    background: rgba(158, 158, 158, 0.2);
    color: #bdbdbd;
}

.tournament-card-body {
    color: #aaa;
    font-size: 0.9rem;
}

.tournament-card-info {
    display: flex;
    gap: 20px;
    margin-bottom: 12px;
}

.tournament-card-info span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tournament-card-rank {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #333;
    color: #bb86fc;
    font-weight: 500;
}

.tournament-card-rank .rank-badge {
    background: rgba(187, 134, 252, 0.2);
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: bold;
}

.tournament-card-forfeit {
    color: #ff8a80;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Empty State */
.no-tournaments {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}

.no-tournaments h3 {
    color: #bb86fc;
    margin-bottom: 16px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-in-out;
}

.modal-content {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
}

.modal-content h3 {
    color: #bb86fc;
    margin-bottom: 16px;
}

.modal-content p {
    color: #aaa;
    margin-bottom: 20px;
}

.modal-content .code-input {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-actions .submit-btn {
    flex: 1;
}

.cancel-btn {
    flex: 1;
    padding: 16px;
    font-size: 1rem;
    background: transparent;
    border: 1px solid #666;
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #888;
}

/* Back Button */
.back-to-list-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    background: transparent;
    border: 1px solid #bb86fc;
    color: #bb86fc;
    margin-right: 12px;
}

.back-to-list-btn:hover {
    background: rgba(187, 134, 252, 0.1);
}

/* Finished Tournament Styles */
.finished-result {
    text-align: center;
    padding: 30px;
}

.finished-result.top-finish {
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.final-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.final-rank {
    font-size: 3rem;
    font-weight: bold;
    color: #bb86fc;
}

.top-finish .final-rank {
    color: #ffd700;
}

.final-message {
    font-size: 1.2rem;
    color: #e0e0e0;
}

.final-points {
    font-size: 1rem;
    color: #aaa;
    margin-top: 8px;
}

/* Error Message */
.error-message {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.5);
    border-radius: 8px;
    padding: 12px 16px;
    color: #ff5252;
    margin-top: 16px;
    text-align: center;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Ban Message */
.ban-message {
    background: rgba(255, 82, 82, 0.2);
    border: 2px solid #ff5252;
    border-radius: 12px;
    padding: 24px;
    color: #ff8a80;
    margin-top: 20px;
    text-align: center;
}

.ban-message h3 {
    color: #ff5252;
    margin-bottom: 10px;
}

.ban-timer {
    font-size: 2rem;
    font-weight: bold;
    color: #ff5252;
    margin-top: 10px;
}

/* Tournament Info Section */
.tournament-info {
    display: none;
    padding: 40px 60px;
    animation: fadeIn 0.3s ease-in-out;
}

.tournament-info.active {
    display: block;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #333;
}

.tournament-title h2 {
    color: #bb86fc;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.tournament-meta {
    display: flex;
    gap: 20px;
    color: #aaa;
    font-size: 0.95rem;
}

.tournament-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.inscription {
    background: rgba(33, 150, 243, 0.2);
    color: #64b5f6;
    border: 1px solid #64b5f6;
}

.status-badge.en-cours {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
    border: 1px solid #81c784;
}

.status-badge.termine {
    background: rgba(158, 158, 158, 0.2);
    color: #bdbdbd;
    border: 1px solid #bdbdbd;
}

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

.refresh-btn, .logout-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
}

.refresh-btn {
    background: transparent;
    border: 1px solid #bb86fc;
    color: #bb86fc;
}

.refresh-btn:hover {
    background: rgba(187, 134, 252, 0.1);
}

.logout-btn {
    background: transparent;
    border: 1px solid #ff5252;
    color: #ff5252;
}

.logout-btn:hover {
    background: rgba(255, 82, 82, 0.1);
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

/* Match Card */
.match-card {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.match-card h3 {
    color: #bb86fc;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.my-match {
    border-color: #bb86fc;
    box-shadow: 0 0 15px rgba(187, 134, 252, 0.2);
}

.my-match h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.my-match h3::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #bb86fc;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

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

.match-players {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.player {
    flex: 1;
    text-align: center;
}

.player-name {
    font-size: 1rem;
    color: #e0e0e0;
    margin-bottom: 8px;
    word-break: break-word;
}

.player-name.me {
    color: #bb86fc;
    font-weight: bold;
}

.player-score {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
}

.player-score.winner {
    color: #81c784;
}

.player-score.loser {
    color: #ff8a80;
}

/* Score Input Styles */
.score-input {
    width: 60px;
    height: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    background: #121212;
    border: 2px solid #444;
    border-radius: 8px;
    color: #fff;
    margin-top: 8px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.score-input:focus {
    outline: none;
    border-color: #bb86fc;
    box-shadow: 0 0 10px rgba(187, 134, 252, 0.3);
}

.score-input::-webkit-inner-spin-button,
.score-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.score-input[type=number] {
    -moz-appearance: textfield;
}

/* Submit Result Button */
.submit-result-btn {
    width: 100%;
    padding: 14px 24px;
    margin-top: 16px;
    font-size: 1rem;
    font-weight: bold;
    background: linear-gradient(135deg, #bb86fc, #9b59b6);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.submit-result-btn:hover {
    background: linear-gradient(135deg, #c9a0ff, #a76bc4);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(187, 134, 252, 0.4);
}

.submit-result-btn:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Submit Error */
.submit-error {
    margin-top: 12px;
}

.submit-error .error-message {
    margin-top: 0;
    font-size: 0.9rem;
}

.vs {
    font-size: 1.2rem;
    color: #666;
    font-weight: bold;
}

.match-status {
    text-align: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #333;
    font-size: 0.9rem;
}

.match-status.pending {
    color: #ffd54f;
}

.match-status.completed {
    color: #81c784;
}

.bye-match {
    text-align: center;
    padding: 20px;
    color: #aaa;
}

.bye-match .bye-label {
    font-size: 1.2rem;
    color: #bb86fc;
    margin-bottom: 8px;
}

/* Standings Table */
.standings-container {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    overflow: hidden;
}

.standings-container h3 {
    color: #bb86fc;
    padding: 16px 20px;
    margin: 0;
    background: #252525;
    border-bottom: 1px solid #333;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
}

.standings-table th {
    background: #1a1a1a;
    color: #aaa;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.standings-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #2a2a2a;
    color: #e0e0e0;
}

.standings-table tr:last-child td {
    border-bottom: none;
}

.standings-table tr:hover {
    background: rgba(187, 134, 252, 0.05);
}

.standings-table tr.highlight {
    background: rgba(187, 134, 252, 0.15);
}

.standings-table tr.highlight td {
    color: #bb86fc;
    font-weight: 500;
}

.rank-cell {
    font-weight: bold;
    color: #bb86fc;
}

.rank-cell.top-3 {
    font-size: 1.1rem;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.stats-cell {
    font-family: monospace;
    font-size: 0.9rem;
    color: #aaa;
}

/* Round Matches Section */
.round-matches {
    margin-top: 40px;
}

.round-matches h3 {
    color: #bb86fc;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

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

/* No Tournament Message */
.no-tournament {
    text-align: center;
    padding: 60px 20px;
    color: #aaa;
}

.no-tournament h3 {
    color: #bb86fc;
    margin-bottom: 16px;
}

/* Loading State */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #aaa;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #bb86fc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

    .tournament-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions button {
        flex: 1;
    }

    .tournament-info {
        padding: 20px;
    }
}

@media (max-width: 600px) {
    .code-form {
        padding: 24px;
        margin: 0 16px;
    }

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

    .standings-table {
        font-size: 0.85rem;
    }

    .standings-table th,
    .standings-table td {
        padding: 10px 8px;
    }
}

/* Match Actions Container */
.match-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.match-actions .submit-result-btn {
    flex: 2;
    margin-top: 0;
}

/* Forfeit Button */
.forfeit-btn {
    flex: 1;
    padding: 14px 16px;
    font-size: 0.9rem;
    font-weight: bold;
    background: transparent;
    border: 2px solid #ff5252;
    border-radius: 8px;
    color: #ff5252;
    cursor: pointer;
    transition: all 0.3s;
}

.forfeit-btn:hover {
    background: rgba(255, 82, 82, 0.15);
    transform: translateY(-2px);
}

.forfeit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Forfeit Confirmation */
.forfeit-confirmation {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid rgba(255, 82, 82, 0.4);
    border-radius: 8px;
    animation: fadeIn 0.3s ease-in-out;
}

.forfeit-confirmation p {
    color: #ff8a80;
    margin: 0 0 12px 0;
    text-align: center;
}

.forfeit-warning {
    font-size: 0.85rem;
    color: #aaa !important;
}

.forfeit-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.forfeit-confirm-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: bold;
    background: #ff5252;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
}

.forfeit-confirm-btn:hover {
    background: #ff6b6b;
    transform: translateY(-2px);
}

.forfeit-confirm-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

.forfeit-cancel-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: bold;
    background: transparent;
    border: 1px solid #666;
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s;
}

.forfeit-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #888;
    color: #ddd;
}

.forfeit-cancel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Responsive adjustments for forfeit */
@media (max-width: 600px) {
    .match-actions {
        flex-direction: column;
    }

    .forfeit-buttons {
        flex-direction: column;
    }
}

/* Responsive for My Tournaments */
@media (max-width: 900px) {
    .my-tournaments-section {
        padding: 20px;
    }

    .user-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .user-actions {
        width: 100%;
    }

    .user-actions button {
        flex: 1;
    }

    .tournaments-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .user-actions {
        flex-direction: column;
    }

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