/* Modern Race History Styles */

/* CSS Variables for Race History theming */
:root {
    --history-bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --history-card-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
    --history-hover-shadow: 0 25px 50px rgba(0, 0, 0, 0.12);
    --history-border: rgba(226, 232, 240, 0.8);
    --history-accent: #667eea;
    --history-accent-light: #7c3aed;
    --history-text-primary: #1a202c;
    --history-text-secondary: #4a5568;
    --history-bg-white: rgba(255, 255, 255, 0.95);
    --history-header-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --history-row-hover: rgba(102, 126, 234, 0.04);
    --history-success: #10b981;
    --history-warning: #f59e0b;
    --history-danger: #ef4444;
}

/* Modern Race History Container */
.race-history {
    background: var(--history-bg-gradient);
    border-radius: 24px;
    padding: 32px;
    margin-top: 32px;
    box-shadow: var(--history-card-shadow);
    position: relative;
    border: 1px solid var(--history-border);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    /* Ensure no horizontal scrollbar on hover */
    overflow-x: hidden !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Add subtle gradient overlay */
.race-history::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(180deg, rgba(102, 126, 234, 0.03) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.race-history:hover {
    transform: translateY(-4px);
    box-shadow: var(--history-hover-shadow);
    border-color: var(--history-accent);
}

/* Modern History Heading */
#history-heading {
    font-size: 1.5em;
    font-weight: 800;
    color: var(--history-text-primary);
    margin-top: 12px;
    margin-bottom: 28px;
    text-align: center;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Add decorative line under heading */
#history-heading::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--history-accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.race-history:hover #history-heading::after {
    width: 100px;
}

/* Modern Table Container */
.table-container {
    background: var(--history-bg-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--history-border);
    position: relative;
    z-index: 2;
}

/* Modern Table Styles */
#history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375rem;
    background: transparent;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Table Headers */
#history-table thead {
    background: var(--history-header-bg);
    color: white;
}

#history-table th {
    padding: 20px 16px;
    text-align: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    border: none;
    position: relative;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#history-table th:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Add subtle dividers between headers */
#history-table th:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
}

/* Table Body */
#history-table tbody tr {
    background: white;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--history-border);
}

#history-table tbody tr:hover {
    background: var(--history-row-hover);
    /* Removed translateX to prevent horizontal overflow */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

#history-table tbody tr:last-child {
    border-bottom: none;
}

/* Table Cells */
#history-table td {
    padding: 18px 16px;
    text-align: center;
    vertical-align: middle;
    font-weight: 500;
    color: var(--history-text-primary);
    position: relative;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Race Number Column */
#history-table td:first-child {
    font-weight: 700;
    color: var(--history-accent);
    font-size: 1rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Date Column */
#history-table td:nth-child(2) {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--history-text-secondary);
    text-align: center;
}

/* Timestamp styling */
#history-table td:nth-child(2) small {
    display: block;
    margin-top: 2px;
    opacity: 0.7;
    font-size: 0.75rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Position Cells - Updated Styling */
.position-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.position-cell.best {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.position-cell.second {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.position-cell.worst {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#history-table tbody tr:hover .position-cell {
    transform: scale(1.1);
}

/* Action Buttons */
.edit-btn,
.delete-btn {
    padding: 8px 12px;
    margin: 0 4px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 45px;
    width: 45px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.edit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.edit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.delete-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.delete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Empty State */
#history-table tbody tr td[colspan] {
    padding: 60px 20px;
    text-align: center;
    color: var(--history-text-secondary);
    font-size: 1rem;
    font-weight: 400;
    background: var(--history-bg-white);
}

/* Mobile Card Layout */
@media (max-width: 768px) {
    .race-history {
        padding: 20px;
        border-radius: 16px;
    }
    
    #history-heading {
        font-size: 1.2em;
        margin-bottom: 20px;
    }
    
    /* Hide table on mobile */
    .table-container {
        display: none;
    }
    
    /* Show mobile cards */
    .mobile-cards {
        display: block;
    }
}

/* Mobile Card Styles */
.mobile-cards {
    display: none;
    gap: 16px;
    flex-direction: column;
}

@media (max-width: 768px) {
    .mobile-cards {
        display: flex;
    }
}

.race-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--history-border);
    transition: all 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.race-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: var(--history-accent);
}

.race-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--history-border);
}

.race-number {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--history-accent);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.race-date {
    font-size: 0.9375rem;
    color: var(--history-text-secondary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.race-positions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.position-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-label {
    font-size: 0.9375rem;
    color: var(--history-text-secondary);
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.race-card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Theme support */
body.theme {
    --history-bg-gradient: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --history-card-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    --history-hover-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    --history-border: rgba(74, 85, 104, 0.6);
    --history-accent: #818cf8;
    --history-accent-light: #a78bfa;
    --history-text-primary: #f7fafc;
    --history-text-secondary: #e2e8f0;
    --history-bg-white: rgba(45, 55, 72, 0.95);
    --history-header-bg: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    --history-row-hover: rgba(129, 140, 248, 0.08);
    --history-success: #34d399;
    --history-warning: #fbbf24;
    --history-danger: #f87171;
}

body.theme .race-history::before {
    background: linear-gradient(180deg, rgba(129, 140, 248, 0.05) 0%, transparent 100%);
}

body.theme #history-table tbody tr {
    background: #374151;
    border-bottom-color: #4a5568;
}

body.theme #history-table tbody tr:hover {
    background: #4b5563;
}

body.theme .race-card {
    background: #374151;
}

body.theme .race-card:hover {
    background: #4b5563;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    #history-table {
        font-size: 0.8rem;
    }
    
    #history-table th,
    #history-table td {
        padding: 14px 12px;
    }
    
    .position-cell {
        width: 36px;
        height: 36px;
        font-size: 0.9375rem;
    }
}

@media (max-width: 480px) {
    .race-history {
        padding: 16px;
        margin-top: 20px;
    }
    
    #history-heading {
        font-size: 1.1em;
        margin-bottom: 16px;
    }
    
    .race-card {
        padding: 16px;
    }
    
    .race-positions {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#history-table tbody tr {
    animation: fadeInUp 0.3s ease-out;
}

.race-card {
    animation: fadeInUp 0.3s ease-out;
}
