/* ============================================
   Modern Dark Basketball Stats Theme
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme colors */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1c2128;
    --bg-elevated: #21262d;

    /* Accent colors */
    --accent-primary: #58a6ff;
    --accent-secondary: #1f6feb;
    --accent-success: #3fb950;
    --accent-warning: #f0883e;
    --accent-danger: #f85149;
    --accent-purple: #a371f7;

    /* Text colors */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;

    /* Border colors */
    --border-primary: #30363d;
    --border-secondary: #21262d;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(at 0% 0%, rgba(88, 166, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(163, 113, 247, 0.05) 0px, transparent 50%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================
   Typography
   ============================================ */

h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 30px;
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 1.4em;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.3px;
}

h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: var(--accent-danger);
    font-weight: 600;
}

/* ============================================
   Score Section
   ============================================ */

.score-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: var(--transition-smooth);
}

.score-section:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--accent-primary);
}

.team-names {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 600;
}

.team-name {
    color: var(--accent-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.team-name:hover {
    color: var(--accent-purple);
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.5);
}

.vs {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 0.85em;
}

.score-display {
    text-align: center;
    font-size: 4em;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    letter-spacing: -2px;
}

/* ============================================
   Layout
   ============================================ */

.main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}

.section:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.sidebar {
    height: fit-content;
    position: sticky;
    top: 20px;
}

.subtitle {
    font-weight: 600;
    margin: 20px 0 12px 0;
    font-size: 0.9em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Player Status Indicator
   ============================================ */

.on-court-indicator {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 16px;
    transition: var(--transition-fast);
}

.on-court-indicator.full {
    background: rgba(63, 185, 80, 0.1);
    border-color: var(--accent-success);
    color: var(--accent-success);
}

.on-court-indicator.warning {
    background: rgba(240, 136, 62, 0.1);
    border-color: var(--accent-warning);
    color: var(--accent-warning);
}

.on-court-indicator.error {
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--accent-danger);
    color: var(--accent-danger);
}

/* ============================================
   Player Checkboxes
   ============================================ */

.player-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.player-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    transition: var(--transition-fast);
    cursor: pointer;
}

.player-checkbox:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
}

.player-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.player-checkbox label {
    cursor: pointer;
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================
   Actions Table
   ============================================ */

.actions-grid {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 8px;
}

.actions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.actions-table th {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--accent-primary);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.actions-table td {
    padding: 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-primary);
}

.actions-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--text-primary);
}

.actions-table tr:hover {
    background: var(--bg-tertiary);
}

.actions-table tr.player-on-court {
    background: var(--bg-elevated);
}

.actions-table tr.player-on-court:hover {
    background: var(--bg-tertiary);
}

/* ============================================
   Buttons
   ============================================ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.btn-success {
    background: var(--accent-success);
    color: var(--bg-primary);
}

.btn-success:hover {
    background: #2ea043;
    box-shadow: 0 4px 16px rgba(63, 185, 80, 0.4);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #da3633;
    box-shadow: 0 4px 16px rgba(248, 81, 73, 0.4);
}

.btn-warning {
    background: var(--accent-warning);
    color: var(--bg-primary);
}

.btn-warning:hover {
    background: #d26d3d;
    box-shadow: 0 4px 16px rgba(240, 136, 62, 0.4);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8em;
    min-width: 40px;
    font-weight: 600;
}

/* ============================================
   Opponent Controls
   ============================================ */

