/**
 * @file
 * Styles for SSE-powered progress components.
 */

/* Progress container */
[data-ffmpeg-progress] {
  position: relative;
  padding: 1rem;
  border-radius: 8px;
  background: var(--ffmpeg-surface-2, #f5f5f5);
  border: 1px solid var(--ffmpeg-border, #e5e7eb);
  transition: all 0.3s ease;
}

[data-ffmpeg-progress].ffmpeg-sse-connected {
  border-color: var(--ffmpeg-success, #16a34a);
}

[data-ffmpeg-progress].ffmpeg-sse-error {
  border-color: var(--ffmpeg-warning, #f59e0b);
}

[data-ffmpeg-progress].ffmpeg-conversion-complete.ffmpeg-conversion-success {
  background: var(--ffmpeg-success-bg, #dcfce7);
  border-color: var(--ffmpeg-success, #16a34a);
}

[data-ffmpeg-progress].ffmpeg-conversion-complete.ffmpeg-conversion-failed {
  background: var(--ffmpeg-danger-bg, #fee2e2);
  border-color: var(--ffmpeg-danger, #dc2626);
}

/* Progress bar container */
.progress-bar-container {
  height: 24px;
  background: var(--ffmpeg-border, #e5e7eb);
  border-radius: 12px;
  overflow: hidden;
  margin: 0.5rem 0;
}

/* Progress bar */
.progress-bar,
[role="progressbar"] {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--ffmpeg-accent, #2563eb) 0%,
    var(--ffmpeg-accent-hover, #1d4ed8) 100%
  );
  border-radius: 12px;
  transition: width 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

/* Animated shimmer effect */
.progress-bar::after,
[role="progressbar"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Completed state - no animation */
.ffmpeg-conversion-complete .progress-bar::after,
.ffmpeg-conversion-complete [role="progressbar"]::after {
  display: none;
}

/* Progress text */
.ffmpeg-progress-percent {
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ffmpeg-text, #111827);
}

.ffmpeg-progress-status,
.ffmpeg-status-text {
  font-size: 0.875rem;
  color: var(--ffmpeg-text-muted, #6b7280);
  margin-top: 0.25rem;
}

/* Active conversions list */
.ffmpeg-active-conversions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ffmpeg-active-conversion-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--ffmpeg-surface, #ffffff);
  border-radius: 6px;
  border: 1px solid var(--ffmpeg-border, #e5e7eb);
  transition: all 0.3s ease;
}

.ffmpeg-active-conversion-item.removing {
  opacity: 0;
  transform: translateX(-20px);
}

.ffmpeg-active-conversion-item .ffmpeg-media-id {
  font-weight: 500;
  color: var(--ffmpeg-text, #111827);
  min-width: 100px;
}

.ffmpeg-active-conversion-item .progress-bar-container {
  height: 8px;
  margin: 0;
}

.ffmpeg-active-conversion-item .ffmpeg-progress-percent {
  font-size: 0.875rem;
  min-width: 45px;
  text-align: end;
}

.ffmpeg-active-conversion-item .ffmpeg-current-step {
  font-size: 0.75rem;
  color: var(--ffmpeg-text-muted, #6b7280);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dashboard widget */
[data-ffmpeg-dashboard] {
  position: relative;
}

.ffmpeg-queue-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
}

.ffmpeg-stat-item {
  text-align: center;
}

.ffmpeg-stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ffmpeg-accent, #2563eb);
  line-height: 1;
}

.ffmpeg-stat-label {
  font-size: 0.75rem;
  color: var(--ffmpeg-text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* Connection status indicator */
.ffmpeg-sse-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-inline-end: 0.5rem;
  background: var(--ffmpeg-text-muted, #6b7280);
}

.ffmpeg-sse-connected .ffmpeg-sse-indicator {
  background: var(--ffmpeg-success, #16a34a);
  animation: pulse 2s infinite;
}

.ffmpeg-sse-error .ffmpeg-sse-indicator {
  background: var(--ffmpeg-warning, #f59e0b);
}

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

/* Estimated time */
.ffmpeg-estimated-time {
  font-size: 0.875rem;
  color: var(--ffmpeg-text-muted, #6b7280);
}

.ffmpeg-estimated-time .ffmpeg-time-value {
  font-weight: 500;
}

/* Toast notifications */
.ffmpeg-toast {
  position: fixed;
  bottom: 1rem;
  inset-inline-end: 1rem;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  background: var(--ffmpeg-text, #111827);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.ffmpeg-toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.ffmpeg-toast.success {
  background: var(--ffmpeg-success, #16a34a);
}

.ffmpeg-toast.error {
  background: var(--ffmpeg-danger, #dc2626);
}

.ffmpeg-toast.warning {
  background: var(--ffmpeg-warning, #f59e0b);
  color: var(--ffmpeg-title, #111827);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ffmpeg-active-conversion-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .ffmpeg-active-conversion-item .ffmpeg-media-id {
    min-width: auto;
  }

  .ffmpeg-active-conversion-item .ffmpeg-current-step {
    max-width: none;
  }

  .ffmpeg-queue-stats {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .ffmpeg-stat-item {
    flex: 1 1 calc(50% - 0.5rem);
  }
}

/* Reduced motion: disable animations and transitions for accessibility */
@media (prefers-reduced-motion: reduce) {
  [data-ffmpeg-progress],
  .ffmpeg-active-conversion-item,
  .ffmpeg-toast,
  .progress-bar,
  [role="progressbar"] {
    transition: none;
  }

  .progress-bar::after,
  [role="progressbar"]::after {
    animation: none;
  }

  .ffmpeg-sse-connected .ffmpeg-sse-indicator {
    animation: none;
  }

  .ffmpeg-toast {
    transform: none;
  }

  .ffmpeg-active-conversion-item.removing {
    transform: none;
  }
}
