/* Team Stats Dashboard Styles */
.team-stats-dashboard {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.dashboard-header h1 {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0;
}

.team-logo-lg {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.season-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.season-selector label {
    margin: 0;
    font-weight: 500;
}

.season-selector select {
    width: 120px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Section Spacing */
#metrics-cards-section,
#progression-charts-section,
#stats-grid-section {
    margin-bottom: 30px;
}

/* Info Alerts */
.alert {
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert i {
    font-size: 1.2rem;
}

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

.table {
    margin-bottom: 0;
}

.table thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Card Styling */
.card {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.card-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    padding: 15px 20px;
}

.card-header h5 {
    margin: 0;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .team-stats-dashboard {
        padding: 10px;
    }

    .team-logo-lg {
        width: 50px;
        height: 50px;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .season-selector {
        width: 100%;
        justify-content: space-between;
    }

    .season-selector select {
        flex: 1;
    }
}

/* Stats Grid */
.stats-grid-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 30px;
}

.stats-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.stats-grid-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.grid-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Export Dropdown Styling */
.grid-controls .dropdown {
    position: relative;
}

.grid-controls .dropdown-menu {
    min-width: 180px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #dee2e6;
    padding: 8px 0;
}

.grid-controls .dropdown-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #495057;
    transition: background-color 0.2s;
    cursor: pointer;
}

.grid-controls .dropdown-item:hover {
    background-color: #f8f9fa;
    color: #212529;
    text-decoration: none;
}

.grid-controls .dropdown-item i {
    width: 18px;
    text-align: center;
    color: #6c757d;
}

.grid-controls .dropdown-item:hover i.fa-file-csv {
    color: #28a745;
}

.grid-controls .dropdown-item:hover i.fa-file-code {
    color: #17a2b8;
}

#gridSearch {
    width: 200px;
}

#statsGrid {
    margin-bottom: 0;
}

#statsGrid thead th {
    background: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

#statsGrid thead th:hover {
    background: #e9ecef;
}

#statsGrid thead th i.fa-sort {
    opacity: 0.3;
    margin-left: 5px;
}

#statsGrid thead th.sort-asc i.fa-sort:before {
    content: "\f0de";
    opacity: 1;
}

#statsGrid thead th.sort-desc i.fa-sort:before {
    content: "\f0dd";
    opacity: 1;
}

/* Home/Away indicators */
.home-game {
    background: #e8f5e9 !important;
}

.away-game {
    background: #fff3e0 !important;
}

/* Win/Loss indicators */
.result-win {
    color: #28a745;
    font-weight: 600;
}

.result-loss {
    color: #dc3545;
    font-weight: 600;
}

/* Metrics Cards */
.metrics-cards-container {
    margin-bottom: 30px;
}

.metrics-header {
    margin-bottom: 20px;
}

.metrics-header h3 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0;
}

.metrics-header h3 i {
    margin-right: 10px;
    color: #9b59b6;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Tablet breakpoint for better 10-card layout */
@media (max-width: 1200px) and (min-width: 769px) {
    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
    }
}

.metric-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    gap: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.metric-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.metric-card#ppgCard .metric-icon {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.metric-card#ypgCard .metric-icon {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.metric-card#toMarginCard .metric-icon {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.metric-card#thirdDownCard .metric-icon {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.metric-card#topCard .metric-icon {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
}

.metric-card#penaltiesCard .metric-icon {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.metric-card#fourthDownCard .metric-icon {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.metric-card#tflCard .metric-icon {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.metric-card#sacksCard .metric-icon {
    background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
}

.metric-card#firstDownsCard .metric-icon {
    background: linear-gradient(135deg, #fad0c4 0%, #ffd1ff 100%);
}

.metric-content {
    flex: 1;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
    margin-bottom: 5px;
}

.metric-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.metric-stats {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #95a5a6;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.metric-stats strong {
    color: #34495e;
}

.metric-trend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.metric-trend.improving {
    background-color: #d4edda;
    color: #155724;
}

.metric-trend.improving::before {
    content: "↑";
    font-size: 1.2rem;
}

.metric-trend.declining {
    background-color: #f8d7da;
    color: #721c24;
}

.metric-trend.declining::before {
    content: "↓";
    font-size: 1.2rem;
}

.metric-trend.stable {
    background-color: #fff3cd;
    color: #856404;
}

.metric-trend.stable::before {
    content: "→";
    font-size: 1.2rem;
}

