﻿/* =====================================================================
   Challenge History – Styles
   /wwwroot/css/challengehistory.css

   IMPORTANT: Every selector that could conflict with the site navbar
   (dropdown-toggle::after, dropdown-menu, dropdown-item) is scoped
   under .challenge-history-page or uses the .ch-dropdown prefix,
   so it NEVER touches nav arrows or menus.
   ===================================================================== */

/* ── Page shell ── */
.challenge-history-page {
    max-width: 1300px;
    margin: 0 auto;
    padding: 28px 20px 60px;
    font-family: inherit;
    color: #1a1a2e;
}

/* ── Hero banner ── */
.hero-banner {
    width: 100%;
    max-height: 220px;
    overflow: hidden;
}

    .hero-banner img {
        width: 100%;
        object-fit: cover;
        object-position: center 40%;
        display: block;
    }

/* ================================================================
   Tabs
   ================================================================ */
.history-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #dde3ec;
    margin-bottom: 28px;
}

.history-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    letter-spacing: .01em;
}

    .history-tab:hover {
        color: #1a1a2e;
    }

    .history-tab.active {
        color: #1a1a2e;
        border-bottom-color: #2563eb;
    }

/* ── Panels ── */
.history-panel {
}

    .history-panel.hidden {
        display: none;
    }

/* ================================================================
   Standings info header
   ================================================================ */
.standings-info {
    margin-bottom: 20px;
}

#standingsChallengeName {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

/* ================================================================
   Standings table
   ================================================================ */
.standings-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 700px;
}

    .standings-table thead tr {
        background: #f8f9fb;
        border-bottom: 2px solid #dde3ec;
    }

    .standings-table th {
        padding: 11px 14px;
        text-align: left;
        font-size: 12px;
        font-weight: 700;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: .05em;
        white-space: nowrap;
    }

    .standings-table tbody tr {
        border-bottom: 1px solid #eef0f5;
        transition: background .12s;
    }

        .standings-table tbody tr:hover {
            background: #f5f7ff;
        }

    .standings-table td {
        padding: 12px 14px;
        vertical-align: middle;
    }

        /* Score column bold */
        .standings-table td:nth-child(4) {
            font-weight: 700;
            font-size: 16px;
            color: #1a1a2e;
        }

/* Placement badge */
.placement-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}

    .placement-badge.p1 {
        background: #d4a017;
    }

    .placement-badge.p2 {
        background: #9ca3af;
    }

    .placement-badge.p3 {
        background: #b45309;
    }

    .placement-badge.pn {
        background: #4b5563;
    }

/* Wager net coloring */
.val-positive {
    color: #16a34a;
    font-weight: 600;
}

.val-negative {
    color: #dc2626;
    font-weight: 600;
}

.val-zero {
    color: #9ca3af;
}

/* Pick cells */
.pick-line {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

    .pick-line.correct .pick-name {
        color: #16a34a;
        font-weight: 600;
    }

.pick-bonus {
    background: #dcfce7;
    color: #15803d;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
}

/* ── Coach chip (avatar + name, clickable) ── */
a.coach-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: opacity .15s;
}

    a.coach-link:hover {
        opacity: .75;
    }

.ch-coach-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #77dd77;
    flex-shrink: 0;
    object-fit: cover;
    display: none; /* shown after load */
}

.ch-coach-initials {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #77dd77;
    flex-shrink: 0;
    background: #e5f6e5;
    color: #14532d;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ch-coach-name {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

/* Roster chips – clickable castaways */
.roster-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 280px;
}

.roster-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f3f4f6;
    border: 2px solid #d1d5db;
    border-radius: 20px;
    padding: 3px 10px 3px 4px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s, box-shadow .12s;
}

    .roster-chip:hover {
        background: #e0e7ff;
        box-shadow: 0 0 0 2px #6366f1;
    }

    .roster-chip img {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        object-fit: cover;
        flex-shrink: 0;
    }

    .roster-chip.mvp {
        background: #fef3c7;
        border-color: #fbbf24;
        color: #92400e;
        font-weight: 700;
    }

    .roster-chip.eliminated {
        opacity: .5;
        text-decoration: line-through;
    }

    .roster-chip sup {
        font-size: 9px;
        font-weight: 700;
        color: inherit;
    }

/* ================================================================
   Scoreboard tab – controls
   ================================================================ */
.scoreboard-team-picker {
    margin-bottom: 16px;
}

.scoreboard-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ── Scoped dropdown (.ch-dropdown) – NEVER touches .navbar ── */
.ch-dropdown {
    position: relative;
    display: inline-block;
}

.ch-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    white-space: nowrap;
    user-select: none;
}

    .ch-dropdown-btn:hover {
        border-color: #2563eb;
        box-shadow: 0 0 0 3px rgba(37,99,235,.1);
    }
/* SVG chevron – won't inherit Bootstrap's ::after override */
.ch-dropdown-chevron {
    display: inline-block;
    width: 12px;
    height: 7px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.ch-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    max-height: 300px;
    overflow-y: auto;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 200;
    padding: 6px 0;
    list-style: none;
    margin: 0;
}

    .ch-dropdown-menu.show {
        display: block;
    }

    .ch-dropdown-menu li {
        padding: 0;
    }

    .ch-dropdown-menu a {
        display: block;
        padding: 9px 16px;
        font-size: 14px;
        color: #1a1a2e;
        text-decoration: none;
        transition: background .1s;
        cursor: pointer;
    }

        .ch-dropdown-menu a:hover {
            background: #f0f4ff;
            color: #2563eb;
        }

