/* Analytics Page Styles */
.analytics-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.analytics-page .header {
    flex-shrink: 0;
}

.analytics-page .analytics-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.analytics-page .footer {
    flex-shrink: 0;
}

.analytics-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-sizing: border-box;
}

.analytics-header {
    text-align: center;
}

.analytics-header h2 {
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-family: var(--font-display);
}

.analytics-header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    margin: 0;
}

.analytics-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-500);
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Heat Map Section */
.heat-map-section {
    background: var(--bg-card);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.heat-map-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

.heat-map-section p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.legend-item {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.legend-item.high-accuracy {
    background: #10b981;
    color: white;
    font-weight: 500;
}

.legend-item.medium-accuracy {
    background: #f59e0b;
    color: white;
    font-weight: 500;
}

.legend-item.low-accuracy {
    background: #ef4444;
    color: white;
    font-weight: 500;
}

.legend-item.no-data {
    background: #6b7280;
    color: white;
    font-weight: 500;
}

/* Keyboard Layout */
.keyboard-container {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding: 1rem 0;
}

.keyboard-layout {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.15);
    min-width: fit-content;
}

.keyboard-row {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
}

.key {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    background: var(--bg-card);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    font-family: var(--font-mono);
    text-align: center;
    line-height: 1.2;
}

.key:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.key-wide {
    min-width: 4rem;
}

.key-extra-wide {
    min-width: 5rem;
}

.key-super-wide {
    min-width: 12rem;
}

/* Key accuracy colors */
.key.accuracy-high {
    background: #10b981;
    border-color: #047857;
    color: white;
    font-weight: 600;
}

.key.accuracy-high:hover {
    background: #059669;
    transform: translateY(-2px);
}

.key.accuracy-medium {
    background: #f59e0b;
    border-color: #d97706;
    color: white;
    font-weight: 600;
}

.key.accuracy-medium:hover {
    background: #d97706;
    transform: translateY(-2px);
}

.key.accuracy-low {
    background: #ef4444;
    border-color: #dc2626;
    color: white;
    font-weight: 600;
}

.key.accuracy-low:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

.key.no-data {
    background: var(--bg-tertiary);
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-tertiary);
}

/* Key tooltips */
.key-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: 1000;
    margin-bottom: 0.5rem;
    pointer-events: none;
}

.key:hover .key-tooltip {
    opacity: 1;
    visibility: visible;
}

.key-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--bg-primary);
}

/* Detailed Stats Table */
.detailed-stats {
    background: var(--bg-card);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.detailed-stats h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

.stats-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-primary);
}

.stats-table th,
.stats-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.stats-table th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stats-table td {
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

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

.character-cell {
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-align: center;
    font-size: 1rem;
    border-radius: var(--radius-sm);
}

.accuracy-cell {
    font-weight: 600;
}

.accuracy-high-text {
    color: var(--success-600);
}

.accuracy-medium-text {
    color: var(--warning-600);
}

.accuracy-low-text {
    color: var(--error-600);
}

/* Analytics Controls */
.analytics-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* No data state */
.no-data-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.125rem;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.no-data-message h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .analytics-container {
        padding: 1rem;
    }
    
    .analytics-header h2 {
        font-size: 2rem;
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .keyboard-layout {
        transform: scale(0.8);
        transform-origin: center;
    }
    
    .analytics-controls {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .keyboard-layout {
        transform: scale(0.7);
    }
    
    .analytics-header h2 {
        font-size: 1.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}
