/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --purple: #a855f7;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 320px;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid #00d289;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.back-to-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #00d289;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.back-to-main:hover {
    background: #00b575;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 210, 137, 0.3);
}

.back-to-main i {
    width: 16px;
    height: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: #00d289;
}

.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.logo-text span {
    font-size: 12px;
    color: var(--gray-400);
}

.credits {
    font-size: 12px;
    color: var(--gray-400);
}

.credits p {
    margin-bottom: 2px;
}

.credits a {
    color: #00d289;
    text-decoration: none;
    transition: color 0.3s ease;
}

.credits a:hover {
    color: #00b575;
}

.sidebar-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

/* Control Groups */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Icons */
.icon-sm {
    width: 14px;
    height: 14px;
}

/* File Upload */
.file-upload {
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--gray-50);
}

.file-upload:hover {
    border-color: var(--primary);
    background: white;
}

.file-upload.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    width: 32px;
    height: 32px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.file-upload p {
    font-size: 13px;
    color: var(--gray-500);
}

.file-upload .link {
    color: var(--primary);
    font-weight: 500;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-500);
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
}

.status.success {
    color: #16a34a;
    background: #f0fdf4;
}

.status.error {
    color: var(--danger);
    background: #fef2f2;
}

/* Filter Rows */
.filter-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-row label {
    font-size: 12px;
    color: var(--gray-600);
}

.filter-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 13px;
    background: white;
    color: var(--gray-800);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.filter-row select:hover:not(:disabled) {
    border-color: var(--gray-400);
}

.filter-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-row select:disabled {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    transition: background 0.2s ease;
}

.radio-label:hover {
    background: var(--gray-100);
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Info Box */
.info-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    padding: 12px;
}

.info-row {
    font-size: 12px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.info-row:last-child {
    margin-bottom: 0;
}

/* Legend */
.legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-600);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
    overflow: hidden;
    height: 100vh;
}

/* Chart Container */
.chart-container {
    flex: 0 0 55%;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 16px;
    position: relative;
    min-height: 250px;
    max-height: 55vh;
}

.chart-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
}

.chart-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--gray-400);
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chart-placeholder p {
    font-size: 14px;
}

.crosshair-label {
    position: absolute;
    left: 60px;
    background: var(--gray-800);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.crosshair-label.visible {
    opacity: 1;
}

/* Table Container */
.table-container {
    flex: 1;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.table-header h3 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.skater-count {
    font-size: 12px;
    color: var(--gray-500);
}

.table-wrapper {
    overflow-y: auto;
    flex: 1;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    background: var(--gray-50);
    z-index: 1;
}

th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

th:first-child {
    width: 60px;
}

th:nth-child(3),
th:nth-child(4) {
    width: 70px;
    text-align: center;
}

th:last-child {
    width: 90px;
    text-align: right;
}

td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}

td:nth-child(3),
td:nth-child(4) {
    text-align: center;
}

td:last-child {
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 12px;
}

tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

tbody tr:hover {
    background: var(--gray-50);
}

tbody tr.selected {
    background: rgba(59, 130, 246, 0.1);
}

tbody tr.empty-row {
    cursor: default;
}

tbody tr.empty-row:hover {
    background: transparent;
}

tbody tr.empty-row td {
    text-align: center;
    color: var(--gray-400);
    padding: 40px;
}

/* Row Colors */
tr.color-lightgreen {
    background: rgba(74, 222, 128, 0.15);
}

tr.color-lightgreen:hover {
    background: rgba(74, 222, 128, 0.25);
}

tr.color-yellow {
    background: rgba(251, 191, 36, 0.15);
}

tr.color-yellow:hover {
    background: rgba(251, 191, 36, 0.25);
}

tr.color-purple {
    background: rgba(168, 85, 247, 0.15);
}

tr.color-purple:hover {
    background: rgba(168, 85, 247, 0.25);
}

tr.color-red {
    background: rgba(239, 68, 68, 0.15);
}

tr.color-red:hover {
    background: rgba(239, 68, 68, 0.25);
}

tr.separator-row {
    background: var(--gray-100);
    cursor: default;
}

tr.separator-row:hover {
    background: var(--gray-100);
}

tr.separator-row td {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }

    .main-content {
        min-height: 50vh;
    }
}

/* Legend Dot Colors */
.legend-dot-success {
    background: var(--success);
}

.legend-dot-warning {
    background: var(--warning);
}

.legend-dot-purple {
    background: var(--purple);
}

.legend-dot-danger {
    background: var(--danger);
}

.legend-dot-gray {
    background: var(--gray-500);
}

/* Info Box Hidden State */
.info-box-hidden {
    display: none;
}

/* Chart Placeholder States */
.chart-placeholder-hidden {
    display: none;
}