/* Legacy trend classes for backward compatibility */
.metric-trend.up {
    background-color: #d4edda;
    color: #155724;
}

.metric-trend.down {
    background-color: #f8d7da;
    color: #721c24;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .stats-grid-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .grid-controls {
        width: 100%;
    }

    #gridSearch {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-value {
        font-size: 1.75rem;
    }
}

@media (max-width: 576px) {
    .metric-card {
        padding: 15px;
    }

    .metric-icon {
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .metric-label {
        font-size: 0.85rem;
    }

    .metric-stats {
        font-size: 0.75rem;
        flex-direction: column;
        gap: 3px;
    }

    /* Keep old metric-details class for backward compatibility */
    .metric-details {
        font-size: 11px;
        flex-direction: column;
        gap: 3px;
    }
}

/* Progression Charts */
.progression-charts-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 30px;
}

.charts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

/* Season Comparison Selector */
.season-comparison-selector {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.season-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.season-selector-header label {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.season-selector-header label i {
    color: #6c757d;
}

.season-selector-actions {
    display: flex;
    gap: 8px;
}

.season-selector-actions .btn {
    font-size: 0.8rem;
    padding: 4px 10px;
}

.season-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.season-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.season-checkbox-item:hover {
    border-color: #adb5bd;
    background: #f1f3f5;
}

.season-checkbox-item.selected {
    border-color: #007bff;
    background: #e7f1ff;
}

.season-checkbox-item input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

.season-checkbox-item label {
    margin: 0;
    cursor: pointer;
    font-weight: 500;
    color: #495057;
    font-size: 0.9rem;
}

.season-checkbox-item.selected label {
    color: #007bff;
    font-weight: 600;
}

.season-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.charts-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
}

.charts-header h3 i {
    margin-right: 10px;
    color: #e74c3c;
}

.chart-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.chart-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    min-height: 300px;
}

.chart-card.chart-main {
    min-height: 400px;
}

.chart-card h5 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-secondary {
    min-height: 250px;
}

@media (min-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chart-card.chart-main {
        grid-column: 1 / -1;
    }
}

/* Chart responsive adjustments */
@media (max-width: 768px) {
    .charts-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .chart-controls {
        width: 100%;
    }

    .chart-controls select {
        width: 100%;
    }

    .season-selector-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .season-selector-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .season-checkboxes {
        gap: 10px;
    }

    .season-checkbox-item {
        flex: 1 1 calc(50% - 5px);
        min-width: 140px;
    }
}

@media (max-width: 576px) {
    .season-checkbox-item {
        flex: 1 1 100%;
    }
}

/* Enhanced Stats Grid Styles */
.stats-grid-table {
    margin-bottom: 0;
    font-size: 0.9rem;
}

.stats-grid-table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    padding: 12px 8px;
}

.stats-grid-table thead th:hover {
    background-color: #e9ecef;
}

.stats-grid-table thead th i.fa-sort {
    opacity: 0.3;
    margin-left: 5px;
    font-size: 0.8rem;
}

.stats-grid-table thead th:hover i.fa-sort {
    opacity: 0.6;
}

.stats-grid-table thead th.sort-asc i.fa-sort::before {
    content: "\f0de"; /* fa-sort-up */
    opacity: 1;
}

.stats-grid-table thead th.sort-desc i.fa-sort::before {
    content: "\f0dd"; /* fa-sort-down */
    opacity: 1;
}

.stats-grid-table tbody tr {
    transition: background-color 0.2s;
}

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

.stats-grid-table tbody tr.home-game {
    background-color: #e8f5e9;
}

.stats-grid-table tbody tr.away-game {
    background-color: #fff3e0;
}

.stats-grid-table tbody tr.home-game:hover {
    background-color: #c8e6c9;
}

.stats-grid-table tbody tr.away-game:hover {
    background-color: #ffe0b2;
}

.stats-grid-table td {
    padding: 10px 8px;
    vertical-align: middle;
}

.result-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

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

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

.home-away-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.home-away-badge.home {
    background-color: #28a745;
    color: white;
}

.home-away-badge.away {
    background-color: #ffc107;
    color: #000;
}

.stats-grid-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.stats-grid-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
}

.stats-grid-header h3 i {
    margin-right: 10px;
    color: #3498db;
}

.stats-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

/* Table Scroll Container for Mobile */
.table-scroll-container {
    position: relative;
}

