/**
 * Multi-Camera Calibration Studio - Styles
 */

* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    background: #1a1a1a;
    color: #e0e0e0;
}

h1, h2, h3 { margin-bottom: 0.5rem; color: #fff; }
.description { color: #aaa; margin-top: 0; }

/* Pipeline stages */
.stage {
    background: #2a2a2a;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #444;
}
.stage-header {
    background: #333;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #444;
}
.stage-header:hover { background: #3a3a3a; }
.stage-header h2 { margin: 0; font-size: 18px; }
.stage-number {
    background: #667eea;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    margin-right: 12px;
}
.stage-title {
    display: flex;
    align-items: center;
}
.stage-status {
    font-size: 12px;
    color: #888;
}
.stage-status.complete { color: #4ade80; }
.stage-status.active { color: #667eea; }
.stage-status.error { color: #ff6b6b; }
.stage-content {
    padding: 20px;
}
.stage.collapsed .stage-content { display: none; }
.stage-expand {
    color: #888;
    font-size: 20px;
    transition: transform 0.2s;
}
.stage.collapsed .stage-expand { transform: rotate(-90deg); }

/* Video grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}
.video-cell {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: zoom-in;
}
.video-cell.zoomed {
    cursor: grab;
}
.video-cell.zoomed.panning {
    cursor: grabbing;
}
.video-cell canvas {
    width: 100%;
    height: auto;
    display: block;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}
.video-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
}
.video-metrics {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: #aaa;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
}

/* Controls */
.controls {
    background: #333;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
button:hover { background: #5568d3; }
button:disabled { background: #444; cursor: not-allowed; }
button.secondary {
    background: #444;
}
button.secondary:hover { background: #555; }
button.active {
    background: #4ade80;
    color: #1a1a1a;
}
button.active:hover { background: #22c55e; }

/* Progress indicator */
.progress-container {
    display: none;
    flex: 1;
    min-width: 150px;
    max-width: 300px;
    background: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
    height: 32px;
    position: relative;
}
.progress-container.active {
    display: block;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.15s ease-out;
    border-radius: 6px;
}
.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Overlay controls */
.overlay-controls {
    background: #333;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 8px 0;
}
.overlay-controls h3 {
    margin: 0 0 6px 0 !important;
    font-size: 11px;
    color: #888;
}
.overlay-checkboxes {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: center;
}
.overlay-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 11px;
    color: #ccc;
    white-space: nowrap;
}
.overlay-checkbox:hover {
    color: #fff;
}
.overlay-checkbox input[type="checkbox"] {
    width: 12px;
    height: 12px;
    accent-color: #667eea;
    cursor: pointer;
}

/* Seekbar */
.seekbar-container {
    background: #333;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
}
.seekbar {
    width: 100%;
    height: 10px;
    background: #444;
    border-radius: 5px;
    position: relative;
    cursor: pointer;
}
.seekbar-progress {
    height: 100%;
    background: #667eea;
    border-radius: 5px;
    width: 0%;
    pointer-events: none;
}
.seekbar-thumb {
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.frame-info {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 13px;
    color: #aaa;
    font-family: monospace;
}

/* Config panel */
.config-panel {
    background: #333;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
}
.config-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 10px 0;
}
.config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.config-item label {
    color: #aaa;
    font-size: 13px;
}
.config-item input, .config-item select {
    background: #1a1a1a;
    border: 1px solid #444;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
}
.config-item input[type="number"] {
    width: 80px;
}

/* Diagnostic console */
.diagnostic-console {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    margin: 15px 0;
    font-family: monospace;
    font-size: 11px;
}
.diagnostic-header {
    background: #2a2a2a;
    padding: 8px 15px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.diagnostic-header h3 { margin: 0; font-size: 12px; }
.diagnostic-header button {
    background: #444;
    padding: 4px 10px;
    font-size: 11px;
}
.diagnostic-body {
    height: 150px;
    overflow-y: auto;
    padding: 10px 15px;
}
.log-entry { margin: 2px 0; display: flex; gap: 10px; }
.log-time { color: #666; flex-shrink: 0; }
.log-msg { color: #aaa; }
.log-msg.info { color: #667eea; }
.log-msg.success { color: #4ade80; }
.log-msg.warn { color: #fbbf24; }
.log-msg.error { color: #ff6b6b; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 15px 0;
}
.data-table th {
    background: #333;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid #444;
}
.data-table td {
    padding: 10px;
    border-bottom: 1px solid #333;
}
.data-table tr:hover { background: #333; }
.data-table tr.selected { background: #3d4a6b; }

/* Hotkeys */
.hotkeys {
    background: #333;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 13px;
}
.hotkeys h3 { margin-top: 0; }
.hotkeys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}
.hotkey {
    display: flex;
    gap: 10px;
}
.hotkey-key {
    color: #667eea;
    font-family: monospace;
    min-width: 80px;
}
.hotkey-desc { color: #aaa; }

/* Loading overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}
.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #444;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error message */
.error-msg {
    background: #4a2020;
    border: 1px solid #ff6b6b;
    color: #ff6b6b;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: none;
}

/* File input styling */
.file-drop-zone {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    color: #888;
    margin: 15px 0;
    cursor: pointer;
    transition: all 0.2s;
}
.file-drop-zone:hover, .file-drop-zone.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}
.file-drop-zone input { display: none; }

/* View config */
.view-list {
    margin: 15px 0;
}
.view-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: #333;
    border-radius: 6px;
    margin: 8px 0;
}
.view-item .view-name {
    flex: 1;
    font-weight: 600;
}
.view-item .view-path {
    color: #888;
    font-size: 12px;
    font-family: monospace;
}
.view-item .view-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #444;
}
.view-item .view-status.loaded { background: #4ade80; }
.view-item .view-status.loading { background: #fbbf24; }
.view-item .view-status.error { background: #ff6b6b; }

/* Split layout - floating video panel on left, scrollable pipeline on right */
.main-layout {
    display: flex;
    gap: 0;
}
.video-panel {
    position: sticky;
    top: 20px;
    width: 50%;
    flex-shrink: 0;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding-right: 10px;
}
.resize-handle {
    width: 12px;
    flex-shrink: 0;
    background: #2a2a2a;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 50vh;
    transform: translateY(-50%);
    height: 60px;
    border-radius: 4px;
    transition: background 0.15s;
}
.resize-handle:hover, .resize-handle.dragging {
    background: #3a3a3a;
}
.resize-handle-dots {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.resize-handle-dots span {
    width: 4px;
    height: 4px;
    background: #666;
    border-radius: 50%;
}
.resize-handle:hover .resize-handle-dots span,
.resize-handle.dragging .resize-handle-dots span {
    background: #888;
}
.main-layout.resizing {
    user-select: none;
    cursor: col-resize;
}
.video-panel::-webkit-scrollbar {
    width: 6px;
}
.video-panel::-webkit-scrollbar-track {
    background: #1a1a1a;
}
.video-panel::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
.pipeline-panel {
    flex: 1;
    min-width: 0;
    padding-left: 10px;
}
.video-panel .video-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 10px 0;
}
.video-panel .video-label {
    font-size: 11px;
    padding: 2px 6px;
}
.video-panel .video-metrics {
    font-size: 9px;
    padding: 2px 6px;
}
.video-panel .seekbar-container {
    padding: 10px 12px;
    margin: 8px 0;
}
.video-panel .controls {
    padding: 10px 12px;
    margin: 8px 0;
    gap: 6px;
}
.video-panel .controls button {
    padding: 6px 10px;
    font-size: 12px;
}
.video-panel .frame-info {
    font-size: 11px;
}
.video-panel h3 {
    font-size: 14px;
    margin: 10px 0 5px 0;
}
.video-panel-header {
    background: #333;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}
.video-panel-header h2 {
    margin: 0;
    font-size: 16px;
}
.video-panel-header p {
    margin: 5px 0 0 0;
    font-size: 12px;
    color: #888;
}

/* Hide video panel and resize handle when no videos loaded */
.video-panel.hidden {
    display: none;
}
.main-layout.no-videos .resize-handle {
    display: none;
}
/* Adjust pipeline panel when video panel is hidden */
.main-layout.no-videos .pipeline-panel {
    max-width: 900px;
    margin: 0 auto;
}

/* Frame Exclusion Gallery */
.exclusion-gallery {
    background: #252525;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
}
.exclusion-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.exclusion-gallery-header h3 {
    margin: 0;
    font-size: 14px;
    color: #fff;
}
.exclusion-stats {
    font-size: 12px;
    color: #888;
}
.exclusion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}
.exclusion-grid::-webkit-scrollbar {
    width: 6px;
}
.exclusion-grid::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}
.frame-thumbnail {
    position: relative;
    aspect-ratio: 4/3;
    background: #1a1a1a;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(74, 222, 128, 0.3);
    transition: all 0.15s;
}
.frame-thumbnail:hover {
    border-color: rgba(74, 222, 128, 0.7);
}
.frame-thumbnail.current {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.4);
}
.frame-thumbnail.excluded {
    opacity: 0.4;
    border-color: rgba(239, 68, 68, 0.5);
}
.frame-thumbnail.excluded:hover {
    opacity: 0.7;
    border-color: rgba(239, 68, 68, 0.9);
}
.frame-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.frame-thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 12px 4px 4px 4px;
    font-size: 10px;
    color: #fff;
    text-align: center;
}
.frame-thumbnail-error {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 3px;
}
.frame-thumbnail-cross-warning {
    position: absolute;
    bottom: 22px;
    left: 4px;
    background: rgba(251, 191, 36, 0.9);
    color: #000;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
    white-space: nowrap;
}

/* Exclusion toggle in table */
.exclude-toggle {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.exclude-toggle:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}
.exclude-toggle.excluded {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    color: #ff6b6b;
}
.data-table tr.excluded-row {
    opacity: 0.5;
    background: rgba(239, 68, 68, 0.1);
}
.data-table tr.excluded-row:hover {
    opacity: 0.7;
}

/* Quick exclusion controls */
.exclusion-controls {
    background: #333;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.exclusion-controls button.exclude-btn {
    background: #dc2626;
}
.exclusion-controls button.exclude-btn:hover {
    background: #b91c1c;
}
.exclusion-controls button.include-btn {
    background: #16a34a;
}
.exclusion-controls button.include-btn:hover {
    background: #15803d;
}
.exclusion-controls .exclusion-hint {
    color: #888;
    font-size: 11px;
}

/* Swarm plot excluded dot styling */
.swarm-dot-excluded {
    opacity: 0.3;
}
