/* NHL Stats Visualizer - Custom Styles */

/* ============================================================================
   Color-Coding System for Stats
   ============================================================================ */

/* Red: 0 goals/points - Cold/Avoid */
.stat-0 {
    background-color: #ffcdd2 !important;
    color: #c62828 !important;
    font-weight: 600;
    text-align: center;
}

/* Green: 1 goal/point - Solid */
.stat-1 {
    background-color: #c8e6c9 !important;
    color: #2e7d32 !important;
    font-weight: 600;
    text-align: center;
}

/* Blue: 2+ goals/points - Hot */
.stat-2plus {
    background-color: #bbdefb !important;
    color: #1565c0 !important;
    font-weight: 700;
    text-align: center;
}

/* Gray: Didn't play */
.stat-empty {
    background-color: #f5f5f5 !important;
    color: #9e9e9e !important;
    font-style: italic;
    text-align: center;
}

/* ============================================================================
   Stats Table Styling
   ============================================================================ */

/* Stat cells with hover effects */
.stat-cell {
    padding: 12px 8px;
    min-width: 60px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    position: relative;
}

.stat-cell:not(.stat-empty):hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.stat-empty {
    cursor: default;
}

/* Sticky player name column */
.player-name-cell {
    position: sticky;
    left: 0;
    background-color: #ffffff;
    z-index: 5;
    font-weight: 600;
    border-right: 2px solid #dee2e6;
    min-width: 180px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 12px 16px;
}

/* Sticky header row */
.stats-table thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 6;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.85rem;
    padding: 12px 8px;
    vertical-align: middle;
}

/* Header for player name column (needs higher z-index) */
.stats-table thead th.player-name-header {
    z-index: 7;
    left: 0;
    background-color: #e9ecef;
    border-right: 2px solid #dee2e6;
}

/* Game header columns */
.game-header {
    min-width: 60px;
    text-align: center;
    font-size: 0.75rem;
}

.game-date {
    display: block;
    font-weight: 600;
    color: #495057;
}

.game-opponent {
    display: block;
    font-size: 0.7rem;
    color: #6c757d;
}

.game-result {
    display: inline-block;
    font-weight: 600;
    margin-top: 2px;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
}

.game-result.win {
    background-color: #d4edda;
    color: #155724;
}

.game-result.loss {
    background-color: #f8d7da;
    color: #721c24;
}

/* Table responsive container */
.table-responsive {
    max-height: 600px;
    overflow-x: auto;
    overflow-y: auto;
}

/* Custom scrollbar styling */
.table-responsive::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Stats tables */
.stats-table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.stats-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ============================================================================
   Tooltip Styling
   ============================================================================ */

.stat-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
}

.stat-tooltip.show {
    display: block;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

/* Tablet and below */
@media (max-width: 992px) {
    .player-name-cell {
        min-width: 150px;
        max-width: 150px;
        font-size: 0.85rem;
    }
    
    .stat-cell {
        min-width: 50px;
        padding: 10px 6px;
        font-size: 0.85rem;
    }
    
    .game-header {
        min-width: 50px;
        font-size: 0.7rem;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .player-name-cell {
        min-width: 120px;
        max-width: 120px;
        font-size: 0.8rem;
        padding: 10px 12px;
    }
    
    .stat-cell {
        min-width: 45px;
        padding: 8px 4px;
        font-size: 0.8rem;
    }
    
    .game-header {
        min-width: 45px;
        font-size: 0.65rem;
    }
    
    .game-opponent {
        font-size: 0.65rem;
    }
    
    /* Reduce table max height on mobile */
    .table-responsive {
        max-height: 400px;
    }
}

/* ============================================================================
   Navigation and Layout
   ============================================================================ */

/* Navbar customization */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: #00bfff !important;
}

.navbar-nav .nav-link.active {
    color: #00bfff !important;
    border-bottom: 2px solid #00bfff;
}

/* Main content padding */
main.container-fluid {
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================================================
   Controls Bar Styling
   ============================================================================ */

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
}

.form-select {
    font-size: 0.95rem;
}

.nav-pills .nav-link {
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.nav-pills .nav-link.active {
    background-color: #0d6efd;
}

/* ============================================================================
   Empty State and Loading Indicators
   ============================================================================ */

#emptyState i {
    opacity: 0.4;
}

#loadingSpinner {
    padding: 60px 0;
}

