/*
  App-wide theme: reskins stock Bootstrap 5.3 via its CSS custom-property hooks, so every
  existing page (which already uses plain `btn btn-*`/`form-control`/`form-select`/`card`/`table`
  classes) picks up the new look with zero markup changes. Loaded after bootstrap.min.css and
  before app.css. A handful of new utility classes (.avatar-initials/.stat-pill/.phase-banner)
  cover pieces that have no stock Bootstrap equivalent, used first by the Draft Room and reusable
  elsewhere later.

  Dark "gamer-y" is the site's only theme (no light/dark toggle) — these values used to live only
  under the Dashboard's own .dashboard-dark class; promoted here so every page gets them through
  the exact same variable-driven mechanism, with zero markup changes anywhere.
*/

:root {
    --brand-primary: #7c5cff;
    --brand-primary-dark: #6142e0;
    --brand-primary-rgb: 124, 92, 255;
    --brand-accent: #2de0c2;
    --brand-danger: #ff5c7a;
    --brand-warning: #ffcb5c;
    --brand-success: #2de08f;
    --brand-surface: #181826;
    --brand-surface-muted: #10101c;
    --brand-border: #2e2e46;
    --brand-text: #f0f0fb;
    --brand-text-muted: #9a9ac0;

    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: var(--brand-primary-rgb);
    --bs-link-color: var(--brand-primary);
    --bs-link-color-rgb: var(--brand-primary-rgb);
    --bs-link-hover-color: var(--brand-primary-dark);
    --bs-body-bg: var(--brand-surface-muted);
    --bs-body-color: var(--brand-text);
    --bs-border-color: var(--brand-border);
    --bs-border-radius: 0.6rem;
    --bs-border-radius-sm: 0.4rem;
    --bs-border-radius-lg: 0.9rem;
    --bs-danger: var(--brand-danger);
    --bs-warning: var(--brand-warning);
    --bs-success: var(--brand-success);
    --bs-tertiary-bg: var(--brand-surface-muted);

    /* .table and .text-muted don't read --bs-table-color/--bs-body-color directly — Bootstrap's
       own rules redeclare --bs-table-color/--bs-table-striped-bg/etc. right on the <table>
       element itself (derived from --bs-emphasis-color), and .text-muted's color comes from
       --bs-secondary-color. A value set on :root never wins against a rule that sets the same
       custom property directly on the element, so these two source variables — not the derived
       per-component ones — are what actually need overriding here. */
    --bs-emphasis-color: var(--brand-text);
    --bs-emphasis-color-rgb: 240, 240, 251;
    --bs-secondary-color: var(--brand-text-muted);
    --bs-secondary-color-rgb: 154, 154, 192;

    --avatar-hues: 12, 48, 84, 150, 186, 222, 258, 294, 330;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: radial-gradient(circle at top, #1c1c30, var(--brand-surface-muted) 60%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--brand-text);
}

/* .table itself redeclares --bs-table-active-bg (derived from --bs-emphasis-color-rgb), so the
   "this is your row" highlight (Standings, the dashboard scoreboard) needs its own override
   targeting .table directly to get the brand-purple tint back instead of a plain overlay. */
.table {
    --bs-table-active-bg: rgba(var(--brand-primary-rgb), 0.18);
}

/* Buttons */
.btn {
    border-radius: var(--bs-border-radius);
    font-weight: 600;
    padding: 0.5rem 1.1rem;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    color: #fff;
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
}

.btn-outline-secondary {
    color: var(--brand-text-muted);
    border-color: var(--brand-border);
}

.btn-outline-secondary:hover {
    background-color: var(--brand-surface-muted);
    color: var(--brand-text);
    border-color: var(--brand-border);
}

.btn-outline-danger {
    color: var(--brand-danger);
    border-color: var(--brand-danger);
}

.btn-outline-danger:hover {
    background-color: var(--brand-danger);
    border-color: var(--brand-danger);
}

.btn-danger {
    background-color: var(--brand-danger);
    border-color: var(--brand-danger);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-primary-rgb), 0.25);
}

