/* ChatClipThat - Modern Gaming Interface */
:root {
  --primary: #9147ff;
  --primary-hover: #772ce8;
  --success: #00ff88;
  --warning: #ffb800;
  --error: #ff4757;
  --bg-primary: #0e0e10;
  --bg-secondary: #18181b;
  --bg-tertiary: #1f1f23;
  --text-primary: #efeff1;
  --text-secondary: #adadb8;
  --text-muted: #717179;
  --border: #2d2d35;
  --border-hover: #3d3d45;
  --shadow: rgba(0, 0, 0, 0.3);
  --gradient-primary: linear-gradient(135deg, #9147ff 0%, #772ce8 100%);
  --gradient-success: linear-gradient(135deg, #00ff88 0%, #00d970 100%);
  
  /* Progress bar colors */
  --progress-bg: #2d2d35;
  --progress-fill: linear-gradient(90deg, #9147ff 0%, #772ce8 100%);
  --progress-fill-downloading: linear-gradient(90deg, #00ff88 0%, #00d970 100%);
  --progress-fill-processing: linear-gradient(90deg, #ffb800 0%, #ff9500 100%);
  --progress-fill-completed: linear-gradient(90deg, #00ff88 0%, #00d970 100%);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 20px var(--shadow);
}

.navbar-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.navbar-brand svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.navbar-brand:hover {
  transform: translateY(-1px);
}

.navbar-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.navbar-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.navbar-links a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.navbar-links a.active {
  color: var(--primary);
  background: rgba(145, 71, 255, 0.1);
}

/* Main Content */
main {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem 0;
  color: var(--text-primary);
  font-weight: 600;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
  margin: 0 0 1rem 0;
  color: var(--text-secondary);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--gradient-primary);
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(145, 71, 255, 0.3);
}

.button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(145, 71, 255, 0.4);
}

.button:active {
  transform: translateY(0);
}

.button.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}

.button.secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.button.success {
  background: var(--gradient-success);
  box-shadow: 0 2px 8px rgba(0, 255, 136, 0.3);
}

.button.success:hover {
  box-shadow: 0 4px 16px rgba(0, 255, 136, 0.4);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow);
}

/* VOD Cards */
.vod-card {
  display: grid;
  grid-template-columns: 320px 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.25rem;
}

.vod-thumbnail {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
}

.vod-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vod-info h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.vod-meta {
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.vod-actions {
  display: flex;
  gap: 0.75rem;
}

/* Job Cards */
.job-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.25rem;
}

.job-info h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}

.job-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Status Badges */
.status {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.status-queued { background: rgba(255, 184, 0, 0.15); color: var(--warning); }
.status-running { background: rgba(145, 71, 255, 0.15); color: var(--primary); }
.status-succeeded { background: rgba(0, 255, 136, 0.15); color: var(--success); }
.status-failed { background: rgba(255, 71, 87, 0.15); color: var(--error); }

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(145, 71, 255, 0.15);
  background: var(--bg-secondary);
}

/* Search */
.search-container {
  margin-bottom: 2rem;
}

.search-form {
  display: flex;
  gap: 1rem;
  max-width: 600px;
}

.search-form input {
  flex: 1;
}

/* Grid Layouts */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(500px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); }

/* Loading States */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error Messages */
.error {
  padding: 1rem;
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 8px;
  color: var(--error);
  margin-bottom: 1rem;
}

/* Success Messages */
.success {
  padding: 1rem;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 8px;
  color: var(--success);
  margin-bottom: 1rem;
}

/* Utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* Responsive */
@media (max-width: 768px) {
  .navbar-content {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  main {
    padding: 1rem;
  }
  
  .vod-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .job-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .search-form {
    flex-direction: column;
  }
  
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* HTMX Loading Indicator */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Compact, inline progress presentation for job cards */
.progress-section {
  margin: 1rem 0 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  position: relative;
  overflow: visible;
}

.progress-section::before {
  content: none;
  display: none;
}

/* Enhanced Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--progress-bg);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.25rem 0 1rem 0;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

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

/* Progress bar states */
.progress-bar-fill[style*="width: 0%"] { background: var(--progress-bg); }
.progress-bar-fill[style*="width: 25%"] { background: var(--progress-fill-downloading); }
.progress-bar-fill[style*="width: 75%"] { background: var(--progress-fill-processing); }
.progress-bar-fill[style*="width: 100%"] { background: var(--progress-fill-completed); }

/* Inline progress meta */
.progress-text {
  display: inline-block;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0 0.5rem;
  font-size: 0.85rem;
}

/* Enhanced Time Estimate */
.time-estimate {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  font-weight: 500;
}

/* Compact stage chip */
.stage-indicator {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0 0.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stage-indicator::before {
  content: none;
}

/* Stage-specific colors */
.stage-initializing {
  background: linear-gradient(135deg, #ffb800 0%, #ff9500 100%);
  color: #000;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.stage-downloading {
  background: linear-gradient(135deg, #00ff88 0%, #00d970 100%);
  color: #000;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.stage-processing_clips {
  background: linear-gradient(135deg, #9147ff 0%, #772ce8 100%);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.stage-completed {
  background: linear-gradient(135deg, #00ff88 0%, #00d970 100%);
  color: #000;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.stage-unknown {
  background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Enhanced Job Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px var(--shadow);
}

/* Enhanced Status Badges */
.job-status-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.status {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.status::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
  opacity: 0.6;
}

.status-queued { 
  background: linear-gradient(135deg, #ffb800 0%, #ff9500 100%); 
  color: #000; 
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.status-running { 
  background: linear-gradient(135deg, #9147ff 0%, #772ce8 100%); 
  color: white; 
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.status-processing { 
  background: linear-gradient(135deg, #9147ff 0%, #772ce8 100%); 
  color: white; 
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.status-completed { 
  background: linear-gradient(135deg, #00ff88 0%, #00d970 100%); 
  color: #000; 
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.status-succeeded { 
  background: linear-gradient(135deg, #00ff88 0%, #00d970 100%); 
  color: #000; 
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

.status-failed { 
  background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%); 
  color: white; 
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Enhanced Job Info Layout */
.card > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.card > div:first-child > div:first-child h4 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
}

.card > div:first-child > div:last-child {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Enhanced Job Details */
.card > div:last-child {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.card > div:last-child > div {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card > div:last-child > div::before {
  content: '•';
  color: var(--primary);
  font-weight: bold;
}

/* Progress Animation */
@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-section:not([style*="display: none"]) {
  animation: progressPulse 2s ease-in-out infinite;
}

/* Responsive Progress */
@media (max-width: 768px) {
  .progress-section {
    padding: 1rem;
    margin: 1rem 0;
  }
  
  .progress-bar {
    height: 20px;
  }
  
  .stage-indicator {
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
  }
  
  .time-estimate {
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
  }
}