/**
 * Convert Page - FFmpeg.wasm Audio/Video Converter
 * Extends the glassmorphism design system
 */

/* ============================================
   PAGE LAYOUT
   ============================================ */
.convert-page {
  padding-top: calc(80px + var(--space-2xl));
}

/* ============================================
   TOOLS INTRODUCTION SECTION
   ============================================ */
.tools-intro {
  margin-bottom: var(--space-3xl);
}

.tools-intro-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.tools-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(236, 72, 153, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
}

.tools-intro-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.tools-intro-subtitle {
  font-size: var(--text-base);
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

/* Tools Cards Grid */
.tools-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-base);
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, transparent);
  transition: all var(--transition-base);
}

.tool-card:hover {
  transform: translateY(-4px);
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-lg);
}

/* Mashup Card */
.tool-card--mashup::before {
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
}

.tool-card--mashup:hover {
  border-color: rgba(236, 72, 153, 0.4);
  box-shadow: 0 8px 32px rgba(236, 72, 153, 0.15);
}

.tool-card--mashup .tool-card-icon {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

/* Convert Card */
.tool-card--convert::before {
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
}

.tool-card--convert.tool-card--active {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.08), rgba(6, 182, 212, 0.05));
}

.tool-card--convert .tool-card-icon {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}

/* Card Icon */
.tool-card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.tool-card-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

/* Card Content */
.tool-card-content {
  flex: 1;
}

.tool-card-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.tool-card-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

.tool-card-features {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-lg) 0;
}

.tool-card-features li {
  position: relative;
  padding-left: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.tool-card-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--accent-primary);
  border-radius: 50%;
}

/* Card CTA */
.tool-card-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent-primary);
  transition: all var(--transition-base);
}

.tool-card:hover .tool-card-cta {
  gap: var(--space-sm);
}

.tool-card-cta svg {
  transition: transform var(--transition-base);
}

.tool-card:hover .tool-card-cta svg {
  transform: translateX(4px);
}

/* Active Badge */
.tool-card-badge {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: #60a5fa;
}

/* Responsive */
@media (max-width: 768px) {
  .tools-cards {
    grid-template-columns: 1fr;
  }

  .tools-intro-title {
    font-size: var(--text-2xl);
  }

  .tool-card {
    padding: var(--space-lg);
  }
}