/* Form controls */
.form-control, .form-select {
    border-radius: var(--bs-border-radius-sm);
    border-color: var(--brand-border);
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--brand-text-muted);
}

/* Cards, tables, badges, alerts */
.card {
    border-color: var(--brand-border);
    border-radius: var(--bs-border-radius-lg);
    box-shadow: 0 2px 10px rgba(31, 31, 51, 0.06);
}

.table {
    --bs-table-hover-bg: var(--brand-surface-muted);
    border-color: var(--brand-border);
}

.table thead th {
    color: var(--brand-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom-width: 1px;
}

.badge.text-bg-primary, .badge.bg-primary {
    background-color: var(--brand-primary) !important;
}

.alert {
    border-radius: var(--bs-border-radius);
    border: none;
}

.alert-danger {
    background-color: rgba(255, 92, 122, 0.16);
    color: #ffb3c2;
}

.alert-warning {
    background-color: rgba(255, 203, 92, 0.16);
    color: #ffe1a3;
}

.alert-success {
    background-color: rgba(45, 224, 143, 0.16);
    color: #9df0cb;
}

.alert-info {
    background-color: rgba(45, 224, 194, 0.16);
    color: #9cf0e4;
}

/* --- Shared component classes (not stock Bootstrap) --- */

/* Colored-initials avatar: deterministic hue derived from the name's hash, used for both
   ProPlayer and ProTeam cards. Sizing is set by the consumer via width/height or a size modifier. */
.avatar-initials {
    --avatar-hue: 220;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background-color: hsl(var(--avatar-hue) 65% 45%);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    user-select: none;
    flex-shrink: 0;
}

.avatar-initials.is-muted {
    filter: grayscale(0.85);
    opacity: 0.55;
}

/* Team logos (fantasy or pro) — square corners instead of the circular crop, since a logo's
   meaningful content often runs right up to its edges/corners. */
.avatar-initials.is-square {
    border-radius: 0;
}

.avatar-initials.size-lg {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 1.5rem;
}

.avatar-initials.avatar-photo {
    object-fit: cover;
    background-color: var(--brand-surface-muted);
}

/* PlayerAvatar.razor — square with small rounded corners (not a circle) for the player's own
   photo, plus a small square team-logo badge overlaid bottom-right. Overrides .avatar-initials'
   circle only within this wrapper — a bare AvatarInitials elsewhere stays circular unless it's
   rendering a team logo, in which case its Square parameter is set (see .is-square above). */
.player-avatar-wrap {
    position: relative;
    display: inline-flex;
}

.player-avatar-wrap .avatar-initials {
    border-radius: 0.5rem;
}

.player-avatar-badge {
    position: absolute;
    bottom: -0.2rem;
    right: -0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 0;
    border: 1.5px solid var(--brand-surface);
    background-color: var(--brand-surface);
    object-fit: cover;
}

.player-avatar-badge.is-large {
    width: 1.5rem;
    height: 1.5rem;
}

/* HelpIcon.razor — a small "?" badge that reveals a description on hover/focus. Pure CSS (no
   Bootstrap JS bundle is loaded anywhere in this app), content sourced from data-tooltip so the
   component itself stays a one-line span. */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background-color: var(--brand-text-muted);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    margin-left: 0.35rem;
    vertical-align: middle;
    user-select: none;
}

.help-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 0.4rem);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 16rem;
    /* Fixed chrome rather than var(--brand-text)/var(--brand-surface): a tooltip popover
       shouldn't shift with the host page's theme, and needs to read as a distinct floating chip
       against the page's own dark surface — a touch lighter than --brand-surface plus a visible
       border, rather than matching (and disappearing into) it. */
    background-color: #262640;
    color: #fff;
    border: 1px solid #3a3a5c;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.35;
    padding: 0.4rem 0.6rem;
    border-radius: var(--bs-border-radius-sm);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.1s ease;
    z-index: 20;
}

.help-icon:hover::after,
.help-icon:focus::after {
    opacity: 1;
    visibility: visible;
}