.table-scroll-inner {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.scroll-hint {
    text-align: center;
    padding: 10px;
    color: #6c757d;
    font-size: 0.85rem;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
    margin-top: -1px;
}

.scroll-hint i {
    margin-right: 5px;
    color: #007bff;
}

/* Mobile Responsive for Stats Grid */
@media (max-width: 768px) {
    .stats-table-wrapper {
        margin: 0 -1rem;
    }

    .stats-grid-table {
        font-size: 0.75rem;
        min-width: 900px;
    }

    .stats-grid-table th,
    .stats-grid-table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }

    /* Sticky Week column */
    .stats-grid-table th:first-child,
    .stats-grid-table td:first-child {
        position: sticky;
        left: 0;
        background: #f8f9fa;
        z-index: 2;
        min-width: 50px;
        box-shadow: 2px 0 4px rgba(0,0,0,0.05);
    }

    /* Sticky Opponent column */
    .stats-grid-table th:nth-child(2),
    .stats-grid-table td:nth-child(2) {
        position: sticky;
        left: 50px;
        background: #f8f9fa;
        z-index: 2;
        min-width: 100px;
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    }

    /* Maintain row background colors for sticky columns */
    .stats-grid-table tbody tr.home-game td:first-child,
    .stats-grid-table tbody tr.home-game td:nth-child(2) {
        background-color: #e8f5e9;
    }

    .stats-grid-table tbody tr.away-game td:first-child,
    .stats-grid-table tbody tr.away-game td:nth-child(2) {
        background-color: #fff3e0;
    }

    .stats-grid-table tbody tr.home-game:hover td:first-child,
    .stats-grid-table tbody tr.home-game:hover td:nth-child(2) {
        background-color: #c8e6c9;
    }

    .stats-grid-table tbody tr.away-game:hover td:first-child,
    .stats-grid-table tbody tr.away-game:hover td:nth-child(2) {
        background-color: #ffe0b2;
    }

    .stats-grid-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* Dark mode support for sticky columns */
[data-theme="dark"] .stats-grid-table th:first-child,
[data-theme="dark"] .stats-grid-table td:first-child,
[data-theme="dark"] .stats-grid-table th:nth-child(2),
[data-theme="dark"] .stats-grid-table td:nth-child(2) {
    background: #2c3e50;
}

[data-theme="dark"] .stats-grid-table tbody tr.home-game td:first-child,
[data-theme="dark"] .stats-grid-table tbody tr.home-game td:nth-child(2) {
    background-color: #1e4620;
}

[data-theme="dark"] .stats-grid-table tbody tr.away-game td:first-child,
[data-theme="dark"] .stats-grid-table tbody tr.away-game td:nth-child(2) {
    background-color: #4a3a1f;
}

[data-theme="dark"] .scroll-hint {
    background: #2c3e50;
    color: #adb5bd;
}

/* Loading skeleton styles */
.loading-skeleton {
    pointer-events: none;
}

.skeleton-box {
    height: 20px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin: 4px 0;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Advanced Filter Panel Styles */
.filter-panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.filter-panel-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filter-section {
    background: white;
    border-radius: 6px;
    padding: 15px;
    border: 1px solid #e0e0e0;
}

.filter-section h5 {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-section h5 i {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Quick Filters Section */
.filter-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.filter-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

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

.filter-btn i {
    font-size: 0.85rem;
    color: #6c757d;
}

.filter-btn:hover i {
    color: #495057;
}

/* Custom Filter Builder */
.filter-builder {
    margin-bottom: 15px;
}

.filter-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.filter-stat,
.filter-operator,
.filter-value {
    height: 38px;
}

.add-filter-btn {
    height: 38px;
    white-space: nowrap;
}

/* Active Filters List */
.active-filters-list {
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #007bff;
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.filter-badge-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    transition: background 0.2s;
}

.filter-badge-remove:hover {
    background: rgba(255, 255, 255, 0.2);
}

.filter-badge-remove i {
    font-size: 0.75rem;
}

/* Filter Results */
.filter-results {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e7f1ff;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #b3d7ff;
}

.results-info {
    font-size: 0.95rem;
    color: #004085;
}

.results-info strong {
    font-weight: 600;
    color: #002752;
}

/* Mobile Responsive for Filters */
@media (max-width: 768px) {
    .filter-buttons-grid {
        grid-template-columns: 1fr;
    }

    .filter-row {
        grid-template-columns: 1fr;
    }

    .add-filter-btn {
        width: 100%;
    }

    .filter-results {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .filter-results button {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .filter-panel {
        padding: 15px;
    }

    .filter-section {
        padding: 12px;
    }

    .filter-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}
