/* F1 Manager Game - Dark F1 Theme */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* F1 Dark Theme Colors */
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --bg-card-hover: #2a2a2a;
    --bg-input: #2d2d2d;
    --accent-red: #e10600;
    --accent-red-hover: #ff1a1a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #3a3a3a;
    --border-accent: #e10600;
    --success: #00d26a;
    --warning: #ffb800;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

.navbar {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    border-bottom: 2px solid var(--accent-red);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-red);
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--accent-red);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 4px solid;
}

.flash-success {
    background: rgba(0, 210, 106, 0.15);
    color: var(--success);
    border-color: var(--success);
}

.flash-error {
    background: rgba(225, 6, 0, 0.15);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.flash-info {
    background: rgba(33, 150, 243, 0.15);
    color: #64b5f6;
    border-color: #2196f3;
}

/* Login */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-box {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--accent-red);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--accent-red);
    font-weight: 700;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-red);
}

.register-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

.register-link a {
    color: var(--accent-red);
    text-decoration: none;
}

.register-link a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--accent-red);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-red-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: #000;
}

.btn-success:hover {
    background: #00e676;
    transform: translateY(-1px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #3a3a3a;
    border-color: var(--accent-red);
}

/* Lobby */
.lobby-container {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(8px);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lobby-actions {
    margin-bottom: 2rem;
}

.rooms-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.rooms-list {
    display: grid;
    gap: 1rem;
}

.room-card {
    background: rgba(40, 40, 40, 0.8);
    backdrop-filter: blur(4px);
    padding: 1.5rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--accent-red);
    transition: all 0.3s;
}

.room-card:hover {
    border-color: var(--accent-red);
}

.room-info h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.room-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.room-full {
    color: var(--text-muted);
    font-style: italic;
}

/* Mina aktiva race */
.my-races-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.my-race-card {
    background: rgba(0, 210, 106, 0.1) !important;
    border-color: var(--success) !important;
}

.my-race-card.racing {
    background: rgba(225, 6, 0, 0.1) !important;
    border-color: var(--accent-red) !important;
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--accent-red); }
    50% { border-color: var(--warning); }
}

.status-racing {
    color: var(--accent-red);
    font-weight: bold;
    animation: blink-text 1s ease-in-out infinite;
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-waiting {
    color: var(--warning);
    font-weight: bold;
}

/* Dashboard */
.dashboard-container {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(8px);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.dashboard-card {
    background: rgba(40, 40, 40, 0.8);
    backdrop-filter: blur(4px);
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--accent-red);
    transition: all 0.3s;
}

.dashboard-card:hover {
    background: rgba(50, 50, 50, 0.9);
    border-left-color: var(--accent-red-hover);
}

.dashboard-card h3 {
    margin-bottom: 1rem;
    color: var(--accent-red);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.budget-amount {
    font-size: 2rem;
    font-weight: bold;
    color: var(--success);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-input);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.stat-item span:first-child {
    color: var(--text-secondary);
}

.stat-item span:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

/* Race Room */
/* ========== MINI LEADERBOARD (F1-stil) ========== */
.mini-leaderboard {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-height: 80vh;
    background: rgba(30, 30, 30, 0.98);
    backdrop-filter: blur(10px);
    border-right: 2px solid var(--accent-red);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mini-leaderboard-header {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
    padding: 12px 16px;
    border-bottom: 2px solid var(--accent-red);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.f1-logo {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(225, 6, 0, 0.8);
}

.race-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
    flex: 1;
    text-align: center;
}

.lap-info {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.mini-leaderboard-gap-toggle {
    display: flex;
    padding: 6px 10px;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gap-toggle-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.gap-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ccc;
}

.gap-toggle-btn.active {
    background: #e10600;
    color: white;
}

.mini-leaderboard-content {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    max-height: calc(80vh - 60px);
}

.mini-leaderboard-content .waiting-text {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.mini-leaderboard-row {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s;
    font-size: 13px;
}

.mini-leaderboard-row:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.mini-leaderboard-row.my-driver {
    background-color: rgba(225, 6, 0, 0.2);
    border-left: 3px solid #e10600;
}

.mini-leaderboard-row.position-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15) 0%, transparent 100%);
}

.mini-leaderboard-row.position-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.1) 0%, transparent 100%);
}

