/*
 * Ikigai Combat — Chaveamento (bracket)
 * Mesma linguagem visual do telão de resultados ao vivo (broadcast):
 * fundo escuro, tipografia Teko/Barlow e acentos vermelho/âmbar.
 * Usado tanto na chave pública (tela cheia) quanto embutido no admin.
 */

:root {
    --rl-bg-0: #070809;
    --rl-bg-1: #101214;
    --rl-bg-2: #171a1d;
    --rl-surface: rgba(22, 25, 28, 0.92);
    --rl-line: rgba(255, 255, 255, 0.08);
    --rl-text: #f4f5f6;
    --rl-muted: #9aa3ad;
    --rl-red: #d32f2f;
    --rl-red-deep: #9a1c1c;
    --rl-amber: #f0a500;
    --rl-live: #2ecc71;
    --rl-danger: #e74c3c;
    --rl-blue: #5dade2;

    --rl-font-display: 'Teko', 'Arial Narrow', sans-serif;
    --rl-font-ui: 'Barlow', 'Helvetica Neue', sans-serif;
    --rl-radius: 4px;
}

/* ── Palco escuro ── */
.bracket-container {
    position: relative;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(211, 47, 47, 0.18), transparent 55%),
        radial-gradient(ellipse 55% 40% at 100% 0%, rgba(240, 165, 0, 0.1), transparent 50%),
        linear-gradient(165deg, var(--rl-bg-0) 0%, var(--rl-bg-1) 45%, #0c0e10 100%);
    color: var(--rl-text);
    font-family: var(--rl-font-ui);
    -webkit-font-smoothing: antialiased;
}

.bracket-container::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.035;
    background-image: repeating-linear-gradient(
        -18deg,
        transparent 0,
        transparent 11px,
        rgba(255, 255, 255, 0.55) 11px,
        rgba(255, 255, 255, 0.55) 12px
    );
    z-index: 0;
}

/* Variante embutida (dentro de um card do admin, não ocupa a viewport toda) */
.bracket-container.bracket-container--embedded {
    min-height: auto;
    border-radius: 12px;
    overflow: hidden;
}

/* ── Barra de ferramentas (usada no admin) ── */
.bk-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: clamp(14px, 2vw, 20px) clamp(16px, 2.2vw, 24px);
    border-bottom: 1px solid var(--rl-line);
}

.bk-toolbar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.bk-toolbar-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--rl-radius);
    background: linear-gradient(135deg, var(--rl-red), var(--rl-amber));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.bk-toolbar-event {
    font-family: var(--rl-font-display);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--rl-text);
    line-height: 1.1;
}

.bk-toolbar-cat {
    font-size: 0.82rem;
    color: var(--rl-muted);
    margin-top: 0.15rem;
}

.bk-toolbar-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ── Botões ── */
.bk-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5em 1.1em;
    border-radius: var(--rl-radius);
    font-family: var(--rl-font-ui);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bk-btn-outline {
    border-color: var(--rl-line);
    color: var(--rl-muted);
    background: transparent;
}

.bk-btn-outline:hover {
    border-color: var(--rl-red);
    color: #fff;
    background: rgba(211, 47, 47, 0.12);
}

.bk-btn-ghost {
    border-color: rgba(93, 173, 226, 0.4);
    color: var(--rl-blue);
    background: rgba(93, 173, 226, 0.08);
}

.bk-btn-ghost:hover {
    background: rgba(93, 173, 226, 0.18);
    color: #fff;
}

.bk-btn-primary {
    background: linear-gradient(135deg, var(--rl-red), var(--rl-red-deep));
    color: #fff;
    box-shadow: 0 6px 18px rgba(211, 47, 47, 0.35);
}

.bk-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(211, 47, 47, 0.45);
    color: #fff;
}

/* ── Alerta (ex.: gerar disputa de 3º lugar) ── */
.bk-alert {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: clamp(14px, 2vw, 20px) clamp(16px, 2.2vw, 24px) 0;
    padding: 1rem 1.25rem;
    border-radius: var(--rl-radius);
    background: rgba(93, 173, 226, 0.1);
    border: 1px solid rgba(93, 173, 226, 0.35);
    color: var(--rl-text);
}

.bk-alert i {
    color: var(--rl-blue);
}

.bk-alert-sub {
    color: var(--rl-muted);
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

/* ── Rounds / colunas de lutas ── */
.bk-rounds {
    position: relative;
    z-index: 1;
    display: flex;
    gap: clamp(16px, 2vw, 28px);
    padding: clamp(16px, 2.2vw, 24px);
    overflow-x: auto;
    align-items: flex-start;
}

.bk-round {
    flex: 0 0 auto;
    width: min(320px, 86vw);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bk-round-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--rl-line);
}

.bk-round-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3em 0.85em;
    background: linear-gradient(135deg, var(--rl-red), var(--rl-red-deep));
    color: #fff;
    font-family: var(--rl-font-display);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: var(--rl-radius);
    white-space: nowrap;
}

.bk-round-progress {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--rl-line);
    color: var(--rl-muted);
    border-radius: 20px;
    padding: 0.2em 0.65em;
    white-space: nowrap;
}

.bk-matches {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Card de luta ── */
.match-card {
    background: var(--rl-surface);
    border: 1px solid var(--rl-line);
    border-radius: var(--rl-radius);
    overflow: hidden;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.match-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--rl-red), var(--rl-amber));
}

.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    border-color: rgba(211, 47, 47, 0.4);
}

/* #4: destaca a luta do atleta logado, pra ele nao precisar catar o proprio
   nome no meio da chave inteira pra saber com quem vai lutar. */