/* ============================================================================
   Animation Classes
   ============================================================================ */

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

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
    .navbar,
    .card-header,
    footer,
    #teamSelect,
    #gameCountSelect,
    #playerTypeTabs {
        display: none;
    }
    
    .stat-cell:not(.stat-empty):hover {
        transform: none;
        box-shadow: none;
    }
    
    .table-responsive {
        overflow: visible;
        max-height: none;
    }
}

/* ============================================================================
   Team Matchup Comparison Styles
   ============================================================================ */

/* Matchup container - side-by-side layout */
.matchup-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Individual team panel */
.matchup-team {
    min-height: 500px;
}

/* Section titles in matchup panels */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.5rem;
}

/* Game results badges */
.game-results {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.game-results .badge {
    font-size: 0.85rem;
    padding: 4px 8px;
    cursor: help;
}

/* Compact table for emoji display */
.compact-table {
    margin-bottom: 1rem;
}

/* Player row styling */
.player-row {
    border-bottom: 1px solid #e9ecef;
    padding: 8px 0;
    transition: background-color 0.2s ease;
}

.player-row:hover {
    background-color: #f8f9fa;
}

.player-row-collapsed {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Player name - clickable to expand */
.player-name {
    min-width: 180px;
    font-weight: 600;
    cursor: pointer;
    color: #0d6efd;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-name:hover {
    color: #0a58ca;
    text-decoration: underline;
}

.expand-icon {
    font-size: 0.9rem;
    color: #6c757d;
}

/* Player total stat display */
.player-total {
    font-weight: 700;
    color: #495057;
    min-width: 30px;
    text-align: center;
    background-color: #e9ecef;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Player emoji cells container */
.player-emojis {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* Compact emoji cells */
.emoji-cell {
    font-size: 16px;
    padding: 4px;
    min-width: 24px;
    display: inline-block;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s ease;
    border-radius: 4px;
}

.emoji-cell:hover {
    transform: scale(1.2);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Expandable details section */
.expandable-details {
    display: none;
    padding: 12px 0 12px 40px;
    background-color: #f8f9fa;
    border-left: 3px solid #0d6efd;
    margin-top: 8px;
    border-radius: 4px;
}

.player-row-expanded .expandable-details {
    display: block;
    animation: slideDown 0.3s ease-out;
}

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

/* Detail list for game-by-game breakdown */
.detail-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    font-size: 0.85rem;
}

.detail-date {
    font-weight: 600;
    color: #495057;
    min-width: 70px;
}

.detail-opponent {
    color: #6c757d;
    min-width: 80px;
}

.detail-stats {
    color: #0d6efd;
    font-weight: 600;
}

/* Mobile responsive - stack panels vertically */
@media (max-width: 768px) {
    .matchup-container {
        grid-template-columns: 1fr;
    }
    
    .player-name {
        min-width: 140px;
        font-size: 0.9rem;
    }
    
    .emoji-cell {
        font-size: 14px;
        padding: 3px;
        min-width: 22px;
    }
    
    .expandable-details {
        padding-left: 20px;
    }
    
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-date,
    .detail-opponent,
    .detail-stats {
        min-width: auto;
    }
}

/* Extra small mobile */
@media (max-width: 576px) {
    .player-row-collapsed {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .player-name {
        min-width: auto;
    }
    
    .player-emojis {
        width: 100%;
    }
}

/* ============================================================================
   Game Detail Modal Styles
   ============================================================================ */

/* Modal Backdrop - dark overlay behind modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    cursor: pointer;
}

.modal-backdrop.modal-visible {
    display: block;
}

/* Modal Container - centered white box */
.modal-container {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    overflow: hidden;
}

.modal-container.modal-visible {
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.3s ease-out;
}

/* Modal fade in animation */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #343a40;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    color: #000;
}

/* Modal Body */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Game Info Header in Modal */
.game-info-header h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #212529;
}

.game-info-header p {
    margin-bottom: 0.5rem;
}

/* Team Section in Modal */
.team-section {
    margin-bottom: 30px;
}

.team-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #343a40;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

/* Player Stats Table in Modal */
.player-stats-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.player-stats-table th {
    background: #f8f9fa;
    padding: 10px 6px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #dee2e6;
    color: #495057;
    font-size: 0.85rem;
}

.player-stats-table th.text-start {
    text-align: left;
}

.player-stats-table td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid #e9ecef;
}

.player-stats-table td.player-name {
    text-align: left;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-stats-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.player-stats-table tbody tr:hover {
    background: #e9ecef;
}

/* Loading Spinner in Modal */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* Responsive Modal Styles */
@media (max-width: 768px) {
    .modal-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .modal-container.modal-visible {
        animation: none;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .game-info-header h3 {
        font-size: 1.4rem;
    }
    
    .team-name {
        font-size: 1.15rem;
    }
    
    .player-stats-table {
        font-size: 11px;
    }
    
    .player-stats-table th,
    .player-stats-table td {
        padding: 6px 3px;
    }
    
    .player-stats-table td.player-name {
        max-width: 120px;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .player-stats-table {
        font-size: 10px;
    }
    
    .player-stats-table th,
    .player-stats-table td {
        padding: 5px 2px;
    }
    
    .team-name {
        font-size: 1rem;
    }
}

/* ============================================================================
   Team Analyzer Card Header Colors (Match stat color scheme)
   ============================================================================ */

/* Goals card header - uses red tones to match stat-0 */
.card-header.goals-header {
    background: linear-gradient(135deg, #e57373 0%, #f44336 100%) !important;
    border-bottom: 3px solid #c62828;
}

/* Points card header - uses green/blue blend to match stat progression */
.card-header.points-header {
    background: linear-gradient(135deg, #66bb6a 0%, #42a5f5 100%) !important;
    border-bottom: 3px solid #1565c0;
}


/* ============================================================================
   Probable Scorers Page Styles (Story 1.16)
   ============================================================================ */

/* Confidence Score Color Scale */
.stat-confidence-low {
    background-color: #e8f5e9 !important; /* Very light green */
    color: #388e3c !important;
}

.stat-confidence-medium {
    background-color: #a5d6a7 !important; /* Light green */
    color: #2e7d32 !important;
}

.stat-confidence-high {
    background-color: #66bb6a !important; /* Medium green */
    color: #1b5e20 !important;
}

.stat-confidence-very-high {
    background-color: #388e3c !important; /* Dark green */
    color: #ffffff !important;
}

/* List group items for probable scorers */
#upcomingGamesList .list-group-item,
#probableGoalScorersList .list-group-item,
#probablePointScorersList .list-group-item,
#historicalPredictionsList .list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    font-size: 0.95rem;
}

#upcomingGamesList .list-group-item.active {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

#upcomingGamesList .list-group-item:not(.active):hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

/* Probable scorer details */
.scorer-name {
    font-weight: 600;
    color: #343a40;
}

.scorer-team {
    font-size: 0.85rem;
    color: #6c757d;
}

.confidence-score-badge {
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 5px;
    min-width: 70px;
    text-align: center;
}

/* Historical predictions */
.prediction-status {
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.prediction-status.correct {
    background-color: #d4edda;
    color: #155724;
}

.prediction-status.incorrect {
    background-color: #f8d7da;
    color: #721c24;
}

.prediction-details {
    font-size: 0.85rem;
    color: #6c757d;
}

/* Responsive adjustments for probable scorers page */
@media (max-width: 768px) {
    #upcomingGamesList .list-group-item,
    #probableGoalScorersList .list-group-item,
    #probablePointScorersList .list-group-item,
    #historicalPredictionsList .list-group-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 12px;
    }

    .scorer-name, .scorer-team, .confidence-score-badge, .prediction-status, .prediction-details {
        width: 100%;
        text-align: left;
        margin-bottom: 5px;
    }

    .confidence-score-badge {
        min-width: auto;
        text-align: center;
    }
}