.mini-leaderboard-row.position-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.1) 0%, transparent 100%);
}

.mini-leaderboard-pos {
    width: 24px;
    text-align: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 14px;
    flex-shrink: 0;
}

.mini-leaderboard-name {
    flex: 1;
    color: #ffffff;
    font-weight: 600;
    margin-left: 8px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-leaderboard-gap {
    width: 70px;
    text-align: right;
    color: #cccccc;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
    flex-shrink: 0;
    margin-right: 8px;
}

.mini-leaderboard-gap.leader {
    color: #ffd700;
    font-weight: 700;
}

.mini-leaderboard-tyre {
    width: 24px;
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.mini-leaderboard-tyre.soft {
    color: #e10600;
}

.mini-leaderboard-tyre.medium {
    color: #ffd700;
}

.mini-leaderboard-tyre.hard {
    color: #ffffff;
}

/* Responsive: Dölj mini-leaderboard på mobil */
@media (max-width: 1024px) {
    .mini-leaderboard {
        display: none;
    }
}

.race-room-container {
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(8px);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.race-info {
    margin-bottom: 1rem;
    padding: 1rem;
    background: rgba(40, 40, 40, 0.7);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.race-status {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-red);
}

.race-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
    margin-left: 280px; /* Gör plats för mini-leaderboard */
}

.race-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.leaderboard-section,
.race-feed-section {
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(6px);
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 2px solid var(--accent-red);
}

.leaderboard-section h3,
.race-feed-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.leaderboard {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.leaderboard-table thead {
    background: var(--accent-red);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.leaderboard-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.leaderboard-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.leaderboard-row {
    transition: background 0.2s;
}

.leaderboard-row:hover {
    background: var(--bg-card-hover);
}

.leaderboard-row.position-1 {
    background: rgba(255, 215, 0, 0.1);
    font-weight: bold;
}

.leaderboard-row.position-2 {
    background: rgba(192, 192, 192, 0.1);
}

.leaderboard-row.position-3 {
    background: rgba(205, 127, 50, 0.1);
}

.leaderboard-row.in-pitlane {
    background: rgba(225, 6, 0, 0.1);
    font-style: italic;
}

.leaderboard-row.player-driver {
    color: var(--success);
    font-weight: bold;
}

.leaderboard-row.player-driver td {
    color: var(--success);
}

.race-feed {
    max-height: 300px;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.8);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.feed-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--accent-red);
    padding-left: 1rem;
}

.race-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Sticky på desktop - följer med när man scrollar */
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.control-panel {
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(6px);
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--accent-red);
}

.control-panel h3 {
    margin-bottom: 1rem;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent-red);
}

.control-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.control-group select:focus {
    outline: none;
    border-color: var(--accent-red);
}

.control-group h4 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 1rem;
}

.pitstop-hint,
.control-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 0.5rem;
    margin-top: 0.25rem;
}

.pitstop-add {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.pitstop-items {
    margin-top: 0.5rem;
}

.pitstop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-remove {
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
}

.btn-remove:hover {
    background: #d32f2f;
}

.emergency-pitstop {
    background: rgba(255, 152, 0, 0.2);
    padding: 1rem;
    border-radius: 4px;
    border: 2px solid #ffc107;
    margin-top: 1rem;
}

.emergency-pitstop-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.btn-warning {
    background: #ff9800;
    color: #000;
    font-weight: 600;
}

.btn-warning:hover {
    background: #ffb300;
}

.driver-pitstop-control {
    background: var(--bg-card);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    border: 2px solid #ddd;
}

.driver-info {
    margin-bottom: 0.75rem;
}

.driver-info strong {
    color: #2a5298;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.driver-stats {
    font-size: 0.9rem;
    color: #666;
}

.driver-pitstop-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-box {
    background: #f44336;
    color: white;
    font-weight: bold;
    padding: 0.5rem 1.5rem;
}

.btn-box:hover {
    background: #d32f2f;
}

/* Push Mode Toggle */
.push-mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.push-mode-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: #34495e;
    color: white;
    border: 2px solid #2c3e50;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    font-weight: 500;
}

.push-mode-btn:hover {
    background: #2c3e50;
    border-color: #3498db;
}

