/* =========================================
   CSS Variables & Reset
   ========================================= */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-card-hover: rgba(31, 41, 55, 0.9);
  --bg-input: rgba(17, 24, 39, 0.6);
  --border-color: rgba(75, 85, 99, 0.4);
  --border-focus: #6366f1;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =========================================
   Login Page
   ========================================= */
.login-body {
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  animation: slideUp 0.6s ease-out;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 0 100px rgba(99, 102, 241, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 12px;
}

/* =========================================
   Inputs
   ========================================= */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-left: 2px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition);
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper input:focus+svg,
.input-wrapper:focus-within svg {
  color: var(--accent);
}

.input-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 2px;
  margin-top: 2px;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

/* =========================================
   Alerts
   ========================================= */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  animation: slideDown 0.3s ease-out;
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-error svg {
  color: var(--error);
  flex-shrink: 0;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-success svg {
  color: var(--success);
  flex-shrink: 0;
}

/* =========================================
   Dashboard Layout
   ========================================= */
.dashboard-body {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 18px;
}

.sidebar-logo svg {
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
}

.nav-item.active svg {
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
}

.logout-btn {
  color: var(--error) !important;
}

.logout-btn:hover {
  background: var(--error-bg) !important;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
}

.avatar svg {
  width: 16px;
  height: 16px;
}

.content-area {
  padding: 32px;
  flex: 1;
}

/* =========================================
   Cards
   ========================================= */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-color);
}

.card-header svg {
  color: var(--accent);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* =========================================
   Download Form
   ========================================= */
.download-card {
  max-width: 640px;
}

.download-form {
  padding: 28px;
}

.form-step {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-actions {
  display: flex;
  gap: 12px;
}

.step-indicator {
  margin-bottom: 4px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 50px;
  font-size: 13px;
  color: var(--accent-hover);
}

.step-badge strong {
  color: var(--text-primary);
}

/* =========================================
   Files List
   ========================================= */
.files-list {
  margin-bottom: 24px;
}

.files-list h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.files-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.file-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.file-card svg {
  color: var(--accent);
  flex-shrink: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  word-break: break-all;
}

/* =========================================
   Animations
   ========================================= */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  50% {
    transform: translateX(6px);
  }

  75% {
    transform: translateX(-4px);
  }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================
   Jobs Page
   ========================================= */
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: var(--transition);
}

.job-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.job-card[data-status="done"] {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.03);
}

.job-card[data-status="failed"] {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.03);
}

.job-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.job-title-group {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.job-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.job-url {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.job-meta-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.job-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* Status dot */
.job-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.status-queued {
  background: #6b7280;
}

.status-downloading {
  background: #3b82f6;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-extracting {
  background: #f59e0b;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-done {
  background: #10b981;
}

.status-failed {
  background: #ef4444;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(0.85);
  }
}

/* Status badges */
.job-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-queued {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
}

.badge-downloading {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.badge-extracting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-done {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-sm {
  font-size: 10px;
  padding: 2px 8px;
}

/* Progress bar */
.job-progress-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  border-radius: 50px;
  transition: width 0.8s ease;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(200%);
  }
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 40px;
}

.progress-detail {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* Completed / error rows */
.job-done-row,
.job-error-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 8px 0;
}

.job-done-row {
  color: #34d399;
}

.job-error-row {
  color: #f87171;
}

.view-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  margin-left: auto;
  transition: var(--transition);
}

.view-link:hover {
  color: var(--accent-hover);
}

/* Live badge */
.live-badge {
  font-size: 11px;
  font-weight: 700;
  color: #34d399;
  letter-spacing: 0.5px;
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Top bar right group */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* Recent jobs on dashboard */
.recent-section {
  margin-top: 24px;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.recent-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.view-all-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}

.view-all-link:hover {
  color: var(--accent-hover);
}

.recent-job-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.rj-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rj-progress {
  font-size: 12px;
  color: #60a5fa;
  font-weight: 600;
}

.rj-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  flex-shrink: 0;
}

.rj-link:hover {
  color: var(--accent);
}

/* =========================================
   Video Player
   ========================================= */
.player-container {
  max-width: 960px;
}

.video-wrapper {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.video-player {
  width: 100%;
  max-height: 70vh;
  display: block;
}

.video-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
}

.video-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Back link */
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.back-link:hover {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.08);
}

/* =========================================
   Videos Grid
   ========================================= */
.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.video-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.video-thumb {
  display: block;
  position: relative;
  height: 160px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  cursor: pointer;
  overflow: hidden;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.3s ease;
}

.video-card:hover .video-thumb img {
  transform: scale(1.05);
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: var(--transition);
}

.video-thumb:hover .play-overlay {
  opacity: 1;
}

.play-overlay svg {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.video-duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

.video-card-info {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.video-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-title:hover {
  color: var(--accent);
}

.video-file-name {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.video-date {
  font-size: 12px;
  color: var(--text-muted);
}

.delete-btn {
  color: var(--text-muted);
  transition: var(--transition);
  padding: 4px;
  border-radius: 4px;
}

.delete-btn:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-state svg {
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
}

.empty-state a {
  color: var(--accent);
  text-decoration: none;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 768px) {
  .sidebar {
    width: 70px;
    overflow: hidden;
  }

  .sidebar-logo span,
  .sidebar-nav .nav-item span,
  .sidebar-footer .nav-item span {
    display: none;
  }

  .sidebar-header {
    padding: 20px 14px;
    display: flex;
    justify-content: center;
  }

  .sidebar-nav .nav-item,
  .sidebar-footer .nav-item {
    justify-content: center;
    padding: 12px;
  }

  .main-content {
    margin-left: 70px;
  }

  .content-area {
    padding: 20px 16px;
  }

  .top-bar {
    padding: 16px 20px;
  }

  .download-card {
    max-width: 100%;
  }

  .videos-grid {
    grid-template-columns: 1fr;
  }

  .video-meta {
    grid-template-columns: 1fr 1fr;
  }
}

/* Job delete button */
.job-delete-btn {
  color: var(--text-muted);
  transition: var(--transition);
  padding: 4px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
}

.job-delete-btn:hover {
  color: var(--error);
  background: var(--error-bg);
}