/* ── Segmented switch ── */
.seg-switch {
    display: inline-flex;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.seg-btn {
    background: none;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}

    .seg-btn.active,
    .seg-btn[aria-pressed="true"] {
        background: #fff;
        color: #1a1a2e;
        box-shadow: 0 1px 4px rgba(0,0,0,.12);
    }

/* ================================================================
   Scoreboard table
   ================================================================ */
.scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scroll-top {
    height: 16px;
    margin-bottom: 2px;
}

.scroll-spacer {
    height: 1px;
}

.scroll-hint {
    display: none;
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
    line-height: 16px;
}

.scroll-bottom {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 900px;
    background: #fff;
}

    .scoreboard-table thead tr:first-child th {
        background: #1a1a2e;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        padding: 10px 8px;
        text-align: center;
        white-space: nowrap;
        border-right: 1px solid rgba(255,255,255,.1);
    }

    .scoreboard-table thead tr:nth-child(2) th {
        background: #252547;
        color: #c7d0e8;
        font-size: 10px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        padding: 7px 8px;
        text-align: center;
        white-space: nowrap;
        border-right: 1px solid rgba(255,255,255,.08);
    }

    .scoreboard-table tbody tr {
        border-bottom: 1px solid #eef0f5;
        transition: background .1s;
    }

        .scoreboard-table tbody tr:hover {
            background: #f5f7ff;
        }

    .scoreboard-table tbody td {
        padding: 10px 8px;
        text-align: center;
        vertical-align: middle;
        color: #374151;
        font-size: 13px;
    }
        /* Role column */
        .scoreboard-table tbody td:first-child {
            text-align: left;
            font-weight: 600;
            color: #4b5563;
            font-size: 12px;
            white-space: nowrap;
            padding-left: 14px;
        }
/* Player cell */
.player-cell {
    display: flex !important;
    align-items: center;
    gap: 8px;
    text-align: left !important;
    min-width: 160px;
    padding-left: 10px !important;
    cursor: pointer;
    border-radius: 6px;
    transition: background .1s;
}

    .player-cell:hover {
        background: #f0f4ff;
    }

    .player-cell img {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid #d1d5db;
        flex-shrink: 0;
    }

    .player-cell .player-name {
        font-weight: 600;
        font-size: 13px;
        color: #1a1a2e;
        white-space: nowrap;
    }

    .player-cell.was-eliminated .player-name {
        text-decoration: line-through;
        color: #9ca3af;
    }
/* Total points column */
.scoreboard-table tbody td:nth-child(3) {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a2e;
}

.stat-cell {
    min-width: 36px;
    color: #4b5563;
}

/* ================================================================
   Transactions
   ================================================================ */
.tx-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tx-filter-btn {
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all .15s;
}

    .tx-filter-btn:hover {
        border-color: #2563eb;
        color: #2563eb;
    }

    .tx-filter-btn.active {
        background: #2563eb;
        border-color: #2563eb;
        color: #fff;
    }

.transactions-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 560px;
}

    .tx-table thead tr {
        background: #f8f9fb;
        border-bottom: 2px solid #dde3ec;
    }

    .tx-table th {
        padding: 10px 14px;
        text-align: left;
        font-size: 12px;
        font-weight: 700;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: .05em;
        white-space: nowrap;
    }

    .tx-table tbody tr {
        border-bottom: 1px solid #eef0f5;
        transition: background .1s;
    }

        .tx-table tbody tr:hover {
            background: #f5f7ff;
        }

    .tx-table td {
        padding: 11px 14px;
        vertical-align: middle;
        color: #374151;
    }

.tx-type-badge {
    display: inline-block;
    border-radius: 12px;
    padding: 3px 11px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

    .tx-type-badge.swap {
        background: #ede9fe;
        color: #6d28d9;
    }

    .tx-type-badge.elim-wager {
        background: #fee2e2;
        color: #b91c1c;
    }

    .tx-type-badge.imm-wager {
        background: #dbeafe;
        color: #1d4ed8;
    }

.tx-outcome-won {
    color: #16a34a;
    font-weight: 700;
}

.tx-outcome-lost {
    color: #dc2626;
    font-weight: 700;
}

/* ================================================================
   Coach Profile Drawer (injected by JS into body)
   ================================================================ */
#chCoachBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 1040;
}

    #chCoachBackdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

#chCoachDrawer {
    position: fixed;
    top: 64px;
    right: -100%;
    bottom: 0;
    width: min(92vw, 420px);
    background: #fff;
    box-shadow: -2px 0 16px rgba(0,0,0,.2);
    border-left: 1px solid rgba(0,0,0,.08);
    border-top-left-radius: 12px;
    display: flex;
    flex-direction: column;
    transition: right .28s ease;
    z-index: 1041;
}

    #chCoachDrawer.open {
        right: 0;
    }

.ch-cd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
}

.ch-cd-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.ch-cd-close {
    appearance: none;
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.ch-cd-body {
    overflow: auto;
    height: 100%;
    padding: 0;
}

/* ================================================================
   Loading / empty messages
   ================================================================ */
.loading-msg {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 48px 0;
    font-size: 14px;
}

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 640px) {
    .challenge-history-page {
        padding: 16px 12px 40px;
    }

    .history-tab {
        padding: 10px 14px;
        font-size: 13px;
    }

    #standingsChallengeName {
        font-size: 18px;
    }

    .standings-table th, .standings-table td {
        padding: 9px 8px;
    }

    .roster-list {
        min-width: 0;
    }

    .scoreboard-controls {
        flex-wrap: wrap;
    }
}
