/* ========================================
   Skiframes.com - Main Stylesheet
   ======================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

/* ========================================
   Header
   ======================================== */

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
}

.nav {
    display: flex;
    gap: 24px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-link.live-btn {
    background: #dc2626;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    animation: pulse-bg 2s ease-in-out infinite;
}

.nav-link.live-btn:hover {
    background: #b91c1c;
    color: white;
}

.nav-link.live-btn .live-dot {
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    animation: blink 1s ease-in-out infinite;
}

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

@keyframes pulse-bg {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ========================================
   Hero Section
   ======================================== */

.hero {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 60px 24px;
    text-align: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 16px;
}

.hero p {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 32px;
}

.hero-search {
    display: flex;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    flex: 1;
    padding: 16px 20px;
    font-size: 16px;
    border: none;
    border-radius: var(--radius);
    outline: none;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--background);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-downloading {
    background: var(--warning) !important;
    color: white !important;
    cursor: wait !important;
}

/* ========================================
   Filters Bar
   ======================================== */

.filters-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
}

.filters-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filter-input,
.filter-select {
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-width: 150px;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
}

.search-group {
    flex: 1;
    min-width: 250px;
}

.search-group .search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ========================================
   Sections
   ======================================== */

.section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 28px;
    font-weight: 700;
}

.view-all {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* ========================================
   Events Grid
   ======================================== */

.events-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.event-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}

.event-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.event-card-image {
    height: 180px;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.event-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-card-image img.event-card-logo {
    width: auto;
    height: 140px;
    object-fit: contain;
}

.event-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.event-badge.race {
    background: var(--primary);
    color: white;
}

.event-badge.training {
    background: var(--success);
    color: white;
}

.event-badge.discipline {
    background: var(--warning);
    color: white;
    left: auto;
    right: 12px;
}

.event-badge.camera {
    background: #2563eb;
    color: white;
    left: auto;
    right: 12px;
    top: 40px;
}

.event-card-content {
    padding: 20px;
}

.event-card-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.event-card-meta {
    color: var(--text-secondary);
    font-size: 14px;
}

.event-card-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

/* Simple Event List */
.event-list-item {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 16px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.event-list-item:hover {
    background: var(--background);
}
.event-list-name {
    font-weight: 600;
    color: var(--primary);
    flex: 1;
    min-width: 200px;
}
.event-list-meta {
    font-size: 14px;
    color: var(--text-secondary);
}
.event-list-stats {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Event Row with Tags */
.event-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, box-shadow 0.15s;
}

.event-row:hover {
    background: var(--background);
    box-shadow: var(--shadow);
}

.event-row-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 70px;
}

.event-row-name {
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 180px;
}

.event-row-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.event-tag-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Event type tags */
.event-tag-pill.type-race {
    background: #dbeafe;
    color: #1d4ed8;
}

.event-tag-pill.type-gate_training,
.event-tag-pill.type-training {
    background: #dcfce7;
    color: #16a34a;
}

.event-tag-pill.type-free_skiing {
    background: #fef3c7;
    color: #d97706;
}

.event-tag-pill.type-test {
    background: #ede9fe;
    color: #7c3aed;
}

/* Discipline tags */
.event-tag-pill.disc-sl {
    background: #fce7f3;
    color: #be185d;
}

.event-tag-pill.disc-gs {
    background: #cffafe;
    color: #0891b2;
}

.event-tag-pill.disc-sg {
    background: #fee2e2;
    color: #dc2626;
}

.event-tag-pill.disc-freeski {
    background: #fef3c7;
    color: #d97706;
}

/* Category tags */
.event-tag-pill.category {
    background: #f3f4f6;
    color: #374151;
}

/* Team tags */
.event-tag-pill.team {
    background: #e0e7ff;
    color: #4338ca;
}

/* Location */
.event-row-location {
    font-size: 12px;
    color: var(--text-secondary);
}

.event-row-counts {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-left: auto;
    text-align: right;
}

/* Grouped event row with sub-buttons */
.event-row-grouped {
    cursor: default;
}

.event-sub-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.event-sub-btn {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.event-sub-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .event-row {
        padding: 10px 12px;
    }

    .event-row-date {
        min-width: 60px;
        font-size: 12px;
    }

    .event-row-name {
        font-size: 14px;
        min-width: 140px;
    }

    .event-tag-pill {
        padding: 2px 8px;
        font-size: 10px;
    }

    .event-row-location {
        width: 100%;
        margin-top: 4px;
    }

    .event-sub-buttons {
        width: 100%;
        margin-top: 8px;
        margin-left: 0;
    }

    .event-sub-btn {
        padding: 6px 14px;
    }
}

/* ========================================
   Search Results
   ======================================== */

.search-results-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-section-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 16px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.search-section-header:first-child {
    margin-top: 0;
}

.search-result-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.search-result-logo {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    border-radius: 8px;
    overflow: hidden;
}

.search-result-logo img {
    width: auto;
    height: 60px;
    object-fit: contain;
}

.search-result-info {
    flex: 1;
}

.search-result-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.search-result-meta {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.search-result-event {
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
}

.search-result-location {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 2px;
}

/* ========================================
   Event Page Header
   ======================================== */

.event-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 40px 24px;
}

.event-header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
}

