/* ============================================================
   StatCrew Web -- shared design system
   Matched to the DiamondStats Pro visual language so all of the
   timleister.com tools share one look: deep navy shell, near-black
   sidebar, dark cards, crimson accent, uppercase letter-spaced
   section labels, big colored stat numerals.
   ============================================================ */

:root {
    --sc-bg-top: #0d1626;
    --sc-bg-bottom: #0a111d;
    --sc-sidebar: #0a0e16;
    --sc-surface: #141d2c;
    --sc-surface-2: #0e1522;        /* inputs, nested wells */
    --sc-surface-hover: #1a2536;
    --sc-border: #233047;
    --sc-border-strong: #2e3d58;
    --sc-text: #e9edf4;
    --sc-muted: #8593a8;
    --sc-accent: #c8202e;           /* DiamondStats crimson */
    --sc-accent-hover: #a91824;
    --sc-accent-glow: rgba(200, 32, 46, .35);
    --sc-accent-dim: #2a1218;       /* active-nav / inning-chip fill */
    --sc-green: #34d17b;
    --sc-blue: #4c9aff;
    --sc-amber: #fbbf24;
    --sc-field: #17452a;
    --sc-field-line: #2e7d4f;
    --sc-radius: .75rem;
    --sc-radius-sm: .5rem;
    --sc-sidebar-w: 232px;
}

html { height: 100%; }
body {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sc-bg-top) 0%, var(--sc-bg-bottom) 100%) fixed;
    color: var(--sc-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
}

/* ---------- Section labels (the family signature) ---------- */
.section-label {
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: .72rem;
    font-weight: 600;
    color: var(--sc-muted);
    margin-bottom: .75rem;
}
.section-label .live-dot {
    display: inline-block;
    width: .55rem; height: .55rem;
    border-radius: 50%;
    background: var(--sc-accent);
    margin-right: .45rem;
    box-shadow: 0 0 8px var(--sc-accent-glow);
    animation: sc-pulse 1.8s infinite;
}
@keyframes sc-pulse { 0%,100% {opacity:1;} 50% {opacity:.35;} }
@media (prefers-reduced-motion: reduce) {
    .section-label .live-dot { animation: none; }
}

/* ---------- App shell: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--sc-sidebar-w);
    min-width: var(--sc-sidebar-w);
    background: var(--sc-sidebar);
    border-right: 1px solid var(--sc-border);
    display: flex;
    flex-direction: column;
}
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.sidebar-brand {
    display: block;
    background: linear-gradient(160deg, var(--sc-accent) 0%, #7d1119 100%);
    color: #fff;
    text-decoration: none;
    padding: 1.6rem 1.25rem;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: .01em;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand .brand-sub {
    display: block;
    font-weight: 600;
    font-size: .68rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    opacity: .85;
    margin-top: .15rem;
}
.sidebar-nav { padding: 1rem .75rem 1.5rem; flex: 1; }
.sidebar-nav .section-label { padding: 0 .55rem; margin: 1.1rem 0 .4rem; }
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--sc-text);
    font-weight: 500;
    padding: .55rem .8rem;
    border-radius: var(--sc-radius-sm);
    border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { color: var(--sc-muted); width: 1.1rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sc-surface-hover); }
.sidebar-nav .nav-link.active {
    background: var(--sc-accent-dim);
    border-left-color: var(--sc-accent);
    color: #ff6b76;
}
.sidebar-nav .nav-link.active i { color: #ff6b76; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .75rem;
    padding: .9rem 1.5rem;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: .65rem;
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius-sm);
    padding: .4rem .8rem .4rem .45rem;
}
.user-chip .avatar {
    width: 2.1rem; height: 2.1rem;
    border-radius: .45rem;
    background: var(--sc-accent-dim);
    color: #ff6b76;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}
.user-chip .u-name { font-weight: 600; font-size: .85rem; line-height: 1.15; }
.user-chip .u-role { color: var(--sc-muted); font-size: .7rem; text-transform: capitalize; }

/* ---------- Cards / surfaces ---------- */
.card {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    color: var(--sc-text);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--sc-border);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .72rem;
    color: var(--sc-muted);
}
.list-group-item {
    background: transparent;
    border-color: var(--sc-border);
    color: var(--sc-text);
}
.list-group-item-action:hover { background: var(--sc-surface-hover); color: var(--sc-text); }