.match-card--minha-luta {
    border-color: var(--rl-amber, #f1c40f);
    box-shadow: 0 0 0 2px rgba(241, 196, 15, 0.35), 0 12px 28px rgba(0, 0, 0, 0.35);
}

.match-card--minha-luta::before {
    width: 5px;
    background: var(--rl-amber, #f1c40f);
}

.match-minha-luta-badge {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.85rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #111;
    background: var(--rl-amber, #f1c40f);
}

.bk-jump-minha-luta {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.1rem;
    border: none;
    border-radius: 999px;
    background: var(--rl-amber, #f1c40f);
    color: #111;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.bk-jump-minha-luta:hover {
    filter: brightness(1.05);
}

.match-content {
    padding: 0;
}

/* Participante */
.participant {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--rl-line);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--rl-text);
    position: relative;
    transition: background 0.2s ease, color 0.2s ease;
}

.participant:last-child {
    border-bottom: none;
}

.competitor-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant.winner {
    background: rgba(46, 204, 113, 0.12);
    color: var(--rl-live);
}

.participant.winner .competitor-name {
    font-weight: 700;
}

.participant.winner .fa-trophy {
    color: var(--rl-live);
    font-size: 1.05rem;
}

.participant.loser {
    background: rgba(231, 76, 60, 0.06);
    color: var(--rl-muted);
    opacity: 0.85;
}

.participant.loser .fa-times {
    color: var(--rl-danger);
    font-size: 1.05rem;
}

.participant.pending {
    background: transparent;
    color: var(--rl-text);
    opacity: 0.92;
}

.match-card[data-vencedor-id] .participant.pending {
    opacity: 0.5;
}

/* Divisor VS */
.vs-divider {
    background: rgba(255, 255, 255, 0.03);
    color: var(--rl-muted);
    text-align: center;
    padding: 0.35rem;
    font-family: var(--rl-font-display);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    border-top: 1px solid var(--rl-line);
    border-bottom: 1px solid var(--rl-line);
    position: relative;
    overflow: hidden;
}

.vs-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    animation: bkShimmer 2.4s infinite;
}

@keyframes bkShimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Rodapé do card: pendente */
.match-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--rl-line);
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--rl-muted);
}

/* Rodapé do card: encerrada */
.match-result-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: rgba(46, 204, 113, 0.12);
    border-top: 1px solid rgba(46, 204, 113, 0.35);
    font-size: 0.8rem;
    color: var(--rl-live);
    font-weight: 700;
}

/* Botão declarar vencedor (admin) — mesmo gradiente do ícone vencedor do telão */
.set-winner-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #1e8f4f, var(--rl-live));
    border: none;
    color: #fff !important;
    padding: 0.55rem 1.3rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
}

.set-winner-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 8px 22px rgba(46, 204, 113, 0.4);
    color: #fff;
}

.set-winner-btn:active {
    transform: translateY(0) scale(0.98);
}

/* ── Pódio ── */
.bk-podium {
    position: relative;
    z-index: 1;
    padding: clamp(18px, 2.4vw, 32px) clamp(16px, 2.2vw, 24px) 0;
}

.bk-podium-title {
    font-family: var(--rl-font-display);
    text-align: center;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--rl-text);
    margin-bottom: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.bk-podium-title i {
    color: var(--rl-amber);
}

.bk-podium-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(10px, 2vw, 24px);
    flex-wrap: wrap;
}

.bk-podium-col {
    text-align: center;
}

.bk-podium-step {
    border-radius: var(--rl-radius);
    padding: 1.4rem 1.3rem 1rem;
    min-width: 150px;
    border: 1px solid var(--rl-line);
    background: var(--rl-surface);
    transition: transform 0.25s ease;
}

.bk-podium-step:hover {
    transform: translateY(-6px);
}

.bk-podium-step.gold {
    border-color: #ffd700;
    background: linear-gradient(160deg, rgba(255, 215, 0, 0.16), var(--rl-surface));
    min-height: 190px;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.15);
}

.bk-podium-step.silver {
    border-color: #c0c0c0;
    background: linear-gradient(160deg, rgba(192, 192, 192, 0.16), var(--rl-surface));
    min-height: 160px;
}

.bk-podium-step.bronze {
    border-color: #cd7f32;
    background: linear-gradient(160deg, rgba(205, 127, 50, 0.18), var(--rl-surface));
    min-height: 140px;
}

.bk-medal {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 0.5rem;
    animation: bkPulse 2.5s ease infinite;
}

@keyframes bkPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.bk-podium-step.gold .bk-medal { color: #ffd700; }
.bk-podium-step.silver .bk-medal { color: #c0c0c0; }
.bk-podium-step.bronze .bk-medal { color: #cd7f32; }

.bk-podium-name {
    font-family: var(--rl-font-display);
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--rl-text);
    line-height: 1.15;
    margin-bottom: 0.3rem;
}

.bk-podium-place {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rl-muted);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 0.2em 0.7em;
    display: inline-block;
}

/* ── Link "Voltar" (chave pública) ── */
.bk-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4em 0.9em;
    border: 1px solid var(--rl-line);
    border-radius: var(--rl-radius);
    color: var(--rl-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.bk-back-link:hover {
    border-color: var(--rl-red);
    color: #fff;
    background: rgba(211, 47, 47, 0.12);
}

/* ── Responsividade ── */
@media (max-width: 720px) {
    .bk-rounds {
        flex-direction: column;
    }

    .bk-round {
        width: 100%;
    }

    .bk-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .bk-toolbar-actions {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bk-medal,
    .vs-divider::before {
        animation-duration: 0.01ms !important;
    }
}