.push-mode-btn.active {
    background: #3498db;
    border-color: #2980b9;
    color: white;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.push-mode-btn.active:hover {
    background: #2980b9;
}

.max-level {
    color: #27ae60;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Broken Car Warning */
.broken-car-warning {
    background: rgba(255, 152, 0, 0.15);
    border: 2px solid #ffc107;
    border-left: 5px solid #ff9800;
}

.broken-car-warning h3 {
    color: #e65100;
    margin-bottom: 0.5rem;
}

.broken-car-warning p {
    margin-bottom: 0.5rem;
    color: #856404;
}

/* Notification Popup */
.notification-popup {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 300px;
    text-align: center;
    transition: top 0.3s ease-out;
    font-size: 1rem;
}

.notification-popup.show {
    top: 20px;
}

.notification-popup.success {
    background: #4caf50;
}

.notification-popup.error {
    background: #f44336;
}

.notification-popup.info {
    background: #2196f3;
}

.notification-popup.warning {
    background: #ff9800;
}

/* Push Mode Buttons */
.speed-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.speed-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #444;
    background: #2a2a2a;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    font-weight: 600;
}

.speed-btn:hover {
    background: #3a3a3a;
}

.speed-btn.active {
    background: #2a5298;
    border-color: #1e3c72;
    box-shadow: 0 2px 4px rgba(42, 82, 152, 0.3);
}

.push-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.push-btn {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #444;
    background: #2a2a2a;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.push-btn:hover {
    background: #3a3a3a;
    border-color: #555;
}

.push-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

/* Individual push mode colors when active */
.push-btn[data-mode="conservative"].active {
    background: #2196f3;
    border-color: #2196f3;
}

.push-btn[data-mode="normal"].active {
    background: #4caf50;
    border-color: #4caf50;
}

.push-btn[data-mode="aggressive"].active {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

/* Control Select */
.control-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #444;
    background: #2a2a2a;
    color: white;
    border-radius: 8px;
    font-size: 1rem;
    margin: 0.5rem 0;
}

/* Pit Controls */
#pit-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#pit-controls .control-select {
    flex: 1;
}

#pit-btn {
    padding: 0.75rem 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
}

/* My Driver Status */
.driver-status-card {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #e10600;
    color: white;
}

.driver-status-card p {
    margin: 0.25rem 0;
}

/* Leaderboard Table - My Driver Highlight */
.my-driver {
    background: rgba(225, 7, 0, 0.694) !important;
    font-weight: bold;
}

/* Button Large */
.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    width: 100%;
}