.event-logo {
    width: 150px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.event-header h1 {
    font-size: 36px;
    margin-top: 12px;
}

.event-meta {
    opacity: 0.9;
    margin-top: 8px;
}

/* ========================================
   Tabs
   ======================================== */

.tabs {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.tab {
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ========================================
   Content Section
   ======================================== */

.content-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.view-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.view-btn {
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.sort-label {
    margin-left: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.sort-buttons {
    display: flex;
    gap: 4px;
}

.sort-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sort-btn:hover {
    background: var(--background);
    color: var(--text);
}

.sort-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.fps-filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.fps-filter-buttons {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.fps-filter-btn {
    padding: 4px 8px;
    font-size: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-weight: 500;
}

.fps-filter-btn:hover {
    background: var(--background);
    color: var(--text);
}

.fps-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.results-count {
    margin-left: auto;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========================================
   Content Grid
   ======================================== */

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.content-grid.list-view {
    grid-template-columns: 1fr;
}

/* Video Card */
.video-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.video-thumbnail {
    position: relative;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #1f2937;
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.video-comparison-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--warning);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.video-card-content {
    padding: 16px;
}

.video-card-content h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.athlete-link {
    color: inherit;
    text-decoration: none;
}

.athlete-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.video-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.video-card-time {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-top: 4px;
}

.video-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.video-card-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* Video Table */
.video-table-container {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.video-table th,
.video-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.video-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.video-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.video-table tbody tr:hover {
    background: var(--background);
}

.video-table tbody tr.search-highlight {
    background: rgba(59, 130, 246, 0.15);
    animation: highlight-pulse 2s ease-in-out;
}

.video-table tbody tr.search-highlight:hover {
    background: rgba(59, 130, 246, 0.25);
}

@keyframes highlight-pulse {
    0% { background: rgba(59, 130, 246, 0.4); }
    100% { background: rgba(59, 130, 246, 0.15); }
}

.video-table tbody tr:last-child td {
    border-bottom: none;
}

.col-select {
    width: 40px;
    text-align: center;
}

.col-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.col-rank {
    width: 60px;
    font-weight: 600;
}

.col-bib {
    width: 60px;
}

.col-athlete {
    font-weight: 500;
}

.col-ussa {
    width: 50px;
}

.ussa-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

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

.col-gender {
    width: 50px;
    padding-right: 20px;
}

.col-bib {
    width: 60px;
    padding-right: 20px;
}

.col-team {
    width: 80px;
    padding-right: 30px;
}

.col-time {
    width: 100px;
    padding-right: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.col-actions {
    width: 180px;
    text-align: right;
}

.col-actions button {
    padding: 6px 12px;
    margin-left: 6px;
}

.btn-ghost {
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
}

.btn-ghost:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
}

.ghost-race-btn {
    font-size: 12px;
}

.gender-header td {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    font-weight: 700;
    font-size: 16px;
    color: white;
    padding: 12px 20px;
    border-bottom: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

/* Montage Speed Filter */
.speed-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 16px;
}

.speed-buttons {
    display: flex;
    gap: 4px;
}

.speed-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.speed-btn:hover {
    background: var(--background);
    color: var(--text);
}

.speed-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Fastest Toggle */
.fastest-toggle {
    margin-left: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.fastest-toggle.active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Montage Time Overlay */
.montage-thumbnail {
    position: relative;
}

.montage-time-overlay {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.montage-fastest-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.montage-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    padding: 0;
    padding-left: 3px; /* Visual center for play triangle */
    z-index: 2;
}

.montage-thumbnail:hover .montage-play-btn {
    opacity: 1;
}

.montage-play-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: white;
}

/* Trajectory (TR) button */
.montage-tr-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #f59e0b;
    color: #000;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    z-index: 3;
    letter-spacing: 0.5px;
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}

.montage-tr-btn:hover {
    background: #fbbf24;
    transform: scale(1.1);
}

/* Montage Compare (side-by-side) */
.montage-card-compare {
    grid-column: span 2;
}

.montage-compare-row {
    display: flex;
    gap: 2px;
}

.montage-thumb-half {
    flex: 1;
    min-width: 0;
}

.montage-thumb-half img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Montage Card */
.montages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 0 20px;
}

.montage-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
}

.montage-card:hover {
    transform: scale(1.02);
}

.montage-thumbnail {
    aspect-ratio: 3/4;
    background: #1f2937;
    position: relative;
}

.montage-fps-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.montage-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.montage-card-content {
    padding: 12px;
}

.montage-card-content p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Download Bar
   ======================================== */

.download-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
}

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

.download-actions {
    display: flex;
    gap: 8px;
}

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 50;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--background);
}

/* ========================================
   Modals
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
}

.video-modal-content {
    width: 900px;
}

.video-container {
    background: black;
}

.video-container video {
    width: 100%;
    max-height: 70vh;
}

.video-info {
    padding: 20px;
}

.video-info h3 {
    margin-bottom: 4px;
}

.video-info p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.video-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.video-controls .divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.image-modal-content {
    max-width: 1200px;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
}

.image-info {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ========================================
   Fullscreen Montage Viewer
   ======================================== */

.montage-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: #000;
}

.montage-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    z-index: 10;
    flex-shrink: 0;
}

