/* LFS Stats Viewer - Main Stylesheet */

/* Base Styles */
body {
    font-family: Arial, sans-serif;
    margin: 20px;
    background-color: #1a1a1a;
    color: #e0e0e0;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0;
    background: linear-gradient(160deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    position: relative;
}

.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #237da0, #a855f7, #ec4899, #f59e0b);
}

.header h1 {
    margin: 0;
    color: white;
    font-size: 1.6em;
    letter-spacing: 0.5px;
}

.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
    padding: 20px 24px;
    gap: 16px;
}

.header-logo-left {
    justify-self: start;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.header-title {
    text-align: center;
    justify-self: center;
}

.header-center {
    text-align: center;
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.header-logo-right {
    justify-self: end;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.track-subtitle {
    font-size: 15px;
    color: rgba(255,255,255,0.55);
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.lfs-logo {
    height: 100%;
    max-height: 160px;
    width: auto;
    opacity: 0.9;
    filter: drop-shadow(0 2px 8px rgba(102,126,234,0.4));
    transition: opacity 0.2s;
    object-fit: contain;
}
.lfs-logo:hover {
    opacity: 1;
}

.custom-logo {
    height: 100%;
    max-height: 160px;
    width: auto;
    opacity: 0.9;
    filter: drop-shadow(0 2px 8px rgba(168,85,247,0.4));
    transition: opacity 0.2s;
    object-fit: contain;
}
.custom-logo:hover {
    opacity: 1;
}

.track-image {
    height: 120px;
    border-radius: 8px;
}

.race-info {
    padding: 12px 24px 8px;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    line-height: 1.8;
}

.info-cards {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.info-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    font-size: 12.5px;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
}

.info-card .info-label {
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mpr-download {
    color: #a78bfa !important;
    text-decoration: none;
    transition: color 0.2s;
}
.mpr-download:hover {
    color: #c4b5fd !important;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    border-bottom: 2px solid #444;
}

.tab {
    cursor: pointer;
    padding: 12px 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s;
    font-weight: 500;
    font-size: 13px;
}

.tab:hover {
    background: #333;
}

.tab.active {
    background: #237da0;
    color: white;
    border-color: #237da0;
    transform: translateY(2px);
}

/* Content */
.content {
    display: none;
    animation: fadeIn 0.3s;
}

.content.active {
    display: block;
}

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

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #444;
}

th {
    background: #333;
    font-weight: bold;
    position: sticky;
    top: 0;
}

tr:hover {
    background: #333;
}

tr:last-child td {
    border-bottom: none;
}

/* Compact Table */
.compact-table {
    font-size: 13px;
}

.compact-table td {
    padding: 8px;
}

/* Lap by Lap Table */
.lbl-table {
    font-size: 11px;
    width: auto;
    white-space: nowrap;
}

.lbl-table th {
    min-width: 70px;
}

.driver-name-header {
    font-size: 13px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lbl-sticky-pos {
    position: sticky;
    left: 0;
    background: #2a2a2a;
    font-weight: bold;
    z-index: 2;
    min-width: 60px;
}

.lbl-sticky-driver {
    position: sticky;
    left: 60px;
    background: #2a2a2a;
    z-index: 2;
}

.lbl-sticky-header-pos {
    position: sticky;
    left: 0;
    background: #333;
    z-index: 3;
    min-width: 60px;
}

.lbl-sticky-header-driver {
    position: sticky;
    left: 60px;
    background: #333;
    z-index: 3;
}

.lap-cell {
    text-align: center;
    color: #000;
    min-width: 75px;
    font-size: 11px;
}

/* Position Cells */
.position {
    font-weight: bold;
    text-align: center;
}

.pos-1 { color: #FFD700; }
.pos-2 { color: #C0C0C0; }
.pos-3 { color: #CD7F32; }
.pos-4, .pos-5, .pos-6, .pos-7, .pos-8, .pos-9, .pos-10 { color: #F44336; }

/* Section Grid */
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(410px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.section-box {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #237da0;
    overflow-x: auto;
}

.section-box h3 {
    margin-top: 0;
    color: #237da0;
}

/* Graph Container */
#graph-container {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

#position-graph {
    display: block;
    margin: 0 auto;
    width: 100%;
    height: 800px;
    max-width: 100%;
}

/* Progress Graph Container */
#progress-graph-container {
    background: #2a2a2a;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

#progress-graph {
    display: block;
    margin: 0 auto;
    width: 100%;
    height: 700px;
    max-width: 100%;
}

/* Legend */
.legend {
    margin-top: 20px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 8px;
}

.legend h4 {
    margin-top: 0;
}

.legend-items {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-color-box {
    width: 50px;
    height: 20px;
}

/* Scrollable Container */
.scrollable-container {
    overflow-x: auto;
}

/* WR Info */
.wr-info {
    font-size: 12px;
    color: #FFD700;
    margin-bottom: 10px;
}

/* Highlight Colors */
.highlight-success {
    color: #4CAF50;
}

.highlight-warning {
    color: #FFA500;
}

.highlight-error {
    color: #F44336;
}

.highlight-info {
    color: #237da0;
}

/* Error Message */
.error-message {
    background: #2a2a2a;
    border-left: 4px solid #F44336;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    color: #F44336;
}

/* Links */
.link-primary {
    color: #237da0;
    text-decoration: none;
}

.link-primary:hover {
    text-decoration: underline;
}

.link-driver {
    color: #20F0C0;
    text-decoration: none;
    font-weight: bold;
}

.link-driver:hover {
    text-decoration: underline;
}

.car-link-with-image {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.car-thumbnail {
    height: 40px;
    width: auto;
    border-radius: 4px;
    vertical-align: middle;
}

/* Text Colors */
.text-success {
    color: #4CAF50;
    font-weight: bold;
}

.text-warning {
    color: #FFA500;
    font-weight: bold;
}

.text-error {
    color: #F44336;
    font-weight: bold;
}

.text-info {
    color: #2196F3;
    font-weight: bold;
}

.text-muted {
    color: #888;
}

.text-gold {
    color: #FFD700;
}

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

/* Font Sizes */
.text-small {
    font-size: 12px;
}

/* Margins */
.mb-10 {
    margin-bottom: 10px;
}

.mb-15 {
    margin-bottom: 15px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

/* Padding */
.p-20 {
    padding: 20px;
}

/* Color Boxes for Legend */
.color-box-100 {
    background: #7070FF;
}

.color-box-101 {
    background: #20F0C0;
}

.color-box-102 {
    background: #A0F00F;
}

.color-box-103 {
    background: #FFFF70;
}

.color-box-105 {
    background: #FFA070;
}

.color-box-107 {
    background: #FF5090;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #888;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        margin: 10px;
    }
    
    .section-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    .header-logo-left, .header-logo-right {
        justify-self: center;
    }
    .lfs-logo, .custom-logo {
        height: 80px;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px;
    }
}

/* Show More Button */
.show-more-btn {
    display: block;
    margin: 15px auto 0;
    padding: 10px 20px;
    background: #2a2a2a;
    color: #fff;
    border: solid 1px #444;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.show-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.show-more-btn:active {
    transform: translateY(0);
}

/* Hidden rows */
.expandable-row.hidden {
    display: none;
}

/* Position Graph Legend */
.graph-legend {
    display: flex !important;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    padding: 15px;
    background: #333 !important;
    border: 2px solid #555;
    border-radius: 5px;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s, opacity 0.2s;
}

.legend-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.legend-marker {
    font-weight: bold;
    font-size: 16px;
    min-width: 30px;
    text-align: center;
}

.pit-marker {
    color: #000000;
    background: #FFFFFF;
    border: 2px solid red;
    border-radius: 50%;
    width: 21px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.dnf-marker {
    color: #FF0000;
}

.lapped-marker {
    color: #888;
    letter-spacing: 2px;
}

.legend-text {
    color: #CCC;
}

.personal-best-marker {
    color: #00FF00;
    font-size: 18px;
}

.fastest-lap-marker {
    color: #FFD700;
    font-size: 18px;
}

/* Chat Messages */
.chat-container {
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.chat-message {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    align-items: baseline;
}

.chat-message:last-child {
    border-bottom: none;
}

.chat-number {
    color: #666;
    font-size: 11px;
    min-width: 30px;
    text-align: right;
}

.chat-driver {
    color: #FFD700;
    font-weight: bold;
    min-width: 150px;
}

.chat-text {
    color: #e0e0e0;
    flex: 1;
    word-wrap: break-word;
}

/* MPR Download Link */
.mpr-download {
    color: #4CAF50;
    text-decoration: none;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    transition: all 0.2s;
}

.mpr-download:hover {
    color: #66BB6A;
    background: rgba(76, 175, 80, 0.1);
}

/* Host flag badges */
.flags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 2px 0;
}
.flag-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 11px;
    white-space: nowrap;
    color: rgba(255,255,255,0.7);
}

/* Relay/stint separator */
.relay-separator {
    color: #888;
    margin: 0 2px;
}

/* Stint bar */
.stint-bar div {
    transition: opacity 0.2s;
    cursor: default;
}
.stint-bar div:hover {
    opacity: 0.8;
}

/* Stints grid layout */
.stints-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(410px, 1fr));
    gap: 12px;
}

/* Allowed cars in header */
.allowed-cars-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    flex-wrap: wrap;
}
.allowed-car-img img {
    height: 70px;
    border-radius: 4px;
    transition: transform 0.2s;
}
.allowed-car-img img:hover {
    transform: scale(1.3);
}
.allowed-car-text {
    color: #ccc;
    font-size: 0.85em;
    text-decoration: none;
    padding: 2px 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* Summary Card */
.summary-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    margin: 0 0 8px 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.08);
}
.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 8px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    transition: background 0.2s;
}
.summary-stat[data-goto-tab] {
    cursor: pointer;
}
.summary-stat:hover {
    background: rgba(255,255,255,0.08);
}
.summary-stat .stat-icon {
    font-size: 1.4em;
    margin-bottom: 4px;
}
.summary-stat .stat-value {
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    line-height: 1.3;
}
.summary-stat .stat-value a {
    color: #fff;
    text-decoration: none;
}
.summary-stat .stat-value a:hover {
    text-decoration: underline;
}
.summary-stat .stat-label {
    font-size: 0.75em;
    color: #999;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-stat .stat-detail {
    font-size: 0.8em;
    color: #bbb;
    margin-top: 2px;
}
.summary-stat .stat-value.purple {
    color: #A855F7;
}
@media (max-width: 600px) {
    .summary-card {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px;
        padding: 10px 12px;
    }
    .summary-stat { padding: 8px 4px; }
    .summary-stat .stat-value { font-size: 1em; }
}

/* Compare */
.compare-selectors {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
}
.compare-select {
    flex: 1;
    min-width: 160px;
    padding: 8px 12px;
    background: #1a1a2e;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
}
.compare-select:focus {
    outline: none;
    border-color: #237da0;
}
.compare-vs {
    font-weight: bold;
    color: #888;
    font-size: 0.9em;
}
.compare-btn {
    padding: 8px 20px;
    background: #237da0;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}
.compare-btn:hover {
    background: #1a6080;
}
.compare-table-wrap {
    overflow-x: auto;
    margin-bottom: 20px;
}
.compare-table {
    width: 100%;
    border-collapse: collapse;
}
.compare-table th, .compare-table td {
    padding: 8px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.compare-table th {
    background: rgba(255,255,255,0.04);
    white-space: nowrap;
}
.compare-label {
    text-align: left !important;
    color: #999;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.compare-best {
    color: #4CAF50 !important;
    font-weight: bold;
}
.compare-chart-wrap {
    height: 350px;
    margin-top: 16px;
}
@media (max-width: 600px) {
    .compare-selectors { flex-direction: column; }
    .compare-select { min-width: 100%; }
    .compare-vs { display: none; }
    .compare-chart-wrap { height: 250px; }
}

/* Custom Select (colored driver names) */
.csel {
    position: relative;
    flex: 1;
    min-width: 180px;
}
.csel-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    min-height: 20px;
    user-select: none;
}
.csel-selected:hover {
    border-color: #237da0;
}
.csel-arrow {
    color: #888;
    margin-left: 8px;
    font-size: 0.8em;
}
.csel-text {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.csel-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 0 0 6px 6px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.csel-options.open {
    display: block;
}
.csel-option {
    padding: 6px 12px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.85em;
    transition: background 0.15s;
}
.csel-option:hover {
    background: rgba(255,255,255,0.1);
}
.csel-pos {
    display: inline-block;
    min-width: 28px;
    color: #888;
    font-size: 0.85em;
}
@media (max-width: 600px) {
    .csel { min-width: 100%; }
}

/* Heatmap */
.heatmap-wrap {
    overflow-x: auto;
    margin-bottom: 12px;
}
.heatmap-table {
    border-collapse: separate;
    border-spacing: 1px;
    width: auto;
}
.heatmap-table thead th {
    background: rgba(255,255,255,0.06);
    padding: 4px 2px;
    font-size: 0.7em;
    color: #999;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
}
.heatmap-driver {
    position: sticky;
    left: 0;
    background: #121212 !important;
    z-index: 3;
    white-space: nowrap;
    padding: 4px 8px !important;
    font-size: 0.8em;
    min-width: 140px;
}
thead .heatmap-driver {
    z-index: 4;
}
.heatmap-pos {
    display: inline-block;
    min-width: 24px;
    text-align: center;
    font-size: 0.8em;
    margin-right: 4px;
}
.heatmap-cell {
    width: 18px;
    min-width: 18px;
    max-width: 18px;
    height: 18px;
    padding: 0 !important;
    cursor: default;
    border-radius: 2px;
    position: relative;
}
.heatmap-cell.heatmap-fastest {
    box-shadow: inset 0 0 0 2px #A855F7;
}
.heatmap-cell.heatmap-pb {
    box-shadow: inset 0 0 0 2px #4CAF50;
}
.heatmap-cell.heatmap-pit::after {
    content: 'P';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: rgba(0,0,0,0.7);
}
.heatmap-lap {
    min-width: 18px;
    max-width: 18px;
}
.heatmap-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 0;
    font-size: 0.8em;
    color: #999;
}
.heatmap-legend-fast { color: rgb(40,180,40); font-size: 1.3em; }
.heatmap-legend-mid { color: rgb(255,150,20); font-size: 1.3em; }
.heatmap-legend-slow { color: rgb(255,0,20); font-size: 1.3em; }
.heatmap-fastest-mark { color: #A855F7; font-size: 1.3em; }
.heatmap-pb-mark { color: #4CAF50; font-size: 1.3em; }
.heatmap-pit-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: #fff;
    color: #000;
    border-radius: 50%;
    font-size: 9px;
    font-weight: bold;
}
@media (max-width: 600px) {
    .heatmap-cell { width: 14px; min-width: 14px; max-width: 14px; height: 14px; }
    .heatmap-lap { min-width: 14px; max-width: 14px; }
    .heatmap-cell.heatmap-pit::after { font-size: 7px; }
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 20px 10px;
    margin-top: 30px;
    color: #a4a4a4;
    font-size: 1em;
    border-top: 1px solid rgba(255,255,255,0.05);
}
.site-footer #exported-at {
    font-size: 0.8em;
    color: #777;
    margin-top: 4px;
}

/* Podium colors - Results table only */
#results > table tr:has(.pos-1) { background: linear-gradient(90deg, rgba(255,215,0,0.25) 0%, transparent 100%); }
#results > table tr:has(.pos-2) { background: linear-gradient(90deg, rgba(192,192,192,0.25) 0%, transparent 100%); }
#results > table tr:has(.pos-3) { background: linear-gradient(90deg, rgba(205,127,50,0.25) 0%, transparent 100%); }
#results > table .pos-1,
#results > table .pos-2,
#results > table .pos-3 {
    color: white;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    font-weight: bold;
}

/* File drop zone */
#file-drop-zone {
    border: 2px dashed #555;
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 500px;
    margin: 80px auto;
}
#file-drop-zone:hover,
#file-drop-zone.drag-over {
    border-color: #237da0;
    background: rgba(35, 125, 160, 0.1);
}
#file-drop-zone .drop-icon {
    font-size: 48px;
    margin-bottom: 16px;
}
#file-drop-zone h2 {
    margin: 0 0 12px 0;
    color: #fff;
}
#file-drop-zone p {
    margin: 4px 0;
    color: #ccc;
}
