@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 32, 0.8);
  --bg-card-hover: rgba(28, 28, 45, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);

  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555568;

  --accent-primary: #6c5ce7;
  --accent-secondary: #a855f7;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a855f7, #ec4899);
  --accent-glow: rgba(108, 92, 231, 0.3);

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --border-color: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(108, 92, 231, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Background gradient orbs */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 600px;
  height: 600px;
  background: var(--accent-primary);
  top: -200px;
  right: -100px;
}

body::after {
  width: 500px;
  height: 500px;
  background: #ec4899;
  bottom: -200px;
  left: -100px;
}

/* ============================================================
   Layout
   ============================================================ */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
  z-index: 1;
}

/* ============================================================
   Header
   ============================================================ */
.app-header {
  text-align: center;
  margin-bottom: 48px;
}

.app-header__icon {
  width: 64px;
  height: 64px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.app-header__title {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.app-header__subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ============================================================
   Sections
   ============================================================ */
.section {
  margin-bottom: 32px;
}

.section__title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section__title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

/* ============================================================
   Upload Zone
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-glass);
  position: relative;
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-primary);
  background: var(--bg-glass-hover);
}

.upload-zone:hover::before,
.upload-zone.drag-over::before {
  opacity: 0.03;
}

.upload-zone.drag-over {
  transform: scale(1.01);
  box-shadow: var(--shadow-glow);
}

.upload-zone__icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  position: relative;
  z-index: 1;
}

.upload-zone__text {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.upload-zone__hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.upload-zone__input {
  display: none;
}

/* ============================================================
   Status Messages
   ============================================================ */
.status-message {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  animation: slideUp 0.3s ease;
}

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

.status-message.visible {
  display: flex;
}

.status-message.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-message.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-message.info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-message.loading {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* ============================================================
   Media List
   ============================================================ */
.media-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: all var(--transition-normal);
  animation: fadeInUp 0.4s ease both;
}

.media-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}

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

.media-card:nth-child(1) { animation-delay: 0.05s; }
.media-card:nth-child(2) { animation-delay: 0.1s; }
.media-card:nth-child(3) { animation-delay: 0.15s; }
.media-card:nth-child(4) { animation-delay: 0.2s; }
.media-card:nth-child(5) { animation-delay: 0.25s; }

.media-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.media-card__info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.media-card__quality {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

.media-card__quality--hd {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(168, 85, 247, 0.2));
  color: var(--accent-secondary);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.media-card__quality--sd {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.media-card__format {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  text-transform: uppercase;
  white-space: nowrap;
}

.media-card__url {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.media-card__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   Progress Bar (within media card)
   ============================================================ */
.media-card__progress {
  margin-top: 16px;
  display: none;
}

.media-card__progress.visible {
  display: block;
  animation: slideUp 0.3s ease;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.3s ease;
  position: relative;
}

.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 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.progress-info__status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-info__status.completed {
  color: var(--success);
}

.progress-info__status.error {
  color: var(--error);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.btn--primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn--primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  filter: brightness(1.1);
}

.btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

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

.btn--ghost:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.btn--danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* ============================================================
   Downloads List
   ============================================================ */
.downloads-section {
  margin-top: 48px;
}

.downloads-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  animation: fadeInUp 0.3s ease both;
}

.download-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.download-item__info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.download-item__icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.download-item__name {
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-item__size {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.download-item__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state__text {
  font-size: 0.9rem;
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .app-container {
    padding: 24px 16px 60px;
  }

  .app-header__title {
    font-size: 1.6rem;
  }

  .upload-zone {
    padding: 32px 20px;
  }

  .media-card__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .media-card__actions {
    width: 100%;
    justify-content: flex-end;
  }

  .download-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .download-item__actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
