:root {
  /* High Performance Dark Theme */
  --primary-color: #3b82f6;        /* Electric Blue */
  --primary-hover: #2563eb;
  --success-color: #10b981;       /* Neon Green */
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --bg-primary: #0f172a;    /* Deep slate */
  --bg-secondary: #1e293b;  /* Lighter slate for cards */
  --bg-tertiary: #334155;   /* Borders/Inputs */
  --text-primary: #f8fafc;  /* White */
  --text-secondary: #94a3b8; /* Muted blue-grey */
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.5;
}

/* App layout */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: var(--bg-secondary);
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  background: linear-gradient(to right, var(--primary-color), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.sign-out-button {
  padding: 0.5rem 1rem;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.sign-out-button:hover {
  background-color: var(--bg-tertiary);
  color: var(--error-color);
  border-color: var(--error-color);
}

.main {
  flex: 1;
  max-width: 1200px; /* Increased max-width for dashboard view */
  width: 100%;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.footer {
  background-color: var(--bg-secondary);
  padding: 2rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: auto;
}

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

.footer a:hover {
  text-decoration: underline;
}

/* Upload Controller & Form */
.upload-controller {
  background-color: var(--bg-secondary);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.config-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.jump-selector {
  display: flex;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  border: 1px solid var(--border-color);
}

.type-btn {
  padding: 0.5rem 1.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}

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

.type-btn.active {
  background-color: var(--bg-tertiary);
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.debug-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.debug-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.drop-zone-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.upload-drop-zone {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: rgba(255,255,255,0.02);
  position: relative;
}

.upload-drop-zone:hover:not(.dragging) {
  border-color: var(--primary-color);
  background-color: rgba(59, 130, 246, 0.05);
}

.upload-drop-zone.dragging {
  border-color: var(--primary-color);
  background-color: rgba(59, 130, 246, 0.1);
}

.file-input {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  top: 0;
  left: 0;
  z-index: 10;
}

.empty-state {
  text-align: center;
  pointer-events: none;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.sub-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.file-ready-state {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background-color: var(--bg-tertiary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 500px;
  z-index: 20; /* Above file input to allow button click */
  pointer-events: none; /* Let clicks pass through generally */
}

.file-preview-icon {
  font-size: 2rem;
}

.file-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.filename {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filesize {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.change-file-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  pointer-events: auto; /* Re-enable clicks */
}

.change-file-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.analyze-hero-button {
  width: 100%;
  max-width: 400px;
  padding: 1rem 2rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.analyze-hero-button:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

.analyze-hero-button:disabled {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.loading-pulse {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.validation-error {
  color: var(--error-color);
  background-color: rgba(239, 68, 68, 0.1);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
  text-align: center;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.validation-banner {
  background-color: var(--bg-secondary);
  padding: 1.5rem 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-top: 2rem;
}

.validation-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.validation-banner.pass {
  border-color: rgba(16, 185, 129, 0.3);
  background-color: rgba(16, 185, 129, 0.05);
}

.validation-banner.pass .status-icon {
  color: var(--success-color);
}

.validation-banner.fail {
  border-color: rgba(239, 68, 68, 0.3);
  background-color: rgba(239, 68, 68, 0.05);
}

.validation-banner.fail .status-icon {
  color: var(--error-color);
}

.validation-banner.pass_with_warnings {
  border-color: rgba(59, 130, 246, 0.3);
  background-color: rgba(59, 130, 246, 0.05);
}

.validation-banner.pass_with_warnings .status-icon {
  color: var(--primary-color);
}

/* Recent uploads */
.recent-uploads {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.recent-header h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.clear-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
}

.clear-button:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.recent-list {
  display: grid;
  gap: 0.75rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  text-align: left;
}

.recent-item:hover {
  background-color: rgba(255,255,255,0.05);
  border-color: var(--border-color);
}

.recent-filename {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.recent-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
}

.recent-type {
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.recent-time {
  color: var(--text-secondary);
}

/* Loading State */
.loading-spinner {
  background-color: var(--bg-secondary);
  padding: 4rem 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border-color);
  margin-top: 2rem;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.5rem;
  border: 3px solid var(--bg-tertiary);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.progress-bar {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background-color: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin: 1.5rem auto;
}

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

.loading-steps ul {
  list-style: none;
  padding: 0;
  text-align: left;
  max-width: 300px;
  margin: 2rem auto 0;
}

.loading-steps li {
  color: var(--text-secondary);
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-steps li:last-child {
  border-bottom: none;
}

.loading-steps li.active {
  color: var(--primary-color);
  font-weight: 600;
}

.loading-steps li.complete {
  color: var(--success-color);
}

.loading-steps li.complete::before {
  content: "✓";
}

/* --- Results Dashboard Styles --- */

.video-preview-container {
  margin-bottom: 2rem;
  background-color: black;
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.analysis-video-player {
  width: 100%;
  height: 100%;
  max-height: 600px;
  display: block;
}

.results-container {
  background-color: var(--bg-secondary);
  padding: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-top: 2rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(0,0,0,0.2);
}

.results-header h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 700;
}

.results-meta {
  display: flex;
  gap: 0.75rem;
}

.meta-tag {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
}

/* Timeline & Phases */
.jump-timeline {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 1rem;
  padding: 2rem;
  align-items: center;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.5) 0%, rgba(15, 23, 42, 0) 100%);
}

.arrow {
  color: var(--text-secondary);
  font-size: 1.5rem;
  opacity: 0.5;
}

.phase-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.2s;
}

.phase-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.phase-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.phase-metrics {
  display: grid;
  gap: 0.75rem;
}

.metric-compact {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.metric-compact .label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.metric-compact .value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.metric-compact .unit {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

/* KPI Grid */
.metrics-dashboard {
  padding: 2rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.metric-card {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 140px;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: rgba(255,255,255,0.2);
}

.metric-card.highlight {
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(59, 130, 246, 0.1) 100%);
  border-color: rgba(59, 130, 246, 0.3);
}

.metric-card.highlight .value-text {
  color: var(--primary-color);
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.metric-card-header {
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.metric-card-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-icon {
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: help;
  opacity: 0.6;
}

.info-icon:hover {
  color: var(--primary-color);
  opacity: 1;
}

.metric-card-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.25rem;
}

.value-text {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.value-unit {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Detailed Breakdown */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border-color);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-item {
  background-color: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.detail-item:hover {
  border-color: var(--border-color);
}

.detail-label {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.detail-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Actions */
.actions-bar {
  display: flex;
  justify-content: center;
  padding: 2rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
}

.download-button.primary {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  padding: 0.875rem 2rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.download-button.primary:hover {
  background-color: white;
  transform: translateY(-1px);
  box-shadow: 0 0 15px rgba(255,255,255,0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .jump-timeline {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .arrow {
    transform: rotate(90deg);
    text-align: center;
  }
}

@media (max-width: 640px) {
  .header-content { flex-direction: column; text-align: center; gap: 1rem; }
  .user-info { flex-direction: column; width: 100%; }
  .sign-out-button { width: 100%; }
  .kpi-grid { grid-template-columns: 1fr; }
  .config-bar { flex-direction: column; align-items: stretch; }
  .jump-selector { width: 100%; }
  .type-btn { flex: 1; }
}