.convert-hero {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.convert-title {
  font-size: var(--text-5xl);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-bottom: var(--space-md);
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.convert-subtitle {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

/* ============================================
   FFMPEG LOADING STATE
   ============================================ */
.ffmpeg-loading {
  padding: var(--space-3xl);
  text-align: center;
}

.ffmpeg-loading h3 {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loading-spinner {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-lg);
}

.spinner-icon {
  animation: rotate 2s linear infinite;
  width: 100%;
  height: 100%;
}

.spinner-icon .path {
  stroke: var(--accent-primary);
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

/* ============================================
   UPLOAD ZONE EXTENSIONS
   ============================================ */
.format-badge--audio {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--accent-secondary);
}

.format-badge--video {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* ============================================
   FILE INFO CARD
   ============================================ */
.file-info-card {
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.file-info-header {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: var(--space-lg);
}

.file-icon {
  width: 64px;
  height: 64px;
  background: var(--gradient-purple);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-sm);
  flex-shrink: 0;
}

.file-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.file-icon--video {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.file-meta span {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.file-type {
  padding: var(--space-xs) var(--space-sm);
  background: var(--accent-muted);
  color: var(--accent-secondary) !important;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* ============================================
   MEDIA PREVIEW
   ============================================ */
.media-preview {
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

/* Video Preview */
.media-preview--video {
  background: linear-gradient(145deg, rgba(15, 15, 20, 0.95), rgba(10, 10, 15, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.media-preview video {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: contain;
  background: transparent;
}

/* Custom video controls styling */
.media-preview video::-webkit-media-controls-panel {
  background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, transparent 100%);
}

/* Audio Preview - Custom Design */
.media-preview--audio {
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.08), rgba(99, 102, 241, 0.05));
  border: 1px solid rgba(139, 92, 246, 0.2);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.audio-visualizer {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-md) 0;
}

.audio-bar {
  width: 4px;
  background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 2px;
  animation: audioWave 1.2s ease-in-out infinite;
  opacity: 0.7;
}

.audio-bar:nth-child(1) { height: 20%; animation-delay: 0s; }
.audio-bar:nth-child(2) { height: 45%; animation-delay: 0.1s; }
.audio-bar:nth-child(3) { height: 70%; animation-delay: 0.2s; }
.audio-bar:nth-child(4) { height: 55%; animation-delay: 0.3s; }
.audio-bar:nth-child(5) { height: 85%; animation-delay: 0.4s; }
.audio-bar:nth-child(6) { height: 65%; animation-delay: 0.5s; }
.audio-bar:nth-child(7) { height: 90%; animation-delay: 0.6s; }
.audio-bar:nth-child(8) { height: 50%; animation-delay: 0.7s; }
.audio-bar:nth-child(9) { height: 75%; animation-delay: 0.8s; }
.audio-bar:nth-child(10) { height: 40%; animation-delay: 0.9s; }
.audio-bar:nth-child(11) { height: 60%; animation-delay: 1.0s; }
.audio-bar:nth-child(12) { height: 35%; animation-delay: 1.1s; }
.audio-bar:nth-child(13) { height: 80%; animation-delay: 0.05s; }
.audio-bar:nth-child(14) { height: 50%; animation-delay: 0.15s; }
.audio-bar:nth-child(15) { height: 65%; animation-delay: 0.25s; }
.audio-bar:nth-child(16) { height: 45%; animation-delay: 0.35s; }
.audio-bar:nth-child(17) { height: 70%; animation-delay: 0.45s; }
.audio-bar:nth-child(18) { height: 55%; animation-delay: 0.55s; }
.audio-bar:nth-child(19) { height: 40%; animation-delay: 0.65s; }
.audio-bar:nth-child(20) { height: 25%; animation-delay: 0.75s; }

@keyframes audioWave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* Paused state - no animation */
.media-preview--audio.paused .audio-bar {
  animation: none;
  opacity: 0.4;
}

.media-preview audio {
  width: 100%;
  max-width: 500px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.3);
}

/* Custom audio styling for webkit browsers */
.media-preview audio::-webkit-media-controls-panel {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.1));
  border-radius: var(--radius-lg);
}

.media-preview audio::-webkit-media-controls-play-button {
  background-color: var(--accent-primary);
  border-radius: 50%;
}

.media-preview audio::-webkit-media-controls-current-time-display,
.media-preview audio::-webkit-media-controls-time-remaining-display {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* Preview label */
.preview-label {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   CONVERSION OPTIONS
   ============================================ */
.conversion-options {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.options-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

.options-title svg {
  color: var(--accent-primary);
}

/* Quick Actions Grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.quick-action-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.quick-action-btn.active {
  background: var(--glass-bg-active);
  border-color: var(--accent-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow-sm);
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.action-icon--purple { background: linear-gradient(135deg, #8b5cf6, #a855f7); }
.action-icon--pink { background: linear-gradient(135deg, #ec4899, #f472b6); }
.action-icon--blue { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.action-icon--green { background: linear-gradient(135deg, #10b981, #34d399); }
.action-icon--orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.action-icon--cyan { background: linear-gradient(135deg, #06b6d4, #22d3ee); }

/* Options Panel */
.options-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  border: 1px solid var(--glass-border);
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.option-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.option-group .form-input {
  padding: var(--space-sm) var(--space-md);
}

.option-group select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Trim Inputs */
.trim-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.trim-inputs .form-input {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
}

.trim-separator {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Convert Actions */
.convert-actions {
  display: flex;
  justify-content: center;
  padding-top: var(--space-lg);
}

.convert-actions .btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: var(--text-base);
}

/* ============================================
   PROCESSING STATE
   ============================================ */
.processing-container {
  padding: var(--space-2xl);
  text-align: center;
}

.processing-info {
  margin-bottom: var(--space-xl);
}

.processing-status {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.processing-detail {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.processing-logs {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-top: var(--space-lg);
  text-align: left;
}

.processing-logs pre {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* ============================================
   RESULT STATE
   ============================================ */
.result-container {
  padding: var(--space-2xl);
  text-align: center;
}

.result-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-lg);
  background: linear-gradient(135deg, #10b981, #34d399);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.4);
}

.result-icon svg {
  width: 40px;
  height: 40px;
  color: white;
}

.result-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.result-detail {
  color: var(--text-muted);
  margin-bottom: var(--space-xl);
}

.result-preview {
  margin-bottom: var(--space-xl);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
}

/* Result Video */
.result-preview--video {
  background: linear-gradient(145deg, rgba(15, 15, 20, 0.95), rgba(10, 10, 15, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.result-preview video {
  width: 100%;
  max-height: 400px;
  display: block;
  object-fit: contain;
}

/* Result Audio */
.result-preview--audio {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), rgba(52, 211, 153, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-preview audio {
  width: 100%;
  max-width: 500px;
  height: 48px;
  border-radius: var(--radius-lg);
}

.result-preview audio::-webkit-media-controls-panel {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.1));
  border-radius: var(--radius-lg);
}

/* Result Image/GIF */
.result-preview--image {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.05));
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-preview img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.result-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .convert-title {
    font-size: var(--text-3xl);
  }

  .file-info-header {
    flex-wrap: wrap;
  }

  .file-icon {
    width: 48px;
    height: 48px;
  }

  .file-icon svg {
    width: 24px;
    height: 24px;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .quick-action-btn {
    padding: var(--space-md);
  }

  .action-icon {
    width: 40px;
    height: 40px;
  }

  .action-icon svg {
    width: 20px;
    height: 20px;
  }

  .options-panel {
    grid-template-columns: 1fr;
  }

  .trim-inputs {
    flex-direction: column;
  }

  .trim-separator {
    display: none;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .convert-page {
    padding-top: calc(70px + var(--space-xl));
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }
}