/* Bold rounded stat readout — cash/escrow today, reusable anywhere a single number needs emphasis. */
.stat-pill {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    background-color: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
    padding: 0.4rem 0.9rem;
    line-height: 1.15;
}

.stat-pill .stat-pill-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-text-muted);
    font-weight: 700;
}

.stat-pill .stat-pill-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand-text);
}

.stat-pill.is-cash {
    background-color: rgba(45, 224, 143, 0.12);
    border-color: rgba(45, 224, 143, 0.35);
}

.stat-pill.is-escrow {
    background-color: rgba(255, 203, 92, 0.12);
    border-color: rgba(255, 203, 92, 0.35);
}

.stat-pill.is-escrow .stat-pill-value {
    color: var(--brand-text-muted);
}

/* Photo/initials card grid — introduced for the Draft Room's nomination grid
   (Draft/PlayerNominationGrid.razor.css has draft-specific states layered on top of these same
   class names), reused as-is for read-only browsing grids like the pro players list. */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.75rem;
}

.card-grid-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
    background-color: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
    padding: 0.85rem 0.5rem;
}

.card-grid-item.is-clickable {
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease;
}

.card-grid-item.is-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(31, 31, 51, 0.1);
    border-color: var(--brand-primary);
}

tr.is-clickable {
    cursor: pointer;
}

tr.is-clickable:hover {
    background-color: rgba(var(--brand-primary-rgb), 0.08);
}

/* Match Detail: per-game tab strip and the home/away-by-role lineup comparison grid. */
.match-game-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--brand-border);
    padding-bottom: 0.75rem;
}

.match-game-tab {
    border: 1px solid var(--brand-border);
    background-color: var(--brand-surface);
    color: var(--brand-text);
    border-radius: var(--bs-border-radius);
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.match-game-tab.is-active {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* Points Breakdown page: headline totals, per-game badges, and the selected-game math panel. */
.points-breakdown-totals {
    padding: 0.75rem 1rem;
    background-color: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
}

.points-breakdown-headline {
    font-size: 1.6rem;
    font-weight: 700;
}

.pb-week-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pb-week-nav .week-indicator {
    flex: 1;
}

.pb-manager-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pb-manager-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--brand-surface);
    color: var(--brand-text);
    cursor: pointer;
}

.pb-manager-button.is-active {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.pb-manager-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.pb-manager-points {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
    opacity: 0.85;
}

.pb-player-section {
    margin-bottom: 2rem;
}

.pb-player-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--brand-border);
}

.pb-player-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.pb-player-total {
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pb-match-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin: 0.75rem 0 0.4rem;
}

/* One row per game — a table-like grid on wide screens, collapsing into a stacked card
   (each piece just stacks, the row's own border/padding already reads as a card) below the
   breakpoint. */
.pb-game-row {
    display: grid;
    grid-template-columns: minmax(8rem, auto) 1fr auto auto;
    align-items: center;
    gap: 0.6rem 1rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
    background-color: var(--brand-surface);
    margin-bottom: 0.4rem;
}

.pb-game-row.is-bench {
    opacity: 0.6;
}

.pb-game-row.is-not-h2h {
    border-color: rgba(230, 150, 30, 0.45);
}

.pb-game-label {
    font-weight: 600;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    white-space: nowrap;
}

.pb-game-meta {
    font-size: 0.72rem;
    font-weight: 400;
}

.pb-stat-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
}

