:root {
  --bg: #0a0a0a;
  --bg-panel: #1a1a1a;
  --bg-card: #252525;
  --text: #e8e8e8;
  --text-muted: #888888;
  --accent: #e82127;
  --accent-hover: #ff3b3b;
  --border: #333333;
  --success: #00d26a;
  --warning: #ffc107;
}

/* ===== GLOBAL PROGRESS BAR ===== */
.global-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s,
    height 0.3s;
}

.global-progress-bar.active {
  opacity: 1;
  height: 28px;
}

.global-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00d26a, #00f5a0, #00d26a, #00b35e);
  background-size: 300% 100%;
  animation: progressShine 2s linear infinite;
  transition: width 0.2s ease-out;
}

.global-progress-bar.active .global-progress-fill {
  box-shadow: 0 0 15px rgba(0, 210, 106, 0.6);
}

.global-progress-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  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);
  opacity: 0;
  transition: opacity 0.3s;
}

.global-progress-bar.active .global-progress-text {
  opacity: 1;
}

@keyframes progressShine {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.global-progress-bar.complete .global-progress-fill {
  background: var(--success);
  animation: none;
}

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

html,
body {
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ===== LAYOUT ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1rem;
}

/* Header */
.header {
  text-align: center;
  padding: 0.75rem 0;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--accent), #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header .subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.lang-switch {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.lang-switch label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.lang-select {
  min-width: 130px;
}

/* ===== TAB STYLES ===== */
.tab-container {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-panel);
  padding: 0.5rem;
  border-radius: 10px;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  background: var(--bg-card);
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  gap: 1rem;
  min-height: 0;
}

/* Video Section */
.video-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.video-container {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

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

/* Drop Zone */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: 3px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone.hidden {
  display: none;
}

.drop-zone:hover,
.drop-zone.dragover {
  background: rgba(232, 33, 39, 0.1);
  border-color: var(--accent);
}

.drop-zone svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.drop-zone h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.drop-zone input {
  display: none;
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border-radius: 10px;
  flex-wrap: wrap;
}

.controls button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.controls button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.controls button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.time-display {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 100px;
}

.controls input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.controls input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.trim-controls {
  margin-top: 10px;
  width: 100%;
  flex-basis: 100%;
}

.trim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.trim-values {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.trim-sep {
  opacity: 0.6;
}

.trim-bar {
  position: relative;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.trim-bar--seek {
  flex: 1;
  min-width: 140px;
}

.trim-values--inline {
  width: 100%;
  justify-content: flex-end;
  margin-top: 4px;
}

.trim-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ff3b30;
  box-shadow: 0 0 0 1px rgba(255, 59, 48, 0.25);
  pointer-events: none;
  z-index: 2;
}

.trim-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.trim-overlay.trim-left {
  left: 0;
}

.trim-overlay.trim-right {
  right: 0;
}

.trim-bar input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 26px;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
}

.trim-bar input[type="range"].trim-seek {
  pointer-events: auto;
}

.trim-bar input[type="range"].trim-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.trim-bar input[type="range"].trim-seek::-moz-range-thumb {
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.trim-bar input[type="range"]::-webkit-slider-runnable-track {
  height: 26px;
  background: transparent;
}

.trim-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  margin-top: 4px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111;
  pointer-events: auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.trim-bar input[type="range"]::-moz-range-track {
  height: 26px;
  background: transparent;
}

.trim-bar input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #111;
  pointer-events: auto;
}

/* Side Panel */
.side-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-card {
  background: var(--bg-panel);
  border-radius: 10px;
  overflow: visible;
  flex-shrink: 0;
}

.panel-card.metadata-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.panel-content {
  padding: 1rem;
}

.panel-content.metadata-content {
  flex: 1;
  overflow: visible;
}

/* File Info */
.file-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-info .filename {
  font-weight: 600;
  word-break: break-all;
  color: var(--accent);
}

.file-info .detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* File List (for merge) */
.file-list-panel {
  background: var(--bg-panel);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-list-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 0.8rem;
}

.file-item .file-number {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.file-item .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-status {
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.file-item .file-status.ready {
  color: var(--success);
}
.file-item .file-status.processing {
  color: var(--warning);
}
.file-item .file-status.done {
  color: var(--success);
}
.file-item .file-status.error {
  color: var(--accent);
}

.file-item .remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.file-item .remove-btn:hover {
  color: var(--accent);
}

.clear-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

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

/* Metadata Grid */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.meta-item {
  background: linear-gradient(135deg, #2a2a2a, #1f1f1f);
  padding: 0.75rem 0.875rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.meta-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.meta-item .label {
  font-size: 0.65rem;
  color: #aaaaaa;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.meta-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.meta-item .value.speed {
  color: #00ff88;
  font-size: 1.25rem;
}
.meta-item .value.gear {
  color: #4da6ff;
}
.meta-item .value.autopilot {
  color: #a78bfa;
}
.meta-item .value.brake-on {
  color: #ff4757;
}
.meta-item .value.brake-off {
  color: #888888;
}
.meta-item .value.blinker-on {
  color: #ffc107;
}
.meta-item .value.blinker-off {
  color: #888888;
}
.meta-item .value.accel {
  color: #00d26a;
}
.meta-item.full-width {
  grid-column: span 2;
}

/* Overlay Settings */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-row label {
  font-size: 0.85rem;
}

.select-input {
  min-width: 170px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
}

.select-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.select-input option {
  background: var(--bg);
  color: var(--text);
}

.hint-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .slider {
  background: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}

/* Export Button */
.export-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.export-btn {
  width: 100%;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #ff4757);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.export-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(232, 33, 39, 0.4);
}

.export-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.export-btn svg {
  width: 18px;
  height: 18px;
}

.export-btn.processing {
  background: var(--warning);
}

.export-btn.secondary {
  background: var(--bg-card);
}

.export-btn.secondary:hover:not(:disabled) {
  background: var(--border);
  box-shadow: none;
}

/* Progress */
.progress-container {
  display: none;
}

.progress-container.visible {
  display: block;
}

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

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.1s;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 900px) {
  .main {
    flex-direction: column;
  }

  .side-panel {
    width: 100%;
  }

  .meta-grid {
    max-height: none;
  }

  .tab-btn {
    font-size: 0.8rem;
    padding: 0.6rem 0.75rem;
  }
}

/* ===== GRID LAYOUT STYLES ===== */
.grid-layout-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.radio-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.radio-option input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.radio-option span {
  font-size: 0.875rem;
  color: var(--text);
}

/* Grid File List */
.grid-file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.grid-file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.camera-icon {
  font-size: 1rem;
}

.camera-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
  min-width: 90px;
}

.file-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-files {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
  font-size: 0.875rem;
}

/* Form checkbox for grid options */
.form-row {
  margin-bottom: 0.75rem;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.form-checkbox span {
  font-size: 0.875rem;
  color: var(--text);
}

/* Radio label for grid layout */
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
}

.setting-row:has(.radio-label) {
  justify-content: flex-start;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.radio-label span {
  color: var(--text);
}
