/* Scorebook Layout — Paper scorebook-style inline action buttons */

/* Team panel container */
.scorebook-team-panel {
    background: #1a1a2e;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

/* Team header */
.scorebook-team-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #16213e;
    border-bottom: 2px solid #0f3460;
}

.scorebook-team-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e0e0e0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scorebook-team-score {
    font-size: 1.6rem;
    font-weight: 900;
    color: #fbbf24;
    min-width: 48px;
    text-align: center;
}

/* Player roster container */
.scorebook-roster {
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Individual player row */
.scorebook-row {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    border-bottom: 1px solid #222;
    gap: 4px;
    min-height: 40px;
    transition: background-color 0.15s;
}

.scorebook-row:last-child {
    border-bottom: none;
}

.scorebook-row.in-game {
    background: rgba(76, 175, 80, 0.22);
    border-left: 3px solid #66bb6a;
}

.scorebook-row:not(.in-game) {
    border-left: 3px solid transparent;
    opacity: 0.75;
}

.scorebook-team-row {
    background: rgba(255, 255, 255, 0.03);
    border-top: 2px solid #333;
    border-left: 3px solid #666 !important;
    opacity: 1 !important;
}

/* Too many on court warning */
.scorebook-overcourt-warning {
    padding: 8px 14px;
    background: rgba(255, 152, 0, 0.25);
    border: 2px solid #ff9800;
    border-radius: 4px;
    color: #ffcc80;
    font-size: 0.95rem;
    font-weight: 800;
    text-align: center;
    margin: 4px 6px;
    animation: overcourt-pulse 1s ease-in-out infinite;
}

@keyframes overcourt-pulse {
    0%, 100% {
        background: rgba(255, 152, 0, 0.25);
        border-color: #ff9800;
        transform: scale(1);
    }
    50% {
        background: rgba(255, 152, 0, 0.45);
        border-color: #ffab40;
        transform: scale(1.02);
    }
}

/* In-game rows pulse when overcourt in sub mode */
.scorebook-row.in-game.overcourt-pulse {
    animation: overcourt-row-pulse 1s ease-in-out infinite;
}

@keyframes overcourt-row-pulse {
    0%, 100% {
        background: rgba(76, 175, 80, 0.22);
        border-left-color: #66bb6a;
    }
    50% {
        background: rgba(255, 152, 0, 0.25);
        border-left-color: #ff9800;
    }
}

/* Sub mode — highlight rows as tappable */
.scorebook-row.sub-mode {
    border: 1px dashed #ff9800;
    opacity: 1 !important;
}

.scorebook-row.sub-mode:active {
    background: rgba(255, 152, 0, 0.15);
}

.scorebook-row.sub-mode.in-game {
    border: 1px solid #4caf50;
}

.scorebook-row.sub-mode:not(.in-game) {
    border: 1px dashed #ff9800;
}

/* Player identity (center) — fixed-width columns for vertical alignment */
.scorebook-player-info {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 80px;
    flex-shrink: 0;
    padding: 0 4px;
}

.scorebook-jersey {
    font-size: 1.05rem;
    font-weight: 900;
    color: #90caf9;
    white-space: nowrap;
    width: 40px;
    text-align: right;
    margin-right: 8px;
}

.scorebook-name {
    font-size: 0.9rem;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 80px;
    margin-right: 8px;
}

.scorebook-pts {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fbbf24;
    width: 48px;
    text-align: left;
    margin-right: 6px;
}

.scorebook-fouls {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffcc80;
    white-space: nowrap;
    width: 52px;
    text-align: left;
}

.scorebook-mins {
    font-size: 0.8rem;
    font-weight: 600;
    color: #999;
    white-space: nowrap;
    width: 40px;
    text-align: left;
}

.scorebook-fouls.fouled-out-text {
    color: #ff1744;
    font-weight: 900;
    animation: foul-text-pulse 1s ease-in-out 60;
}

/* Fouled-out row — red highlight with 60s pulse then solid */
.scorebook-row.fouled-out {
    background: rgba(255, 23, 68, 0.15) !important;
    border-left: 3px solid #ff1744 !important;
    animation: foul-row-pulse 1.2s ease-in-out 50;
}

.scorebook-row.fouled-out .scorebook-name {
    color: #ef9a9a;
}

@keyframes foul-text-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes foul-row-pulse {
    0%, 100% {
        background: rgba(255, 23, 68, 0.15);
        border-left-color: #ff1744;
    }
    50% {
        background: rgba(255, 23, 68, 0.35);
        border-left-color: #ff5252;
    }
}

/* Button containers */
.scorebook-buttons-left,
.scorebook-buttons-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.scorebook-buttons-left {
    /* High-frequency buttons get slightly more room */
}

.scorebook-buttons-right {
    margin-left: auto;
}

/* Base button style */
.sb-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 2px 5px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2a2a3e;
    color: #e0e0e0;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.08s, background-color 0.08s;
    line-height: 1;
}

