/* ============================================
   EPUB to PDF Converter — Dark Theme
   Freecvt.com Design System
   ============================================ */

:root {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a24;
  --bg-tertiary: #24243a;
  --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;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Skip Link ---- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 16px;
}

/* ---- Header ---- */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
}

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

/* ---- Navigation ---- */
.main-nav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-list {
  list-style: none;
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

.nav-list li a {
  display: inline-block;
  padding: 6px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.nav-list li a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-list li a.active {
  color: var(--accent-hover);
  background: var(--accent-glow);
  font-weight: 600;
}

/* ---- Main Content ---- */
.converter-page {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 48px 24px 64px;
}

.converter-container {
  width: 100%;
  max-width: var(--max-w);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ---- Page Title ---- */
.page-title {
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: -16px;
}

/* ---- Upload Zone ---- */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--bg-secondary);
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--border-hover);
  background: var(--accent-glow);
  box-shadow: 0 0 24px rgba(99, 102, 241, 0.1);
}

.upload-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.upload-icon svg {
  width: 48px;
  height: 48px;
}

.upload-text {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.upload-text strong {
  color: var(--accent-hover);
}

.upload-subtext {
  font-size: 13px;
  color: var(--text-muted);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---- File Info ---- */
.file-info {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.file-info-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.file-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.btn-remove {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-remove:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ---- Convert Button ---- */
.btn-convert {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-convert:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

.btn-convert:active:not(:disabled) {
  transform: translateY(0);
}

.btn-convert:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-convert.converting {
  pointer-events: none;
}

.btn-convert.converting .btn-text {
  display: none;
}

.btn-convert .btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-convert .btn-spinner[hidden] {
  display: none;
}

.spinner-icon {
  animation: spin 1s linear infinite;
}

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

/* ---- Progress Bar ---- */
.progress-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-bar[hidden] {
  display: none;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Status Message ---- */
.status-message {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.status-message[hidden] {
  display: none;
}

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

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

/* ---- How It Works ---- */
.how-it-works {
  padding: 32px 0 0;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.step-item:hover {
  border-color: var(--border-hover);
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.step-content p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Features ---- */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  transition: border-color 0.2s;
}

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

.feature-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 12px;
}

.feature-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.site-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- Hidden render container ---- */
#renderContainer {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 800px;
  height: 1100px;
  overflow: hidden;
  visibility: hidden;
}

#renderContainer canvas {
  display: block;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
  }

  .main-nav {
    width: 100%;
  }

  .nav-list {
    gap: 2px;
  }

  .nav-list li a {
    font-size: 12px;
    padding: 5px 8px;
  }

  .converter-page {
    padding: 32px 16px 48px;
  }

  .page-title {
    font-size: 24px;
  }

  .page-subtitle {
    font-size: 14px;
  }

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

  .upload-icon svg {
    width: 36px;
    height: 36px;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .step-item {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .page-title {
    font-size: 20px;
  }

  .nav-list {
    flex-wrap: wrap;
  }

  .upload-zone {
    padding: 24px 12px;
  }
}

/* ---- Print ---- */
@media print {
  .site-header,
  .site-footer,
  .how-it-works,
  .features {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .converter-page {
    padding: 0;
  }

  .converter-container {
    max-width: 100%;
  }
}