/* Hint Text */
.hint {
    color: #888;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Feed Item Animation */
.feed-item {
    animation: slideIn 0.3s ease;
}

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

/* Car Visualization */
.car-visualization-section {
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(6px);
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 2px solid var(--accent-red);
    margin-bottom: 2rem;
}

.car-visualization-section h3 {
    margin-bottom: 1rem;
    color: var(--accent-red);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.car-visualization-container {
    position: relative;
    min-height: 150px;
    background: rgba(20, 20, 20, 0.9);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 25px 20px 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.car-visualization-container p {
    color: var(--text-secondary);
}

.gap-scale-horizontal {
    position: absolute;
    left: 0;
    top: 0;
    height: 20px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 6px 6px 0 0;
    z-index: 100;
    border-bottom: 2px solid rgba(255, 215, 0, 0.5);
}

.gap-scale-mark-h {
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    padding: 2px 4px;
    color: white;
    font-size: 0.55rem;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

.gap-scale-mark-h.leader {
    background: rgba(255, 215, 0, 0.4);
    color: #ffd700;
    font-weight: 900;
    border-radius: 3px;
}

.car-item {
    position: absolute;
    transition: top 0.5s ease-out, left 0.3s ease-out;
    display: flex;
    flex-direction: row;
    align-items: center;
    z-index: 10;
    gap: 3px;
}

.car-gap-label {
    background: rgba(0, 0, 0, 0.85);
    color: #888;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: bold;
    white-space: nowrap;
    border: 1px solid rgba(136, 136, 136, 0.3);
    text-align: center;
    line-height: 1.1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-family: 'Consolas', 'Monaco', monospace;
    transition: color 0.3s, border-color 0.3s;
}

.car-gap-label.leader {
    background: rgba(255, 215, 0, 0.95);
    color: #000;
    border-color: #ffd700;
    font-weight: 900;
}

.car-gap-label.gaining {
    color: #0f0;
    border-color: rgba(0, 255, 0, 0.5);
    text-shadow: 0 0 4px rgba(0, 255, 0, 0.5);
}

.car-gap-label.losing {
    color: #ff4444;
    border-color: rgba(255, 68, 68, 0.5);
    text-shadow: 0 0 4px rgba(255, 68, 68, 0.5);
}

/* Slitage-label */
.car-wear-label {
    background: rgba(0, 0, 0, 0.85);
    color: #0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.55rem;
    font-weight: bold;
    white-space: nowrap;
    border: 1px solid rgba(0, 255, 0, 0.3);
    text-align: center;
    line-height: 1.1;
    font-family: 'Consolas', 'Monaco', monospace;
}

.car-wear-label.wear-warning {
    color: #ffa500;
    border-color: rgba(255, 165, 0, 0.4);
}

.car-wear-label.wear-critical {
    color: #ff4444;
    border-color: rgba(255, 68, 68, 0.4);
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.car-icon {
    min-width: 55px;
    height: 20px;
    padding: 0 5px;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
    border: 2px solid #888;
    border-radius: 4px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.3s;
}

/* Däckfärger på ramen - dessa har prioritet */
.car-icon.tyre-soft {
    border-color: #e10600 !important;
    box-shadow: 0 2px 6px rgba(225, 6, 0, 0.4);
}

.car-icon.tyre-medium {
    border-color: #ffd700 !important;
    box-shadow: 0 2px 6px rgba(255, 215, 0, 0.4);
}

.car-icon.tyre-hard {
    border-color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(255, 255, 255, 0.3);
}

.car-icon:hover {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    z-index: 20;
}


.car-icon.my-driver {
    border-width: 3px;
    position: relative;
    
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.8), 
                0 0 0 4px rgba(0, 150, 255, 0.4),
                0 4px 12px rgba(0, 0, 0, 0.6);
    animation: playerPulse 2s ease-in-out infinite;
}

/* Puls-effekt för spelarens bil */
@keyframes playerPulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.8), 
                    0 0 0 4px rgba(0, 150, 255, 0.4),
                    0 4px 12px rgba(0, 0, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(0, 150, 255, 1), 
                    0 0 0 6px rgba(0, 150, 255, 0.6),
                    0 4px 16px rgba(0, 150, 255, 0.4);
    }
}

/* Överskriv box-shadow för spelarens bil baserat på däcktyp */
.car-icon.my-driver.tyre-soft {
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.8), 
                0 0 0 4px rgba(0, 150, 255, 0.4),
                0 2px 6px rgba(225, 6, 0, 0.6),
                0 4px 12px rgba(0, 0, 0, 0.6);
}

.car-icon.my-driver.tyre-medium {
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.8), 
                0 0 0 4px rgba(0, 150, 255, 0.4),
                0 2px 6px rgba(255, 215, 0, 0.6),
                0 4px 12px rgba(0, 0, 0, 0.6);
}

.car-icon.my-driver.tyre-hard {
    box-shadow: 0 0 0 2px rgba(0, 150, 255, 0.8), 
                0 0 0 4px rgba(0, 150, 255, 0.4),
                0 2px 6px rgba(255, 255, 255, 0.5),
                0 4px 12px rgba(0, 0, 0, 0.6);
}

.car-icon.in-pit {
    opacity: 0.5;
    border-style: dashed;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.8;
    }
}

.car-name-inside {
    color: white;
    font-size: 0.6rem;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}