.sb-btn:active {
    transform: scale(0.92);
}

.sb-btn.sb-sm {
    min-width: 30px;
    min-height: 34px;
    padding: 2px 3px;
    font-size: 0.65rem;
}

/* Button color variants */
.sb-btn.sb-made {
    background: #1b5e20;
    border-color: #2e7d32;
    color: #a5d6a7;
}

.sb-btn.sb-made:active {
    background: #2e7d32;
}

.sb-btn.sb-miss {
    background: #4a1515;
    border-color: #c62828;
    color: #ef9a9a;
}

.sb-btn.sb-miss:active {
    background: #7f1d1d;
}

.sb-btn.sb-warn {
    background: #4a3000;
    border-color: #e65100;
    color: #ffcc80;
}

.sb-btn.sb-warn:active {
    background: #6d4c00;
}

.sb-btn.sb-stat {
    background: #1a237e;
    border-color: #3949ab;
    color: #9fa8da;
}

.sb-btn.sb-stat:active {
    background: #283593;
}

.sb-btn.sb-info {
    background: #01579b;
    border-color: #0277bd;
    color: #81d4fa;
}

.sb-btn.sb-info:active {
    background: #0277bd;
}

/* Stat counter badge */
.sb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 7px;
    background: #fbbf24;
    color: #000;
    font-size: 0.55rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.sb-badge-warn {
    background: #ff5722;
    color: #fff;
}

/* Last action banner */
.last-action-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    margin-bottom: 8px;
    background: #1a2a1a;
    border: 1px solid #2e7d32;
    border-radius: 6px;
    gap: 8px;
}

.last-action-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #e0e0e0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.last-action-check {
    color: #4caf50;
    font-weight: bold;
    font-size: 1rem;
}

.last-action-context {
    color: #888;
    font-size: 0.75rem;
}

.last-action-undo {
    flex-shrink: 0;
    min-width: 60px;
    min-height: 36px;
    padding: 4px 12px;
    border: 2px solid #ef5350;
    border-radius: 4px;
    background: #4a1515;
    color: #ef9a9a;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.08s, background-color 0.08s;
    letter-spacing: 0.5px;
}

.last-action-undo:active {
    transform: scale(0.92);
    background: #7f1d1d;
}

/* Responsive: on small screens, stack teams vertically */
@media (max-width: 959px) {
    .scorebook-roster {
        max-height: 50vh;
    }
}

/* Zoom wrapper — scales entire scorebook area */
.scorebook-zoom-wrapper {
    transform-origin: top center;
    transition: transform 0.15s ease;
}

/* One-shot pulse around the game clock when the clock toggles between
   running and stopped. Gives the scorer visual confirmation that their
   Start/Stop click — or the HID button press they can't always see fire —
   actually registered. The wrapper is inline-block so the box-shadow
   ripples around the actual text bounds instead of the parent column. */
.clock-pulse-wrapper {
    display: inline-block;
    border-radius: 14px;
    padding: 2px 12px;
}
.clock-pulse-wrapper.clock-pulse-active {
    animation: clock-pulse 0.7s ease-out;
}
@keyframes clock-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(255, 109, 0, 0.85); background-color: rgba(255, 109, 0, 0.18); }
    60%  { box-shadow: 0 0 0 24px rgba(255, 109, 0, 0);    background-color: rgba(255, 109, 0, 0.05); }
    100% { box-shadow: 0 0 0 0   rgba(255, 109, 0, 0);    background-color: transparent; }
}

/* Sticky score header — keeps the blue score/clock/period bar pinned at the
   top of the viewport while the scorer scrolls through long bench lists or
   the play-by-play feed. Sits just below the MudAppBar (which is 64px tall
   and fixed-position). z-index must exceed any subsequent MudPaper but stay
   below MudDialog/MudPopover so dialogs still render correctly above it. */
.sticky-score-header {
    position: sticky;
    top: 64px;
    z-index: 50;
    /* The ScoreHeader's own MudPaper carries the #1e3a5f background, but
       give the wrapper an opaque backdrop too so anything bleeding through
       a transparent ScoreHeader edge (e.g. mb-3 margin) stays masked. */
    background-color: #121212;
}

/* Condensed one-row variant — visible only when the page is scrolled
   (JS adds .condensed to .sticky-score-header). Replaces the full
   ScoreHeader card with a thin bar so the scorer still sees score,
   period, and clock without giving up half the viewport. */