/* ---------- Stat tiles ---------- */
.stat-tile {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
    padding: 1.35rem 1.25rem;
    text-align: center;
}
.stat-tile .stat-value { font-size: 2.3rem; font-weight: 800; line-height: 1.1; color: var(--sc-text); }
.stat-tile .stat-label {
    color: var(--sc-muted);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .14em;
    margin-top: .25rem;
}
/* Colored numerals, DiamondStats-style: green / blue / amber / red rotation */
.row > div:nth-child(4n+1) .stat-tile .stat-value { color: var(--sc-green); }
.row > div:nth-child(4n+2) .stat-tile .stat-value { color: var(--sc-blue); }
.row > div:nth-child(4n+3) .stat-tile .stat-value { color: var(--sc-amber); }
.row > div:nth-child(4n+4) .stat-tile .stat-value { color: #ff5560; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--sc-radius-sm); font-weight: 600; }
.btn-accent, .btn-primary {
    background: var(--sc-accent);
    border-color: var(--sc-accent);
    color: #fff;
}
.btn-accent:hover, .btn-accent:focus, .btn-primary:hover, .btn-primary:focus {
    background: var(--sc-accent-hover);
    border-color: var(--sc-accent-hover);
    color: #fff;
}
.btn-secondary, .btn-outline-primary, .btn-outline-secondary, .btn-outline-dark, .btn-light, .btn-dark {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border-strong);
    color: var(--sc-text);
}
.btn-secondary:hover, .btn-outline-primary:hover, .btn-outline-secondary:hover,
.btn-outline-dark:hover, .btn-light:hover, .btn-dark:hover {
    background: var(--sc-surface-hover);
    border-color: var(--sc-border-strong);
    color: #fff;
}
.btn-outline-success { color: var(--sc-green); border-color: var(--sc-green); }
.btn-outline-success:hover { background: rgba(52,209,123,.12); color: var(--sc-green); }
.btn-outline-danger { color: #ff5560; border-color: #ff5560; }
.btn-outline-danger:hover { background: rgba(255,85,96,.12); color: #ff5560; }
.btn-link { color: #ff6b76; }
.btn-link:hover { color: #ff8a93; }
a { color: #ff6b76; }
a:hover { color: #ff8a93; }
.sidebar-nav a, .btn, .nav-link, .navbar-brand { text-decoration: none; }

/* Selected state used by pickers (jersey buttons) */
.jersey-btn.btn-dark, .btn-check:checked + .btn {
    background: var(--sc-accent);
    border-color: var(--sc-accent);
    color: #fff;
}
.jersey-btn.border-3 { border-color: var(--sc-amber) !important; }

/* ---------- Forms ---------- */
.form-label { color: var(--sc-muted); }
label.form-label, .form-check-label { font-size: .85rem; }
.form-label.small, .form-label {
    text-transform: uppercase;
    letter-spacing: .1em;
    font-size: .7rem;
    font-weight: 600;
}
.form-control, .form-select {
    background: var(--sc-surface-2);
    border: 1px solid var(--sc-border);
    color: var(--sc-text);
    border-radius: var(--sc-radius-sm);
}
.form-control:focus, .form-select:focus {
    background: var(--sc-surface-2);
    border-color: var(--sc-accent);
    color: var(--sc-text);
    box-shadow: 0 0 0 .2rem var(--sc-accent-glow);
}
.form-control::placeholder { color: #5a6578; }
.form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238593a8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
.form-check-input { background-color: var(--sc-surface-2); border-color: var(--sc-border-strong); }
.form-check-input:checked { background-color: var(--sc-accent); border-color: var(--sc-accent); }
.form-text { color: var(--sc-muted); }
.input-group-text { background: var(--sc-surface-hover); border-color: var(--sc-border); color: var(--sc-muted); }

/* ---------- Tables ---------- */
.table { color: var(--sc-text); --bs-table-bg: transparent; --bs-table-color: var(--sc-text); }
.table > :not(caption) > * > * { border-bottom-color: var(--sc-border); }
table.table thead th {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .12em;
    color: var(--sc-muted);
    border-bottom: 1px solid var(--sc-border-strong);
}
.table-hover > tbody > tr:hover > * { background: var(--sc-surface-hover); color: var(--sc-text); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(255,255,255,.02); color: var(--sc-text); }
.table-light, .table-light > th, .table-light > td { background: var(--sc-surface-hover) !important; color: var(--sc-text) !important; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .02em; }
.role-badge { text-transform: capitalize; font-weight: 500; }
.role-badge.role-super_admin { background: var(--sc-accent); color: #fff; }
.role-badge.role-school_admin { background: var(--sc-blue); color: #06101f; }
.role-badge.role-stat_keeper { background: var(--sc-green); color: #06180d; }
.badge-status-scheduled { background: var(--sc-surface-hover); color: var(--sc-muted); border: 1px solid var(--sc-border-strong); }
.badge-status-in_progress { background: var(--sc-accent); }
.badge-status-final { background: var(--sc-green); color: #06180d; }
.badge-status-postponed, .badge-status-cancelled { background: #414d63; }

/* ---------- Alerts / flash ---------- */
.alert { border-radius: var(--sc-radius); border: 1px solid var(--sc-border); }
.alert-success { background: rgba(52,209,123,.1); border-color: rgba(52,209,123,.4); color: #7fe7ae; }
.alert-danger { background: rgba(255,85,96,.1); border-color: rgba(255,85,96,.4); color: #ff9aa1; }
.alert-warning { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.35); color: #fcd77c; }
.alert-info { background: rgba(76,154,255,.08); border-color: rgba(76,154,255,.35); color: #9ec6ff; }

/* ---------- Dropdowns / modals / misc bootstrap ---------- */
.dropdown-menu { background: var(--sc-surface); border: 1px solid var(--sc-border-strong); }
.dropdown-item { color: var(--sc-text); }
.dropdown-item:hover { background: var(--sc-surface-hover); color: #fff; }
.modal-content { background: var(--sc-surface); border: 1px solid var(--sc-border-strong); color: var(--sc-text); }
.text-muted { color: var(--sc-muted) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--sc-border) !important; }
hr { border-color: var(--sc-border-strong); opacity: 1; }
.offcanvas { background: var(--sc-sidebar); color: var(--sc-text); }

/* ---------- Auth (login) ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--sc-bg-top) 0%, var(--sc-bg-bottom) 100%);
    padding: 1rem;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: 1rem;
    box-shadow: 0 24px 60px rgba(0,0,0,.5);
    overflow: hidden;
    padding: 0;
}
.auth-brand-panel {
    background: #fff;
    text-align: center;
    padding: 3rem 2rem;
    border-bottom: 3px solid var(--sc-accent);
}
.auth-brand-panel .brand-mark {
    font-weight: 800;
    font-size: 1.6rem;
    color: var(--sc-accent);
    letter-spacing: .01em;
}
.auth-brand-panel .brand-sub {
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .2em;
    font-size: .68rem;
    font-weight: 700;
    margin-top: .2rem;
}
.auth-body { padding: 2rem 2.25rem 2.5rem; }
.auth-body h1 { font-size: 1.6rem; font-weight: 800; }

/* ---------- Scoring console ---------- */
.console-scoreboard {
    background: var(--sc-surface);
    border: 1px solid var(--sc-border);
    border-radius: var(--sc-radius);
}
.console-scoreboard .team-code {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .78rem;
    color: var(--sc-muted);
    font-weight: 700;
}
.console-scoreboard .fs-2 { font-weight: 800; }
.quarter-chip {
    display: inline-block;
    background: var(--sc-accent-dim);
    border: 1px solid var(--sc-accent);
    border-radius: var(--sc-radius-sm);
    color: #ff6b76;
    font-weight: 700;
    padding: .2rem .8rem;
}
#commandBar .btn {
    background: var(--sc-surface);
    border: 1.5px solid var(--sc-border-strong);
    color: var(--sc-text);
    font-weight: 700;
}
#commandBar .btn:hover { background: var(--sc-surface-hover); }
#commandBar .btn[data-cmd="rush"], #commandBar .btn[data-cmd="pass"] { border-color: var(--sc-blue); }
#commandBar .btn[data-cmd="penalty"] { border-color: var(--sc-amber); }
#commandBar .btn[data-cmd="gamectrl"] { border-color: var(--sc-accent); }
#playLogPanel .card-header { letter-spacing: .14em; }
.play-log-item {
    border-bottom: 1px solid var(--sc-border);
    padding: .55rem .25rem;
    font-size: .88rem;
}
.play-log-item .badge { font-size: .68rem; }
.pbp-scoring { color: var(--sc-green); font-weight: 600; }

/* Field visuals (scoreboard strip + tappable spot bars): dark turf */
#fieldStrip, .spot-bar {
    background: linear-gradient(90deg, var(--sc-field) 0%, #1d5a36 50%, var(--sc-field) 100%) !important;
    border: 1px solid var(--sc-field-line) !important;
}
#fieldStrip span, .spot-bar span { color: #cfe9d9; }
#fieldMidline, .spot-bar .position-absolute[style*="background:#66bb6a"] { background: var(--sc-field-line) !important; }

/* ---------- Touch / responsive ---------- */
.touch-target { min-width: 48px; min-height: 48px; }
@media (max-width: 575.98px) {
    .btn { padding-top: .55rem; padding-bottom: .55rem; }
    h1, .h1 { font-size: 1.5rem; }
    .app-topbar { padding: .75rem 1rem; }
}