.pb-stat {
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pb-stat-label {
    color: var(--brand-text-muted);
    margin-right: 0.25rem;
}

.pb-game-total {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
}

.pb-game-flags {
    min-width: 4.5rem;
    text-align: right;
}

@media (max-width: 640px) {
    .pb-game-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .pb-game-total, .pb-game-flags {
        text-align: left;
    }
}

.points-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: var(--bs-border-radius);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.points-badge-bench {
    background-color: rgba(120, 120, 120, 0.25);
    color: var(--brand-text-muted);
}

.points-badge-h2h {
    background-color: rgba(255, 203, 92, 0.22);
    color: #ffe1a3;
}

.lineup-badge-bye {
    background-color: rgba(255, 92, 122, 0.18);
    color: #ffb3c2;
    margin-left: 0;
    margin-right: 0.35rem;
}

.card-grid-item.is-selected {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(var(--brand-primary-rgb), 0.3);
}

.match-lineup {
    display: flex;
    flex-direction: column;
    background-color: var(--brand-surface);
    border: 1px solid var(--brand-border);
    border-radius: var(--bs-border-radius);
    overflow: hidden;
}

/* Thin, mirrored comparison row: avatar at the outer edge of each side, then
   Champion/KDA/CS/VIS/DMG/Gold going inward — so the two sides read outward-in as a matchup
   rather than top-to-bottom as a roster list. Fixed widths (not min-width) on every stat cell,
   shared between the header-label row and every data row, are what keep columns vertically
   aligned despite each row's justify-content: space-between spreading them across the same
   available width. */
.match-lineup-row {
    display: grid;
    grid-template-columns: 1fr 4.5rem 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--brand-border);
}

.match-lineup-row:last-child {
    border-bottom: none;
}

.match-lineup-row.is-summary,
.match-lineup-row.is-header {
    background-color: var(--brand-surface-muted);
}

.match-lineup-role {
    text-align: center;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-text-muted);
    font-weight: 700;
}

.match-lineup-winner {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--brand-success);
}

.match-lineup-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.match-lineup-side.is-away {
    flex-direction: row-reverse;
}

.match-lineup-side.is-winner {
    background-color: rgba(var(--brand-primary-rgb), 0.1);
    border-radius: 0.3rem;
}

.match-lineup-side.is-empty {
    opacity: 0.5;
}

.match-lineup-baron,
.match-lineup-dragon,
.match-lineup-tower,
.match-lineup-inhib,
.match-lineup-herald,
.match-lineup-grub {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-text-muted);
    text-align: center;
}

.match-lineup-meta {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--brand-text-muted);
    text-transform: none;
    letter-spacing: normal;
}

.match-lineup-avatar-spacer {
    width: 3rem;
    flex-shrink: 0;
}

.match-lineup-champion {
    font-weight: 700;
    font-size: 0.8rem;
    width: 4.5rem;
    flex-shrink: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-lineup-kda {
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    width: 3.6rem;
    flex-shrink: 0;
    text-align: center;
}

.match-lineup-dmg,
.match-lineup-cs,
.match-lineup-vis,
.match-lineup-gold {
    font-size: 0.85rem;
    color: var(--brand-text-muted);
    font-variant-numeric: tabular-nums;
    width: 2.6rem;
    flex-shrink: 0;
    text-align: center;
}

.match-lineup-champion.is-label,
.match-lineup-kda.is-label,
.match-lineup-dmg.is-label,
.match-lineup-cs.is-label,
.match-lineup-vis.is-label,
.match-lineup-gold.is-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
    color: var(--brand-text-muted);
}

.card-grid-item-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.card-grid-item-meta {
    font-size: 0.75rem;
    color: var(--brand-text-muted);
}

/* Bold colored status banner — draft phase indicator today. */
.phase-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-dark));
    color: #fff;
    border-radius: var(--bs-border-radius);
    padding: 0.85rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 4px 14px rgba(var(--brand-primary-rgb), 0.28);
}

.phase-banner-timer {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.phase-banner.is-waiting {
    background: linear-gradient(90deg, var(--brand-text-muted), var(--brand-text));
}

.phase-banner.is-bidding {
    background: linear-gradient(90deg, var(--brand-accent), #0f8c7f);
}

.live-log-panel {
    max-height: 320px;
    overflow-y: auto;
    background: var(--brand-surface-muted);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 0.75rem;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.85rem;
}

.live-log-entry {
    display: flex;
    gap: 0.5rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--brand-border);
    white-space: pre-wrap;
    word-break: break-word;
}

.phase-banner.is-complete {
    background: linear-gradient(90deg, var(--brand-success), #148a5f);
}