.sticky-score-header .sticky-condensed { display: none; }
.sticky-score-header.condensed .sticky-full { display: none; }
.sticky-score-header.condensed .sticky-condensed {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e3a5f;
    padding: 6px 14px;
    margin-bottom: 12px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    gap: 12px;
}
.sticky-condensed .sc-team {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.sticky-condensed .sc-away { justify-content: flex-end; }
.sticky-condensed .sc-label {
    color: #666;
    font-size: 0.65rem;
    letter-spacing: 2px;
    font-weight: 600;
}
.sticky-condensed .sc-name {
    color: #b0b0b0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.sticky-condensed .sc-score {
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    min-width: 38px;
    text-align: center;
}
.sticky-condensed .sc-center {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sticky-condensed .sc-period {
    color: #ea580c;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    white-space: nowrap;
}
.sticky-condensed .sc-clock {
    color: #ffffff;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* On phone-sized viewports drop the team names so the score + clock
   never get squeezed off-screen. */
@media (max-width: 600px) {
    .sticky-condensed .sc-name { display: none; }
    .sticky-condensed .sc-label { display: none; }
}

/* Zoom control bar */
.scorebook-zoom-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
}

.zoom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    border: 1px solid #444;
    border-radius: 4px;
    background: #2a2a3e;
    color: #e0e0e0;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background-color 0.1s;
}

.zoom-btn:active {
    background: #3a3a5e;
}

.zoom-label {
    font-size: 0.8rem;
    color: #888;
    min-width: 40px;
    text-align: center;
    font-weight: 600;
}

/* Ensure touch targets on very small screens with horizontal scroll */
@media (max-width: 600px) {
    .scorebook-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .scorebook-row::-webkit-scrollbar {
        display: none;
    }

    .scorebook-name {
        max-width: 50px;
    }

    .sb-btn {
        min-width: 32px;
        min-height: 34px;
    }

    .sb-btn.sb-sm {
        min-width: 28px;
        min-height: 32px;
    }
}

/* ========== BOX SCORE ========== */

.box-score {
    background: #111827;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

/* Period filter tabs */
.box-period-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.box-period-tab {
    background: #1f2937;
    color: #9ca3af;
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.box-period-tab:hover {
    background: #374151;
    color: #e5e7eb;
}

.box-period-tab.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.box-period-tab.current:not(.active) {
    border-color: #f59e0b;
    color: #f59e0b;
}

/* Quarter-by-quarter table */
.box-score-quarters {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.box-score-quarters th,
.box-score-quarters td {
    padding: 6px 10px;
    text-align: center;
    border: 1px solid #333;
    color: #e0e0e0;
}

.box-score-quarters thead th {
    background: #1e3a5f;
    color: #90caf9;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.box-score-quarters tbody td {
    background: #1a1a2e;
    font-weight: 600;
    font-size: 0.95rem;
}

.box-team-col {
    text-align: left !important;
    font-weight: 700 !important;
    min-width: 100px;
    color: #fff !important;
}

.box-total-col {
    background: #1e3a5f !important;
    color: #fbbf24 !important;
    font-weight: 900 !important;
    font-size: 1rem !important;
}

.box-current-period {
    background: rgba(76, 175, 80, 0.2) !important;
    border-color: #4caf50 !important;
}

/* Team label above player table */
.box-score-team-label {
    font-size: 0.9rem;
    font-weight: 800;
    color: #90caf9;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 4px 4px;
    border-bottom: 2px solid #1e3a5f;
    margin-bottom: 0;
}

/* Player stats table */
.box-score-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
}

.box-score-players {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    white-space: nowrap;
}

.box-score-players th,
.box-score-players td {
    padding: 4px 6px;
    text-align: center;
    border-bottom: 1px solid #222;
    color: #ccc;
}

.box-score-players thead th {
    background: #16213e;
    color: #888;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.box-score-players tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.box-player-col {
    text-align: left !important;
}

.box-name-col {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.box-pts {
    color: #fbbf24 !important;
    font-weight: 800;
}

.box-on-court {
    background: rgba(76, 175, 80, 0.1);
}

.box-on-court td:first-child {
    border-left: 2px solid #4caf50;
}

.box-fouled-out {
    color: #ff1744 !important;
    font-weight: 900;
}

.box-totals-row {
    border-top: 2px solid #444;
    background: rgba(255, 255, 255, 0.03);
}

.box-totals-row td {
    font-weight: 700;
    color: #e0e0e0;
}

/* Per-quarter points columns */
.box-quarter-col {
    color: #90caf9 !important;
    font-size: 0.75rem;
    min-width: 28px;
    text-align: center;
    border-left: 1px solid #333;
}

.box-score-players thead th.box-quarter-col {
    background: #162a44;
    color: #64b5f6 !important;
    font-weight: 600;
    font-size: 0.7rem;
}

/* Timeout log table */
.box-score-timeouts {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.box-score-timeouts th,
.box-score-timeouts td {
    padding: 5px 8px;
    border: 1px solid #333;
    color: #e0e0e0;
}

.box-score-timeouts thead th {
    background: #2e2e1a;
    color: #ff9800;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.box-score-timeouts tbody td {
    background: #1a1a2e;
}