.opponent-controls {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* ============================================
   Statistics Section
   ============================================ */

.stats-section {
    margin-bottom: 24px;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 14px 10px;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    border-bottom: 2px solid var(--accent-primary);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.stats-table td {
    padding: 12px 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

.stats-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

.stats-table tr:hover {
    background: var(--bg-tertiary);
}

.stats-table tr.player-on-court {
    background: var(--bg-elevated);
}

.stats-table tr.player-on-court:hover {
    background: var(--bg-tertiary);
}

.plus-minus-positive {
    color: var(--accent-success);
    font-weight: 700;
}

.plus-minus-negative {
    color: var(--accent-danger);
    font-weight: 700;
}

.status-on-court {
    color: var(--accent-success);
    font-weight: 600;
}

.status-bench {
    color: var(--text-tertiary);
}

/* ============================================
   Controls
   ============================================ */

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 8px 0;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    overflow: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    margin: 5% auto;
    padding: 32px;
    border-radius: 16px;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
}

.close:hover {
    color: var(--text-primary);
}

#rename-inputs {
    margin: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rename-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.rename-input-group label {
    min-width: 80px;
    font-weight: 500;
    color: var(--text-secondary);
}

.rename-input-group input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 1em;
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.rename-input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

/* ============================================
   Scrollbar (Webkit)
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-primary);
}

/* ============================================
   Responsive Design - Phase 1 Mobile Optimization
   ============================================ */

@media (max-width: 768px) {
    body {
        padding: 12px;
        padding-bottom: 80px; /* Space for fixed bottom navigation */
    }

    .container {
        padding-bottom: 20px;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .sidebar {
        position: static;
        width: 100%;
        order: -1; /* Show sidebar first on mobile */
    }

    /* Typography adjustments */
    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 1.2em;
    }

    /* Score section - more compact */
    .score-section {
        padding: 20px;
        margin-bottom: 16px;
    }

    .team-names {
        font-size: 1.1em;
        flex-wrap: wrap;
    }

    .score-display {
        font-size: 2.8em;
    }

    /* Player checkboxes - larger touch targets */
    .player-checkbox {
        padding: 14px 16px;
        min-height: 50px;
    }

    .player-checkbox input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .player-checkbox label {
        font-size: 1.05em;
    }

    /* Actions table - horizontally scrollable with larger buttons */
    .actions-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 16px;
    }

    .actions-table {
        font-size: 0.8em;
        min-width: 600px; /* Force horizontal scroll for better button spacing */
    }

    .actions-table th {
        padding: 12px 6px;
        font-size: 0.75em;
    }

    .actions-table td {
        padding: 6px 4px;
    }

    /* Action buttons - minimum touch size 50px */
    .btn-sm {
        padding: 8px 10px;
        font-size: 0.85em;
        min-width: 50px;
        min-height: 50px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Regular buttons - larger for touch */
    .btn {
        padding: 14px 24px;
        font-size: 1em;
        min-height: 50px;
    }

    /* Opponent controls - vertical stack on mobile */
    .opponent-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .opponent-controls .btn {
        width: 100%;
    }

    /* Statistics table - horizontally scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .stats-table {
        min-width: 800px; /* Force horizontal scroll */
        font-size: 0.8em;
    }

    .stats-table th,
    .stats-table td {
        padding: 10px 6px;
        white-space: nowrap;
    }

    /* Controls - fixed bottom navigation */
    .controls {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top: 2px solid var(--accent-primary);
        padding: 12px;
        gap: 8px;
        justify-content: space-around;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
        z-index: 100;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .controls .btn {
        flex: 1;
        min-width: 120px;
        padding: 12px 16px;
        font-size: 0.9em;
    }

    /* Section styling for mobile */
    .section {
        padding: 16px;
        margin-bottom: 16px;
    }

    /* Modal adjustments for mobile */
    .modal-content {
        margin: 10% 20px;
        padding: 24px;
        max-width: 100%;
    }

    #rename-inputs {
        gap: 10px;
    }

    .rename-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .rename-input-group label {
        min-width: auto;
        font-size: 0.9em;
    }

    .rename-input-group input {
        padding: 12px;
        font-size: 1em;
    }

    /* Touch feedback enhancement */
    .btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .player-checkbox:active {
        transform: scale(0.98);
    }

    /* Improved tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(88, 166, 255, 0.2);
    }
}

/* ============================================
   Phase 2 Mobile Optimization - Quick Actions Mode
   ============================================ */

/* Quick Actions Toggle Button */
.quick-actions-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    background: var(--accent-purple);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-smooth);
    display: none; /* Hidden on desktop */
}

.quick-actions-toggle:active {
    transform: scale(0.9);
}

