/* ===== CSS Variables (Design System) ===== */
:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #24243a;
  --bg-hover: #2e2e48;
  --border-color: #2e2e48;
  --border-hover: #6366f1;
  --text-primary: #e0e0e0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --max-w: 640px;
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Accessibility ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Focus Styles ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Navbar ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.logo:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.6875rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.nav-links a.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}

/* ===== Layout ===== */
header {
  border-bottom: 1px solid var(--border-color);
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border-color);
}

/* ===== Page Title ===== */
.page-title {
  text-align: center;
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 700;
  margin: 1.5rem 0 0.375rem;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
}

/* ===== Converter Wrapper ===== */
.converter-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* ===== Upload Zone ===== */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  margin-bottom: 1.5rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone.drag-over {
  box-shadow: 0 0 24px var(--accent-glow);
}

/* ===== Upload Content ===== */
.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  cursor: pointer;
  min-height: 180px;
}

.upload-icon {
  color: var(--text-muted);
  margin-bottom: 1rem;
  width: 48px;
  height: 48px;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  color: var(--accent);
}

.upload-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.upload-subtext {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.browse-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.browse-link:hover {
  color: var(--accent-hover);
}

.upload-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.75rem;
}

/* ===== Preview Grid ===== */
#preview-section {
  margin-bottom: 1.5rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.preview-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
  transition: border-color var(--transition);
}

.preview-card:hover {
  border-color: var(--accent);
}

.preview-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: contain;
  background-color: var(--bg-primary);
  display: block;
}

.preview-info {
  padding: 0.5rem 0.625rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
}

.preview-name {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.preview-size {
  font-size: 0.6875rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  font-size: 1rem;
  flex-shrink: 0;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition);
}

.preview-remove:hover,
.preview-remove:focus-visible {
  color: var(--error);
  background: rgba(239, 68, 68, 0.12);
}

.preview-card.converted {
  border-color: var(--success);
}

.preview-card.converted::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ===== Buttons ===== */
#actions-section {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn {
  flex: 1;
  padding: 0.875rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

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

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

/* ===== Progress ===== */
#progress-section {
  margin-bottom: 1.5rem;
}

.progress-bar-wrapper {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a29bfe);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== Error Display ===== */
.error-display {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* ===== Info Section ===== */
.info-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.info-section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-align: center;
  color: var(--text-primary);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
}

.step {
  text-align: center;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.step h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--text-primary);
}

.step p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .navbar {
    padding: 0.75rem 1rem;
    justify-content: center;
  }

  .nav-links {
    display: none;
  }

  .page-title {
    margin-top: 1rem;
  }

  .upload-content {
    padding: 2rem 1rem;
    min-height: 150px;
  }

  .preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  #actions-section {
    flex-direction: column;
  }

  .steps {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
