/* Kinetic — Premium Design System (Attently-inspired) */

/* ── Reset & Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Warm off-white backgrounds */
  --bg: #faf9f7;
  --bg-secondary: #f5f4f1;
  --bg-elevated: #ffffff;

  /* Dark mode */
  --bg-dark: #161821;
  --bg-dark-secondary: #1e2030;
  --bg-dark-elevated: #252738;

  /* Primary — Electric cyan/teal (video/creative energy) */
  --primary: #14b8a6;
  --primary-hover: #0d9488;
  --primary-light: rgba(20, 184, 166, 0.08);
  --primary-ring: rgba(20, 184, 166, 0.3);

  /* Accent — Warm amber */
  --accent: #f59e0b;
  --accent-hover: #d97706;

  /* Text */
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Borders */
  --border: #e8e6e1;
  --border-hover: #d4d1cc;

  /* Status colors */
  --status-queued: #8b5cf6;
  --status-processing: #3b82f6;
  --status-rendering: #f59e0b;
  --status-complete: #22c55e;
  --status-failed: #ef4444;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 4px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 8px rgba(0,0,0,0.04), 0 12px 24px rgba(0,0,0,0.1);
  --shadow-xl: 0 8px 16px rgba(0,0,0,0.06), 0 20px 40px rgba(0,0,0,0.12);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }

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

.header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
}

.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-complete);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
  animation: pulse 2s ease-in-out infinite;
}

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

.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Cards ── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 20px 24px 0;
}

.card-body {
  padding: 20px 24px;
}

.card-footer {
  padding: 0 24px 20px;
}

/* ── Form ── */
.form-section {
  margin-bottom: 32px;
}

.form-section h2 {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-sublabel {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
  line-height: 1;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font);
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--duration) var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── Job List ── */
.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.jobs-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.job-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--duration) var(--ease);
  cursor: default;
}

.job-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.job-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.job-icon.queued { background: rgba(139,92,246,0.1); }
.job-icon.processing { background: rgba(59,130,246,0.1); }
.job-icon.rendering { background: rgba(245,158,11,0.1); }
.job-icon.complete { background: rgba(34,197,94,0.1); }
.job-icon.failed { background: rgba(239,68,68,0.1); }

.job-info {
  flex: 1;
  min-width: 0;
}

.job-topic {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.job-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-queued {
  background: rgba(139,92,246,0.1);
  color: var(--status-queued);
}

.badge-processing {
  background: rgba(59,130,246,0.1);
  color: var(--status-processing);
}

.badge-rendering {
  background: rgba(245,158,11,0.1);
  color: var(--status-rendering);
}

.badge-complete {
  background: rgba(34,197,94,0.1);
  color: var(--status-complete);
}

.badge-failed {
  background: rgba(239,68,68,0.1);
  color: var(--status-failed);
}

.job-progress-wrap {
  flex-shrink: 0;
  width: 120px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 500ms var(--ease);
  background: var(--primary);
}

.progress-fill.complete {
  background: var(--status-complete);
}

.progress-fill.failed {
  background: var(--status-failed);
}

.progress-fill.processing {
  background: var(--status-processing);
  animation: shimmer 1.5s ease-in-out infinite;
}

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

.progress-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 3px;
}

.job-actions {
  flex-shrink: 0;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--status-complete);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.btn-download:hover {
  background: #16a34a;
  box-shadow: var(--shadow-sm);
}

.btn-download:active {
  transform: scale(0.97);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* ── Toast / Notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.8125rem;
  animation: slideIn 300ms var(--ease);
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--status-complete); }
.toast.error { border-left: 3px solid var(--status-failed); }
.toast.info { border-left: 3px solid var(--status-processing); }

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
}

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

/* ── Stats Row ── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 2px;
}

/* ── Script Builder (Advanced) ── */
.scene-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scene-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
}

.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.scene-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
}

.btn-remove-scene {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1;
  transition: all var(--duration) var(--ease);
}

.btn-remove-scene:hover {
  color: var(--status-failed);
  background: rgba(239,68,68,0.08);
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header { padding: 0 16px; }
  .main { padding: 20px 16px 80px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .job-card { flex-wrap: wrap; }
  .job-progress-wrap { width: 100%; }
  h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.25rem; }
}

/* ── Animations ── */
.fade-in {
  animation: fadeIn 300ms var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}
