/* Baseball Statistics Display Enhancement - Savant Enhanced Styles */

/* ============================================
   1. Data Density Optimization
   ============================================ */

/* Clean, Minimal Table Layout */
.savant-table-compact {
    font-size: 12px;
    line-height: 1.4;
    border-collapse: collapse;
    width: 100%;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.savant-table-compact th,
.savant-table-compact td {
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
}

.savant-table-compact th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.savant-table-compact tbody tr {
    transition: all 0.15s ease;
}

.savant-table-compact tbody tr:hover {
    background: #f8fafc;
    transform: none;
}

.savant-table-compact tbody tr:last-child td {
    border-bottom: none;
}

/* Enhanced Stat Value Styling */
.stat-value {
    font-weight: 600;
    color: #1e293b;
    font-family: 'Roboto Mono', monospace;
}

.stat-value strong {
    font-weight: 700;
    color: #0f172a;
}

.stat-label {
    font-weight: 500;
    color: #64748b;
}

.stat-comparison {
    color: #64748b;
    font-size: 11px;
}

.stat-indicator {
    font-size: 11px;
}

/* Smart Empty Value Display */
.stat-empty {
    display: inline-block;
    width: 20px;
    height: 1px;
    background: transparent;
}

.stat-zero {
    color: #cbd5e0;
    font-size: 11px;
    font-weight: 400;
}

.stat-null {
    color: #9ca3af;
    font-size: 11px;
}

.no-data {
    color: #6b7280;
    font-style: italic;
    font-size: 11px;
}

.insufficient-data {
    color: #9ca3af;
    font-size: 11px;
}

/* ============================================
   2. Enhanced League Comparison System
   ============================================ */

/* Subtle Performance Indicators - Less Visual Noise */
.perf-elite {
    border-left: 3px solid #22c55e;
    background: rgba(34, 197, 94, 0.02);
}

.perf-excellent {
    border-left: 3px solid #16a34a;
    background: rgba(34, 197, 94, 0.01);
}

.perf-above {
    border-left: 3px solid #84cc16;
    background: transparent;
}

.perf-average {
    border-left: 3px solid #e5e7eb;
    background: transparent;
}

.perf-below {
    border-left: 3px solid #f59e0b;
    background: transparent;
}

.perf-poor {
    border-left: 3px solid #ef4444;
    background: rgba(239, 68, 68, 0.02);
}

/* Comparison visual indicators */
.comparison-visual {
    position: relative;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin: 4px 0;
}

.comparison-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #22c55e);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.comparison-text {
    font-size: 9px;
    color: #6b7280;
    font-weight: 500;
}

/* ============================================
   3. Card-Based Layout for Responsive Display
   ============================================ */

/* Adaptive container switches between views */
@media (max-width: 768px) {
    .desktop-view { display: none; }
    .mobile-view { display: block; }
}

@media (min-width: 769px) {
    .desktop-view { display: block; }
    .mobile-view { display: none; }
}

/* Player Cards */
.player-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.player-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.player-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.player-card-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #002d72;
}

.player-position {
    background: #e5e7eb;
    color: #6b7280;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.player-card-stats {
    padding: 12px;
}

.stat-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
    margin-bottom: 12px;
}

.stat-group.secondary {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #002d72;
    font-family: 'Roboto Mono', monospace;
    transition: color 0.3s ease, transform 0.2s ease;
}

.stat-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    margin-top: 2px;
    font-weight: 500;
}

.stat-group-details {
    margin-top: 8px;
}

.stat-group-details summary {
    font-size: 11px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 0;
    border-top: 1px solid #e5e7eb;
    margin-top: 8px;
}

.stat-group-details summary:hover {
    color: #002d72;
}

.player-card-comparison {
    padding: 8px 12px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

/* ============================================
   4. Progressive Disclosure Implementation
   ============================================ */

.stats-toggle-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.toggle-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.toggle-icon {
    font-size: 11px;
    transition: transform 0.2s ease;
}

.toggle-btn.active .toggle-icon {
    transform: rotate(90deg);
}

/* Collapsible sections */
.stats-basic {
    display: block;
}

.stats-advanced {
    display: none;
    animation: slideDown 0.3s ease;
}

.stats-advanced.expanded {
    display: block;
}

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

/* ============================================
   5. Interactive Hover States & Tooltips
   ============================================ */

.stats-tooltip {
    position: absolute;
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.tooltip-header {
    font-weight: 600;
    margin-bottom: 4px;
    color: #f9fafb;
}

.tooltip-body {
    color: #d1d5db;
}

.tooltip-body div {
    margin-bottom: 2px;
}

/* ============================================
   6. Visual Polish and Micro-interactions
   ============================================ */

/* Animated stat changes */
.stat-value.increased {
    animation: pulseGreen 1s ease;
}

.stat-value.decreased {
    animation: pulseRed 1s ease;
}

@keyframes pulseGreen {
    0%, 100% { color: #002d72; }
    50% { color: #10b981; transform: scale(1.05); }
}

@keyframes pulseRed {
    0%, 100% { color: #002d72; }
    50% { color: #ef4444; transform: scale(1.05); }
}

/* Inline sparklines */
.inline-sparkline {
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

/* Enhanced table interactions */
.savant-table-compact tbody tr {
    transition: all 0.2s ease;
    cursor: pointer;
}

.savant-table-compact tbody tr:hover {
    background: linear-gradient(90deg, #f0f9ff 0%, #ffffff 100%);
    transform: translateX(2px);
}

/* Data attribute styling */
[data-stat] {
    position: relative;
    cursor: help;
}

[data-stat]:hover::after {
    content: attr(data-stat);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 4px;
}

/* ============================================
   7. Responsive Enhancements
   ============================================ */

@media (max-width: 768px) {
    .savant-table-compact {
        font-size: 11px;
    }
    
    .savant-table-compact th,
    .savant-table-compact td {
        padding: 8px 12px;
    }
    
    .stats-toggle-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .toggle-btn {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    .stat-group {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-value {
        font-size: 14px;
    }
    
    .player-card-header {
        padding: 8px;
    }
    
    .player-card-stats {
        padding: 8px;
    }
}

@media (max-width: 640px) {
    .savant-table-compact {
        font-size: 10px;
    }
    
    .savant-table-compact th,
    .savant-table-compact td {
        padding: 6px 8px;
    }
    
    .stats-toggle-bar {
        flex-direction: column;
        gap: 6px;
    }
    
    .toggle-btn {
        font-size: 10px;
        padding: 4px 8px;
        justify-content: center;
    }
}

/* ============================================
   8. Loading States
   ============================================ */

.stats-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.stats-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #002d72;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   8. Enhanced Button Styling
   ============================================ */

.savant-btn-export {
    transition: all 0.2s ease !important;
}

.savant-btn-export:hover {
    background: #2563eb !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3) !important;
}

.savant-btn-export:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3) !important;
}

/* ============================================
   9. Accessibility Enhancements
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus states for keyboard navigation */
.toggle-btn:focus,
.player-card:focus {
    outline: 2px solid #002d72;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .perf-elite,
    .perf-excellent,
    .perf-above {
        background: #22c55e;
        color: white;
    }
    
    .perf-below,
    .perf-poor {
        background: #ef4444;
        color: white;
    }
}
