/*
 * Bagan pertandingan live (bagan-pertandingan.php + assets/js/bracket.js).
 * Semua class memakai prefix "bk-" supaya tidak bentrok dengan style situs
 * (mis. .match-card di style.css). Warna memakai token situs dari style.css.
 */
:root {
    /* HARUS sama dengan konstanta COL_WIDTH di assets/js/bracket.js */
    --bk-card-width: 240px;
    --bk-winner-bg: var(--um-orange);
    --bk-winner-text: #1c2530;
    --bk-loser-bg: #eef1f4;
    --bk-loser-text: var(--ink-soft);
    --bk-line: #8a96a5;
}

/* ---------------------------- Tab kategori ---------------------------- */
.bk-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
}

.bk-tab {
    flex: 0 0 auto;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    background: none;
    color: var(--ink-soft);
    font: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
}

.bk-tab:hover { color: var(--um-blue); }

.bk-tab.is-active {
    color: var(--um-blue);
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: inset 0 3px 0 var(--um-blue);
}

.bk-tab:focus-visible {
    outline: 2px solid var(--um-blue);
    outline-offset: 2px;
}

/* HP: tab jadi grid 2x2 supaya keempat kategori terlihat tanpa scroll samping;
   kata "Perorangan" disembunyikan agar label muat. */
@media (max-width: 640px) {
    .bk-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        overflow: visible;
        border-bottom: none;
    }

    .bk-tab {
        padding: 10px 8px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--card-bg);
        text-align: center;
        line-height: 1.25;
    }

    .bk-tab.is-active {
        color: #fff;
        background: var(--um-blue);
        border-color: var(--um-blue);
        box-shadow: none;
    }

    .bk-tab__prefix { display: none; }
}

.bk-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.bk-panel__desc {
    margin: 0 0 16px;
    color: var(--ink-soft);
}

/* Baris atas panel: deskripsi di kiri, tombol "Layar penuh" di kanan. */
.bk-panel__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 16px;
}
.bk-panel__head .bk-panel__desc { margin: 0; }

.bk-fullscreen {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--um-blue);
    text-decoration: none;
    white-space: nowrap;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.bk-fullscreen:hover { border-color: var(--um-blue); }
.bk-fullscreen[hidden] { display: none; }

.bk-meta {
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--ink-soft);
}

.bk-meta:empty { display: none; }

/* Embed resmi Challonge (dipakai saat kuota API habis). */
.bk-embed {
    display: block;
    width: 100%;
    height: 640px;
    border: 0;
    border-radius: 10px;
    background: #fff;
}

@media (max-width: 640px) {
    .bk-embed { height: 520px; }
}

.bk-loading { color: var(--ink-soft); }

.bk-error {
    color: #b42318;
    background: #fef3f2;
    border: 1px solid #fecdca;
    border-radius: 10px;
    padding: 12px 16px;
}

.bk-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.bk-head h3 {
    margin: 0;
    font-size: 1.15rem;
}

.bk-badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(29, 112, 183, 0.1);
    color: var(--um-blue);
}

.bk-badge--complete {
    background: rgba(46, 158, 91, 0.14);
    color: #1f7a45;
}

.bk-badge--pending {
    background: var(--bk-loser-bg);
    color: var(--ink-soft);
}

.bk-section { margin-top: 22px; }

.bk-section__title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ------------------------- Penyisihan grup ---------------------------- */
.bk-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
    gap: 16px;
}

.bk-group {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.bk-group__title {
    margin: 0;
    padding: 10px 14px;
    background: var(--um-blue);
    color: #fff;
    font-size: 0.95rem;
}

.bk-standings-wrap { overflow-x: auto; }

/* min-width di-reset: style.css memberi semua <table> min-width 560px. */
table.bk-standings {
    min-width: 0;
    width: 100%;
}

.bk-standings th,
.bk-standings td {
    padding: 8px 10px;
    font-size: 0.85rem;
    text-align: center;
    vertical-align: middle;
}

.bk-standings th { font-size: 0.72rem; }

.bk-standings td.bk-standings__name,
.bk-standings th:nth-child(2) {
    text-align: left;
    width: 100%;
}

.bk-standings th { white-space: nowrap; }

.bk-standings td.bk-standings__key { font-weight: 700; }

.bk-history { white-space: nowrap; }

.bk-history__chip {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    margin: 0 1px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
}

.bk-history__chip--win { background: var(--um-green); }
.bk-history__chip--loss { background: #e5484d; }

.bk-group-matches {
    list-style: none;
    margin: 0;
    padding: 6px 14px 12px;
    border-top: 1px solid var(--border);
}

.bk-group-matches__title {
    padding: 6px 0 2px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}

.bk-gm {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--ink-soft);
}

.bk-gm + .bk-gm { border-top: 1px dashed var(--border); }

.bk-gm__team--right { text-align: right; }

.bk-gm__team.is-winner {
    color: var(--ink);
    font-weight: 700;
}

.bk-gm__score {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--ink);
    white-space: nowrap;
}

.bk-gm.bk-state-open .bk-gm__score { color: var(--um-blue); }

/* ------------------------------ Bagan --------------------------------- */
.bk-scroll {
    overflow-x: auto;
    padding-bottom: 8px;
}

.bk-track { position: relative; }

.bk-round-label {
    position: absolute;
    top: 0;
    width: var(--bk-card-width);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.bk-connectors {
    position: absolute;
    top: 0;
    left: 0;
    overflow: visible;
    pointer-events: none;
}

.bk-connectors path {
    fill: none;
    stroke: var(--bk-line);
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.bk-connectors text {
    fill: var(--ink-soft);
    font-size: 10px;
    font-family: inherit;
}

.bk-match {
    position: absolute;
    width: var(--bk-card-width);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.bk-match.bk-state-open {
    outline: 2px solid var(--um-blue);
    outline-offset: 1px;
}

.bk-match.bk-state-pending { opacity: 0.7; }

.bk-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bk-loser-bg);
    color: var(--bk-loser-text);
}

.bk-row:first-child { border-bottom: 1px solid rgba(0, 0, 0, 0.06); }

.bk-row.is-winner {
    background: var(--bk-winner-bg);
    color: var(--bk-winner-text);
}

.bk-seed {
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    padding: 0 3px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.1);
}

.bk-seed:empty { visibility: hidden; }

/* Nama panjang otomatis wrap; tinggi kartu dihitung ulang oleh bracket.js,
   jadi garis penghubung tetap presisi. */
.bk-name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.3;
    font-weight: 500;
}

.bk-row.is-winner .bk-name { font-weight: 700; }

.bk-scores {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

.bk-set {
    min-width: 14px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 620px) {
    .bk-panel { padding: 16px; }
}