.car-position-label {
    background: #2a5298;
    color: white;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.5rem;
    border: 1px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.car-position-label.position-1 {
    background: #ffd700;
    color: #000;
    border-color: #ffed4e;
}

.car-position-label.position-2 {
    background: #c0c0c0;
    color: #000;
    border-color: #e0e0e0;
}

.car-position-label.position-3 {
    background: #cd7f32;
    color: #fff;
    border-color: #e6a052;
}

/* Responsive */
@media (max-width: 768px) {
    .race-layout {
        grid-template-columns: 1fr;
        margin-left: 0; /* Ingen margin på mobil */
        /* Lägg till padding längst ned för att kontrollerna inte ska täcka innehåll */
        padding-bottom: 280px;
    }
    
    .race-controls {
        /* På mobil: fixed längst ned */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 250px;
        background: var(--bg-card);
        border-top: 3px solid var(--accent-red);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
        z-index: 1000;
        padding: 1rem;
        overflow-y: auto;
        /* Gör så att kontrollerna kan scrollas om de är för höga */
        -webkit-overflow-scrolling: touch;
    }
    
    .control-panel {
        margin-bottom: 0;
        padding: 1rem;
        border: none;
        border-radius: 0;
        background: var(--bg-card);
    }
    
    .control-panel h3 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .control-group {
        margin-bottom: 0.75rem;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .notification-popup {
        left: 10px;
        right: 10px;
        transform: none;
        min-width: auto;
        /* Se till att notifikationer visas ovanför kontrollerna */
        z-index: 1001;
    }
    
    .push-buttons {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .push-btn {
        flex: 1;
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .car-visualization-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .car-visualization-section h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .car-visualization-container {
        min-height: 400px;
        height: 500px;
        padding: 10px;
        overflow: hidden;
        position: relative;
    }
    
    #track-canvas {
        display: block;
        width: 100%;
        height: 100%;
    }
    
    .gap-scale-horizontal {
        height: 15px;
        font-size: 0.5rem;
    }
    
    .gap-scale-mark-h {
        font-size: 0.45rem;
        padding: 1px 3px;
    }
    
    .car-item {
        gap: 2px;
    }
    
    .car-icon {
        min-width: 40px;
        width: 40px;
        height: 18px;
        padding: 0 3px;
        font-size: 0.5rem;
    }
    
    .car-name-inside {
        font-size: 0.5rem;
        max-width: 50px;
    }
    
    .car-position-label {
        width: 12px;
        height: 12px;
        font-size: 0.45rem;
    }
    
    .car-gap-label {
        font-size: 0.5rem;
        padding: 1px 3px;
    }
    
    .car-wear-label {
        font-size: 0.45rem;
        padding: 1px 3px;
    }
    
    /* Se till att race-main inte täcks av kontrollerna */
    .race-main {
        margin-bottom: 0;
    }
}

/* ========== RACE HISTORY ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.race-history-list {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

.race-history-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.race-history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    border-color: var(--accent-red);
}

.race-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.race-history-header h3 {
    color: var(--accent-red);
    margin: 0;
}

.race-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.race-history-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.my-result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.my-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
}

.race-history-leaderboard {
    margin: 1rem 0;
}

.race-history-leaderboard h4 {
    color: var(--accent-red);
    margin-bottom: 0.5rem;
}

.top-three {
    list-style: none;
    padding: 0;
}

.top-three li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--bg-input);
    border-radius: 4px;
    color: var(--text-primary);
}

.driver-name {
    flex: 1;
    font-weight: 500;
}

.points {
    color: var(--accent-red);
    font-weight: bold;
}

.no-races {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border-radius: 8px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* ========== RACE RESULT ========== */
.race-result-header {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.race-result-header h2 {
    color: var(--accent-red);
    margin-bottom: 0.5rem;
}

.race-date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.my-result-card {
    background: linear-gradient(135deg, var(--accent-red) 0%, #8b0000 100%);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 16px rgba(225, 6, 0, 0.3);
}

.my-result-card h3 {
    margin-bottom: 1rem;
    color: white;
}

.my-result-details {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.result-stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.position-badge.large {
    font-size: 2rem;
    padding: 0.5rem 1rem;
}

.race-result-table {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

.race-result-table h3 {
    color: var(--accent-red);
    margin-bottom: 1rem;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table thead {
    background: var(--accent-red);
}

.result-table th {
    padding: 1rem;
    text-align: left;
    font-weight: bold;
    color: white;
    border-bottom: 2px solid var(--border-color);
}

.result-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.result-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.my-result-row {
    background: rgba(225, 6, 0, 0.1) !important;
    font-weight: bold;
}

.race-result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.race-results-summary {
    margin: 1rem 0;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border-radius: 4px;
    color: var(--text-primary);
}

.result-item.my-result {
    background: rgba(225, 6, 0, 0.1);
    font-weight: bold;
}

.result-position {
    font-weight: bold;
    color: var(--accent-red);
    min-width: 30px;
}

.result-name {
    flex: 1;
}

.result-points {
    color: var(--accent-red);
    font-weight: bold;
}
