/* ═══════════════════════════════════════════════════════════
   AI Media Processor — Premium Dark Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 32, 0.7);
  --bg-card-hover: rgba(30, 30, 48, 0.8);
  --bg-input: rgba(16, 16, 28, 0.9);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(139, 92, 246, 0.3);
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
  --gradient-glow: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Animated background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.5); }

/* ── Layout ───────────────────────────────────────────────── */
.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  text-align: center;
  margin-bottom: 48px;
}

.header__logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.header__icon {
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.header__title {
  font-size: 32px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.header__subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
  max-width: 500px;
  margin: 0 auto;
}

/* ── Card Base ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin-bottom: 24px;
  transition: var(--transition);
  box-shadow: var(--shadow-glow);
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow), 0 0 60px rgba(139, 92, 246, 0.05);
}

.card__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card__title-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-glow);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ── Drop Zone ────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed rgba(139, 92, 246, 0.25);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: rgba(139, 92, 246, 0.03);
  position: relative;
  overflow: hidden;
}

.dropzone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-glow);
  opacity: 0;
  transition: var(--transition);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.06);
}

.dropzone:hover::before,
.dropzone.drag-over::before {
  opacity: 1;
}

.dropzone__icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  position: relative;
  z-index: 1;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.dropzone__text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  position: relative;
  z-index: 1;
}

.dropzone__hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

.dropzone__browse {
  color: var(--accent-purple);
  text-decoration: underline;
  cursor: pointer;
}

.dropzone__browse:hover {
  color: var(--accent-cyan);
}

/* File preview */
.file-preview {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.file-preview.show {
  display: flex;
}

.file-preview__icon {
  font-size: 28px;
}

.file-preview__info {
  flex: 1;
  text-align: left;
}

.file-preview__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.file-preview__size {
  font-size: 12px;
  color: var(--text-muted);
}

.file-preview__remove {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview__remove:hover {
  background: rgba(244, 63, 94, 0.2);
}

/* ── Language Selector ────────────────────────────────────── */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.lang-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.lang-chip:hover {
  border-color: rgba(139, 92, 246, 0.2);
  background: rgba(139, 92, 246, 0.05);
}

.lang-chip.selected {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.1);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.1);
}

.lang-chip__checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  font-size: 11px;
  color: transparent;
}

.lang-chip.selected .lang-chip__checkbox {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

.lang-chip__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.lang-chip.selected .lang-chip__label {
  color: var(--text-primary);
}

.lang-chip__flag {
  font-size: 16px;
}

/* ── Submit Button ────────────────────────────────────────── */
.submit-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
  margin-top: 8px;
}

.submit-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: var(--transition);
}

.submit-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Progress Section ─────────────────────────────────────── */
#progress-section {
  display: none;
}

#progress-section.show {
  display: block;
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Progress stages */
.stages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
}

.stages::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  z-index: 0;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.stage__dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}

.stage.active .stage__dot {
  border-color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.15);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

.stage.done .stage__dot {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
}

.stage.failed .stage__dot {
  border-color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.15);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 0 30px rgba(139, 92, 246, 0.5); }
}

.stage__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.stage.active .stage__label {
  color: var(--accent-purple);
}

.stage.done .stage__label {
  color: var(--accent-emerald);
}

.stage.failed .stage__label {
  color: var(--accent-rose);
}

/* Progress bar */
.progress-bar-wrapper {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.progress-text strong {
  color: var(--text-primary);
}

/* ── Results Section ──────────────────────────────────────── */
#results-section {
  display: none;
}

#results-section.show {
  display: block;
  animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.result-item {
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.result-item:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.result-item__lang {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-item__badge {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
  border-radius: 999px;
  font-weight: 600;
}

.download-btn {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-accent);
  background: rgba(139, 92, 246, 0.06);
  color: var(--accent-purple);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.download-btn:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--accent-purple);
  color: white;
}

/* ── Error Message ────────────────────────────────────────── */
.error-message {
  display: none;
  padding: 14px 18px;
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.2);
  border-radius: var(--radius-md);
  color: var(--accent-rose);
  font-size: 14px;
  margin-top: 16px;
}

.error-message.show {
  display: block;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ── Job History ──────────────────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition);
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--border-accent);
}

.history-item__info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-item__name {
  font-size: 13px;
  font-weight: 500;
}

.history-item__status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item__status.done {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.history-item__status.processing {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-purple);
}

.history-item__status.failed {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.footer a {
  color: var(--accent-purple);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .app {
    padding: 24px 16px 60px;
  }

  .header__title {
    font-size: 24px;
  }

  .card {
    padding: 20px;
  }

  .dropzone {
    padding: 32px 16px;
  }

  .lang-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stages {
    gap: 4px;
  }

  .stage__label {
    font-size: 9px;
  }

  .stage__dot {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }
}