.montage-viewer-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.montage-viewer-title h3 {
    font-size: 15px;
    font-weight: 600;
    color: white;
    margin: 0;
}

.montage-counter {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.montage-viewer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.montage-compare-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.montage-compare-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.montage-compare-btn.active {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

/* FPS variant buttons in fullscreen viewer */
.viewer-fps-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 8px;
}

.viewer-fps-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.viewer-fps-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.viewer-fps-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.montage-viewer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.montage-viewer-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.montage-viewer-body {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}

.montage-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 36px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s;
    user-select: none;
}

.montage-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.montage-nav:disabled {
    opacity: 0.15;
    cursor: default;
}

.montage-nav-prev { left: 12px; }
.montage-nav-next { right: 12px; }

.montage-display {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    gap: 4px;
    padding: 0 72px;
}

.montage-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    min-width: 0;
}

.montage-panel img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.montage-display:not(.split-view) .montage-panel-current {
    flex: 1;
}

.montage-display.split-view .montage-panel {
    flex: 1;
}

.montage-panel-label {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #16a34a;
    color: white;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    z-index: 5;
}

.montage-panel-info {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    z-index: 5;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .montage-viewer-toolbar {
        flex-direction: column;
        gap: 6px;
        padding: 8px 12px;
    }
    .montage-display {
        padding: 0 48px;
    }
    .montage-display.split-view {
        flex-direction: column;
        gap: 2px;
    }
    .montage-nav {
        width: 36px;
        height: 60px;
        font-size: 28px;
    }
    .montage-nav-prev { left: 4px; }
    .montage-nav-next { right: 4px; }
}

/* ========================================
   Download Progress
   ======================================== */

.download-progress {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    width: 320px;
    z-index: 1000;
}

