/**
 * 🏁 Heat Racing System CSS
 * Additional styles for the heat-based racing interface
 */

/* Heat Racing Phase - Improved contrast */
.heat-racing-phase {
    padding: 2rem 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.05), transparent);
    min-height: 100vh;
}

/* Race Controls */
.race-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.race-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.progress-text {
    font-weight: 600;
    color: #1a202c;
    white-space: nowrap;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #f7fafc;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-percent {
    font-weight: 600;
    color: #667eea;
    min-width: 40px;
    text-align: right;
}

/* Current Heat Section */
.current-heat-section {
    display: grid;
    grid-template-columns: 2fr 1.5fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
}

.current-heat-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(15px);
}

.heat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.heat-header h2 {
    margin: 0;
    color: #1a202c;
    font-size: 1.5rem;
}

.heat-navigation {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.heat-dropdown {
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #1a202c;
    font-weight: 500;
}

/* Heat Lanes */
.heat-lanes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.lane {
    background: white;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lane.lane-unused {
    opacity: 0.4;
    background: repeating-linear-gradient(
        45deg,
        #f7fafc,
        #f7fafc 10px,
        #edf2f7 10px,
        #edf2f7 20px
    );
    border-style: dashed;
}

.lane:not(.lane-unused):hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* Lane-specific colors */
.lane-1 { border-color: #4299e1; }
.lane-2 { border-color: #48bb78; }  
.lane-4 { border-color: #ed8936; }

.lane-header {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lane-racer {
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.car-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 0.5rem;
    background: #f7fafc;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.racer-name {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 600;
}

/* Results Entry */
.results-entry {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.results-entry h3 {
    margin: 0 0 1.5rem 0;
    color: #1a202c;
    text-align: center;
}

.finish-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.finish-position {
    text-align: center;
}

.finish-position label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1a202c;
}

.lane-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.finish-btn {
    padding: 0.75rem 1rem;
    border: 3px solid #e2e8f0;
    background: white;
    color: #1a202c;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.finish-btn:hover {
    border-color: #667eea;
    background: #667eea;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.finish-btn.selected {
    background: #48bb78;
    color: white;
    border-color: #48bb78;
    box-shadow: 0 0 16px rgba(72, 187, 120, 0.4);
    transform: scale(1.1);
}

/* First place buttons - gold accent */
.finish-position:first-child .finish-btn.selected {
    background: #f6ad55;
    border-color: #f6ad55;
    box-shadow: 0 0 16px rgba(246, 173, 85, 0.4);
}

/* Second place buttons - silver accent */  
.finish-position:nth-child(2) .finish-btn.selected {
    background: #a0aec0;
    border-color: #a0aec0;
    box-shadow: 0 0 16px rgba(160, 174, 192, 0.4);
}

/* Third place buttons - bronze accent */
.finish-position:nth-child(3) .finish-btn.selected {
    background: #d69e2e;
    border-color: #d69e2e;
    box-shadow: 0 0 16px rgba(214, 158, 46, 0.4);
}

.results-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Standings Card */
.standings-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 2px solid #e2e8f0;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
}

.standings-card h3 {
    margin: 0 0 1rem 0;
    color: #1a202c;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.standings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    overflow-y: auto;
}

.standing-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    min-height: 60px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* Removed podium styling - all standings items look identical */

.standing-item .position {
    width: 2rem;
    height: 2rem;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Removed podium position styling - all position badges look identical */

.racer-details {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.racer-details .name {
    font-weight: 600;
    color: #1a202c;
    font-size: 1rem;
    line-height: 1.2;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.racer-details .car-info {
    font-size: 0.85rem;
    color: #718096;
    line-height: 1.2;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.races-count {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 500;
    flex-shrink: 0;
    width: 2rem;
    text-align: center;
}

/* Tie breaker badge in standings */
.tie-breaker-badge {
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

/* Small team badges for standings */
.team-badge-small {
    display: inline-block;
    padding: 0.05rem 0.2rem;
    border-radius: 2px;
    font-size: 0.6rem;
    font-weight: 600;
    color: white;
    margin-left: 0.15rem;
    vertical-align: middle;
}

.team-badge-small.team-guardians {
    background: #1d4ed8;
}

.team-badge-small.team-knights {
    background: #dc2626;
}

/* Heat Schedule Section */
.heat-schedule-section {
    margin-top: 3rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    backdrop-filter: blur(15px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.heat-schedule-section h3 {
    margin-bottom: 2rem;
    color: #1a202c;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(135deg, #48bb78 0%, #2E8B57 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.heat-schedule-section h3:before {
    content: "🏁";
    position: absolute;
    left: -3rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    -webkit-text-fill-color: initial;
}

.heat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1rem;
}

@media (min-width: 1200px) {
    .heat-grid {
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    }
}

.heat-item {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(72, 187, 120, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    transition: all 0.2s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.heat-item.current {
    border-color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
    box-shadow: 0 0 20px rgba(72, 187, 120, 0.3);
    transform: scale(1.02);
}

.heat-item.completed {
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(72, 187, 120, 0.1);
}

.heat-number {
    font-weight: 700;
    color: #48bb78;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    text-align: center;
    padding: 0.5rem;
    background: rgba(72, 187, 120, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(72, 187, 120, 0.2);
}

/* Heat schedule lanes (different from current heat lanes) */
.heat-item .heat-lanes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lane-assignment {
    font-size: 0.9rem;
    color: #2d3748;
    line-height: 1.3;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    border: 1px solid rgba(72, 187, 120, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.lane-assignment strong {
    color: #1a202c;
    font-weight: 600;
    min-width: 24px;
    flex-shrink: 0;
}

/* Heat results styling */
.heat-item.completed .lane-assignment {
    background: rgba(72, 187, 120, 0.05);
    border-color: rgba(72, 187, 120, 0.15);
    font-weight: 600;
}

.heat-item.completed .heat-number {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.15);
    border-color: rgba(72, 187, 120, 0.3);
}

/* Final Heat/Tie Breaker Styling */
.heat-item.final-heat {
    border: 3px solid #dc2626;
    background: linear-gradient(135deg, #fef2f2 0%, rgba(220, 38, 38, 0.1) 100%);
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.3);
    position: relative;
}

.heat-item.final-heat.current {
    border-color: #b91c1c;
    box-shadow: 0 0 25px rgba(185, 28, 28, 0.4);
    animation: pulse-red 2s infinite;
}

.heat-item.final-heat .heat-number {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.3);
}

.tie-breaker-label {
    font-size: 0.7rem;
    color: #dc2626;
    font-weight: bold;
    text-align: center;
    background: rgba(220, 38, 38, 0.1);
    padding: 0.2rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border: 1px solid #dc2626;
}

@keyframes pulse-red {
    0%, 100% { 
        box-shadow: 0 0 25px rgba(185, 28, 28, 0.4);
    }
    50% { 
        box-shadow: 0 0 35px rgba(185, 28, 28, 0.6);
    }
}

.completed-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #48bb78;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Race Completion */
.race-completion {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.9) !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

.race-completion[style*="display: block"] {
    display: flex !important;
}

.completion-card {
    background: white !important;
    border-radius: 32px;
    padding: 4rem;
    width: 80vw !important;
    max-width: 1200px !important;
    min-width: 800px !important;
    text-align: center;
    border: 4px solid #667eea !important;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5) !important;
    position: relative !important;
    margin: auto !important;
    transform: none !important;
}

.completion-card h2 {
    margin: 0 0 3rem 0;
    color: #1a202c !important;
    font-size: 3.5rem !important;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

/* Podium */
.podium {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 2rem;
    margin: 3rem 0;
    height: 400px;
}

.podium-place {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 20px 20px 0 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: end;
    border: 4px solid #e2e8f0;
    min-width: 200px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.podium-first {
    height: 100%;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%) !important;
    border-color: #FFD700 !important;
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.5) !important;
}

.podium-second {
    height: 80%;
    background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%) !important;
    border-color: #C0C0C0 !important;
    box-shadow: 0 12px 35px rgba(192, 192, 192, 0.5) !important;
}

.podium-third {
    height: 60%;
    background: linear-gradient(135deg, #CD7F32 0%, #B8860B 100%) !important;
    border-color: #CD7F32 !important;
    box-shadow: 0 12px 35px rgba(205, 127, 50, 0.5) !important;
}

.place-number {
    font-size: 2.5rem !important;
    font-weight: 700;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    margin-bottom: 1.5rem;
}

.racer-info .name {
    font-weight: 600;
    color: #1a202c !important;
    margin-bottom: 0.5rem;
    font-size: 1.4rem !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.racer-info .points {
    font-size: 1.2rem !important;
    color: #4a5568 !important;
    font-weight: 500;
}

.celebration-confetti {
    font-size: 3rem !important;
    margin: 3rem 0;
    animation: bounce 1s infinite;
    letter-spacing: 0.5rem;
}

/* Completion Card Buttons */
.completion-card .btn {
    padding: 1rem 2rem !important;
    font-size: 1.2rem !important;
    margin: 0 1rem !important;
    min-width: 160px !important;
}

.completion-card .btn-primary {
    background: #48bb78 !important;
    border: none !important;
}

.completion-card .btn-outline {
    border: 2px solid #667eea !important;
    color: #667eea !important;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Mobile Responsive */
/* Mobile responsive updates for heat schedule */
@media (max-width: 768px) {
    .heat-grid {
        grid-template-columns: 1fr;
    }
    
    .heat-item {
        padding: 1rem;
        min-height: 100px;
        max-width: none;
    }
    
    .heat-lanes {
        gap: 0.4rem;
    }
    
    .lane-assignment {
        font-size: 0.85rem;
        padding: 0.4rem 0.5rem;
    }
    
    .current-heat-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .standings-card {
        padding: 0.5rem;
        margin-top: 1rem;
    }
    
    .standing-item {
        padding: 0.25rem 0.375rem;
        gap: 0.375rem;
    }
    
    .standing-item .position {
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.7rem;
    }
    
    .racer-details .name {
        font-size: 0.75rem;
    }
    
    .racer-details .car-info {
        font-size: 0.65rem;
    }
    
    .heat-lanes {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .lane.lane-unused {
        display: none;
    }
    
    .race-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .race-progress {
        margin: 0;
        max-width: none;
    }
    
    .heat-navigation {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .finish-buttons {
        gap: 1.5rem;
    }
    
    .lane-buttons {
        flex-wrap: wrap;
    }
    
    .podium {
        flex-direction: column;
        height: auto;
        gap: 1rem;
    }
    
    .podium-place {
        width: 100%;
        max-width: 300px;
        height: 120px !important;
        flex-direction: row;
        justify-content: space-between;
        border-radius: 12px;
    }
    
    .completion-card {
        padding: 2.5rem 1.5rem;
        width: 95% !important;
        min-width: auto !important;
        border-radius: 24px;
    }
    
    .completion-card h2 {
        font-size: 2.5rem !important;
    }
    
    .podium {
        height: 300px;
        gap: 1rem;
        margin: 2rem 0;
    }
    
    .podium-place {
        min-width: 140px;
        padding: 1.5rem;
    }
    
    .place-number {
        font-size: 2rem !important;
        margin-bottom: 1rem;
    }
    
    .racer-info .name {
        font-size: 1.2rem !important;
    }
    
    .celebration-confetti {
        font-size: 2.5rem !important;
    }
}

/* Extra responsive adjustments */
@media (max-width: 480px) {
    .heat-grid {
        grid-template-columns: 1fr;
    }
    
    .heat-item {
        padding: 0.75rem;
    }
    
    .heat-lanes {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .lane-assignment {
        padding: 0.25rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .lane-assignment:last-child {
        border-bottom: none;
    }
}

/* Team Badge */
.team-badge, .age-group-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    display: inline-block;
    margin-top: 0.25rem;
}

/* Team-specific colors - High contrast */
.team-guardians {
    background: #1d4ed8 !important; /* Darker blue for Guardians */
    color: white !important;
    border: 2px solid #3b82f6 !important;
    font-weight: 600 !important;
}

.team-knights {
    background: #dc2626 !important; /* Bright red for Knights */
    color: white !important;
    border: 2px solid #f87171 !important;
    font-weight: 600 !important;
}

/* Enhanced contrast for team cards */
.racer-card:has(.team-guardians) {
    border-left: 4px solid #1d4ed8;
    background: linear-gradient(135deg, rgba(29, 78, 216, 0.1), transparent);
}

.racer-card:has(.team-knights) {
    border-left: 4px solid #dc2626;
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.1), transparent);
}

/* Tournament Name Section */
.tournament-name-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.tournament-name-section label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.tournament-name-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    background: white;
    color: #2d3748;
    transition: border-color 0.2s ease;
}

.tournament-name-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tournament-name-input::placeholder {
    color: #a0aec0;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-light: rgba(102, 126, 234, 0.15);
        --primary-alpha: rgba(102, 126, 234, 0.3);
    }
}