.quick-actions-toggle.active {
    background: var(--accent-success);
}

/* Quick Actions Overlay */
.quick-actions-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 150;
    overflow-y: auto;
    padding: 20px;
    padding-top: 100px;
}

.quick-actions-overlay.active {
    display: block;
}

.quick-actions-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-bottom: 2px solid var(--accent-purple);
    z-index: 151;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quick-actions-score {
    font-size: 2em;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Quick Actions Player Cards */
.quick-actions-players {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 100px;
}

.quick-player-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 12px;
    padding: 16px;
    transition: var(--transition-fast);
}

.quick-player-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.quick-player-name {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-player-stats {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.quick-action-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.quick-action-btn {
    padding: 16px 8px;
    font-size: 0.85em;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.quick-action-btn:active {
    transform: scale(0.92);
}

.quick-action-btn.success {
    background: var(--accent-success);
    color: white;
}

.quick-action-btn.miss {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.quick-action-btn.stat {
    background: var(--accent-primary);
    color: white;
}

.quick-action-label {
    font-size: 0.75em;
    opacity: 0.9;
}

/* Quick Actions Bottom Controls */
.quick-actions-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent-danger);
    padding: 12px;
    display: flex;
    gap: 8px;
    z-index: 151;
}

.quick-actions-controls .btn {
    flex: 1;
    min-height: 55px;
}

@media (max-width: 768px) {
    .quick-actions-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Smooth scrolling for mobile */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Pull to refresh indicator space */
    body {
        overscroll-behavior-y: contain;
    }

    /* Sticky table headers for stats */
    .stats-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    /* Better scroll indicators */
    .actions-grid::after,
    .table-container::after {
        content: '→';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        background: linear-gradient(to left, var(--bg-secondary) 0%, transparent 100%);
        padding: 10px 15px;
        font-size: 1.5em;
        color: var(--accent-primary);
        pointer-events: none;
        opacity: 0.7;
    }

    /* Hide scroll indicator when at end */
    .actions-grid.scrolled-end::after,
    .table-container.scrolled-end::after {
        opacity: 0;
    }

    /* Improved section transitions */
    .section {
        transition: all var(--transition-smooth);
    }

    /* Collapse sections for more focus */
    .section.collapsed {
        max-height: 60px;
        overflow: hidden;
        cursor: pointer;
    }

    .section.collapsed h2::after {
        content: ' ▼';
        font-size: 0.7em;
        color: var(--text-tertiary);
    }

    .section:not(.collapsed) h2::after {
        content: ' ▲';
        font-size: 0.7em;
        color: var(--text-tertiary);
    }

    /* Swipe gesture feedback */
    .swipe-indicator {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0, 0, 0, 0.9);
        color: white;
        padding: 20px 30px;
        border-radius: 12px;
        font-size: 1.2em;
        font-weight: 700;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
        z-index: 1000;
    }

    .swipe-indicator.show {
        opacity: 1;
    }

    /* Haptic feedback simulation */
    @keyframes haptic-pulse {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.05); }
    }

    .btn.haptic {
        animation: haptic-pulse 0.15s ease;
    }

    /* Floating action button style for quick access */
    .floating-quick-btn {
        position: fixed;
        bottom: 90px;
        right: 20px;
        width: 65px;
        height: 65px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-primary) 100%);
        color: white;
        border: none;
        font-size: 1.8em;
        cursor: pointer;
        box-shadow: var(--shadow-lg), 0 0 30px rgba(163, 113, 247, 0.5);
        z-index: 99;
        transition: all var(--transition-smooth);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .floating-quick-btn:active {
        transform: scale(0.85);
    }

    .floating-quick-btn.active {
        background: linear-gradient(135deg, var(--accent-success) 0%, var(--accent-primary) 100%);
        box-shadow: var(--shadow-lg), 0 0 30px rgba(63, 185, 80, 0.5);
    }
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   Utilities
   ============================================ */

.text-glow {
    text-shadow: 0 0 10px currentColor;
}

.card-glow {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}