.download-progress h4 {
    margin-bottom: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.download-progress p {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========================================
   Footer
   ======================================== */

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    text-align: center;
    margin-top: 60px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer p {
    color: var(--text-secondary);
    font-size: 14px;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: var(--primary);
    text-decoration: none;
}

.separator {
    margin: 0 8px;
    color: var(--border);
}

/* ========================================
   Loading State
   ======================================== */

.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state {
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .logo-img {
        height: 32px;
    }

    .logo-text {
        font-size: 18px;
    }

    /* Smaller hero on mobile */
    .hero {
        padding: 24px 16px;
    }

    .hero h1 {
        font-size: 22px;
        margin-bottom: 8px;
    }

    .hero p {
        font-size: 14px;
        margin-bottom: 16px;
    }

    .hero-search {
        flex-direction: column;
        gap: 8px;
    }

    .search-input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .btn-primary {
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Compact filters bar on mobile */
    .filters-bar {
        padding: 12px 16px;
    }

    .filters-content {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 8px;
    }

    /* Hide date, category, type filters on mobile - only show team */
    .filter-group:has(#dateFilter),
    .filter-group:has(#categoryFilter),
    .filter-group:has(#typeFilter) {
        display: none;
    }

    .filter-group:has(#teamFilter) {
        flex: 1;
        min-width: 0;
    }

    .filter-group label {
        font-size: 11px;
    }

    .filter-select,
    .filter-input {
        padding: 8px 10px;
        font-size: 13px;
        min-width: 0;
    }

    #clearFilters {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Sections */
    .section {
        padding: 24px 16px;
    }

    .section-header h2 {
        font-size: 22px;
    }

    /* Event list */
    .events-grid {
        gap: 0;
    }

    .event-card-image {
        height: 140px;
    }

    .event-card-content {
        padding: 16px;
    }

    .event-card-content h3 {
        font-size: 16px;
    }

    .download-content {
        flex-direction: column;
        gap: 12px;
    }

    .download-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .video-modal-content {
        width: 100%;
        border-radius: 0;
    }

    .video-controls {
        justify-content: center;
    }

    .video-controls .divider {
        display: none;
    }
}

/* ========================================
   Athlete Re-Identification View
   ======================================== */

.montage-view-toggle {
    display: flex;
    gap: 2px;
    margin-right: 16px;
    background: var(--border);
    border-radius: var(--radius);
    padding: 2px;
}

.view-btn {
    padding: 5px 14px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius) - 2px);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.view-btn:hover {
    color: var(--text);
}

.view-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.athlete-view {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.athlete-sensitivity {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.athlete-sensitivity input[type="range"] {
    width: 200px;
    accent-color: var(--primary);
}

.athlete-sensitivity span {
    font-weight: 600;
    color: var(--text);
}

.athlete-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.athlete-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.15s;
}

.athlete-card-header:hover {
    background: var(--background);
}

.athlete-avatar {
    width: 56px;
    height: 72px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--background);
}

.athlete-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.athlete-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
}

.athlete-label {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    outline: none;
    border-bottom: 1px dashed transparent;
    cursor: text;
    line-height: 1.3;
}

.athlete-label:hover {
    border-bottom-color: var(--border);
}

.athlete-label:focus {
    border-bottom-color: var(--primary);
}

.athlete-run-count,
.athlete-best-time {
    font-size: 13px;
    color: var(--text-secondary);
}

.athlete-best-time {
    font-weight: 500;
    color: #16a34a;
}

.athlete-expand-icon {
    font-size: 14px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform 0.2s;
    user-select: none;
}

.athlete-runs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 0 20px 16px;
}

.athlete-runs .montage-card {
    cursor: pointer;
}

/* Drag and drop states */
.montage-card.dragging {
    opacity: 0.5;
}

.athlete-card.drag-target {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background: #eff6ff;
}

.athlete-card.drag-target .athlete-card-header {
    background: #dbeafe;
}

/* Responsive */
@media (max-width: 768px) {
    .montage-view-toggle {
        margin-right: 8px;
    }

    .athlete-sensitivity input[type="range"] {
        width: 120px;
    }

    .athlete-runs {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* ========================================
   Virtual Race Modal
   ======================================== */

.vr-open-btn {
    margin-left: auto;
}

.virtual-race-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    background: #111;
}

.vr-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    flex-shrink: 0;
    z-index: 10;
}

.vr-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.vr-mode-tabs {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 2px;
}

.vr-mode-tab {
    padding: 6px 18px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}

.vr-mode-tab:hover:not(.disabled) {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.vr-mode-tab.active {
    background: var(--primary);
    color: white;
}

.vr-mode-tab.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.vr-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.vr-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Athlete selectors row */
.vr-selectors {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.7);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.vr-selector-group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.vr-selector-group label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.vr-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 13px;
    font-weight: 500;
    min-width: 0;
    flex: 1;
    max-width: 240px;
    cursor: pointer;
}

.vr-select:focus {
    outline: none;
    border-color: var(--primary);
}

.vr-select option {
    background: #222;
    color: white;
}

.vr-vs {
    color: rgba(255, 255, 255, 0.35);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.vr-diff {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 3px 10px;
    border-radius: 4px;
    min-width: 70px;
    text-align: center;
    flex-shrink: 0;
}

.vr-diff-behind {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.vr-diff-ahead {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

/* Content area */
.vr-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

.vr-empty {
    color: rgba(255, 255, 255, 0.4);
    font-size: 18px;
    font-weight: 500;
}

.vr-panels {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 8px;
}

.vr-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.vr-panel-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    z-index: 5;
    white-space: nowrap;
}

.vr-video-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    min-height: 0;
}

.vr-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.vr-montage-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    min-height: 0;
}

.vr-montage-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.vr-panel-info {
    text-align: center;
    color: white;
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 6px 0;
    flex-shrink: 0;
}

.vr-panel-meta {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 8px;
}

/* Playback controls bar */
.vr-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.9);
    flex-shrink: 0;
}

.vr-controls .btn {
    padding: 6px 14px;
    font-size: 13px;
}

.vr-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.vr-speed-btn {
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.vr-speed-btn:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.vr-speed-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.vr-time-display {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
}

/* Responsive */
@media (max-width: 480px) {
    .vr-selectors {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .vr-select {
        min-width: 160px;
        font-size: 13px;
    }

    .vr-panels {
        flex-direction: column;
    }

    .vr-controls {
        flex-wrap: wrap;
        gap: 6px;
    }

    .vr-vs {
        display: none;
    }
}
