/* ============================================
   pdfmd — Harvard Crimson × Minimal SaaS
   Inspired by iLovePDF/SmallPDF patterns
   ============================================ */

:root {
  /* Harvard-inspired palette */
  --crimson: #A51C30;
  --crimson-dark: #8C1826;
  --crimson-light: #C73E4E;
  --indigo: #1e293b;
  --indigo-deep: #0f172a;
  --charcoal: #374151;
  --slate: #64748b;
  --silver: #94a3b8;
  --cloud: #f1f5f9;
  --white: #ffffff;

  /* Semantic */
  --bg: var(--white);
  --bg-subtle: var(--cloud);
  --bg-card: var(--white);
  --text: var(--indigo);
  --text-secondary: var(--charcoal);
  --text-muted: var(--slate);
  --border: #e2e8f0;
  --accent: var(--crimson);
  --accent-hover: var(--crimson-dark);
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: var(--indigo-deep);
  --bg-subtle: var(--indigo);
  --bg-card: var(--indigo);
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--crimson); color: white; }

.skip-link {
  position: absolute; top: -40px; left: 0;
  background: var(--accent); color: white;
  padding: 8px 16px; z-index: 999; font-size: 14px;
}
.skip-link:focus { top: 0; }

.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;
}

/* ---- HEADER ---- */
header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-text { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }

.header-nav {
  display: flex; align-items: center; gap: 16px;
}

.nav-link {
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  transition: color var(--transition);
}
.nav-link:hover { color: var(--text); text-decoration: none; }

.token-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}

.token-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.theme-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition);
}
.theme-btn:hover { background: var(--bg-subtle); color: var(--text); }

/* ---- HERO ---- */
.hero {
  padding: 64px 0 40px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero-sub {
  font-size: 17px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ---- UPLOAD CARD (iLovePDF style) ---- */
.upload-card {
  max-width: 560px; margin: 0 auto;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  cursor: pointer;
  transition: all 0.25s ease;
  background: var(--bg-card);
}

.upload-card:hover, .upload-card.dragover {
  border-color: var(--accent);
  background: rgba(165, 28, 48, 0.03);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .upload-card:hover,
[data-theme="dark"] .upload-card.dragover {
  background: rgba(165, 28, 48, 0.08);
}

.upload-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }

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

.upload-label {
  font-size: 16px; font-weight: 500; color: var(--text);
}
.upload-label strong { color: var(--accent); }

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

/* ---- OPTIONS PANEL ---- */
.options-panel {
  max-width: 560px; margin: 16px auto 0;
}

.options-toggle {
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; text-align: center;
  padding: 8px 0;
  list-style: none;
  transition: color var(--transition);
}
.options-toggle:hover { color: var(--text); }
.options-toggle::-webkit-details-marker { display: none; }
.options-toggle::before { content: '+ '; }
[open] > .options-toggle::before { content: '- '; }

.options-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 16px; margin-top: 8px;
  background: var(--bg-subtle); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.opt-group label:first-child {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px;
}

.opt-group select {
  width: 100%; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--bg-card); color: var(--text);
}

.check-row { display: flex; gap: 12px; }

.check-label {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
}

.check-label input[type="checkbox"] {
  accent-color: var(--accent); width: 16px; height: 16px;
}

/* ---- TRUST ROW ---- */
.trust-row {
  display: flex; justify-content: center; gap: 24px;
  margin-top: 24px; flex-wrap: wrap;
}

.trust-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}

.trust-item svg { color: var(--success); flex-shrink: 0; }

/* ---- HOW IT WORKS ---- */
.how-section {
  padding: 48px 0;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.how-section h2 {
  text-align: center; font-size: 22px; font-weight: 700;
  margin-bottom: 32px; letter-spacing: -0.5px;
}

.steps-row {
  display: flex; align-items: flex-start; justify-content: center; gap: 20px;
}

.step {
  text-align: center; flex: 1; max-width: 220px;
}

.step-num {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  margin: 0 auto 12px;
}

.step h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.step p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.step-arrow {
  display: flex; align-items: center;
  color: var(--silver); padding-top: 8px;
}

@media (max-width: 640px) {
  .steps-row { flex-direction: column; align-items: center; }
  .step-arrow { transform: rotate(90deg); }
}

/* ---- WORKSPACE ---- */
.workspace { padding: 40px 0; }

.workspace-grid {
  display: grid; grid-template-columns: 280px 1fr; gap: 20px;
}

@media (max-width: 768px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 { font-size: 14px; font-weight: 600; }

.task-panel, .preview-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-panel { min-height: 300px; }

.preview-content {
  padding: 16px; overflow-y: auto; max-height: 500px;
  font-size: 14px; line-height: 1.7;
}

.preview-content pre {
  background: var(--bg-subtle); padding: 12px;
  border-radius: var(--radius-xs); overflow-x: auto;
  font-size: 13px;
}

.preview-content table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px;
}
.preview-content th, .preview-content td {
  border: 1px solid var(--border); padding: 8px 10px; text-align: left;
}
.preview-content th { background: var(--bg-subtle); font-weight: 600; }
.preview-content img { max-width: 100%; border-radius: 6px; margin: 8px 0; }

/* Task Items */
.task-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.task-item:hover { background: var(--bg-subtle); }
.task-item:last-child { border-bottom: none; }

.task-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.task-name { font-size: 13px; font-weight: 500; }

.task-badge {
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-uploaded { background: rgba(59,130,246,0.1); color: #3b82f6; }
.badge-queued { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-processing { background: rgba(217,119,6,0.1); color: var(--warning); }
.badge-completed { background: rgba(5,150,105,0.1); color: var(--success); }
.badge-failed { background: rgba(220,38,38,0.1); color: var(--error); }

.task-progress { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.task-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.5s ease; }

.task-meta { display: flex; gap: 10px; margin-top: 4px; font-size: 11px; color: var(--text-muted); }

.empty-state { padding: 40px 16px; text-align: center; }
.empty-state p { font-size: 14px; color: var(--text-muted); }

/* ---- FEATURES ---- */
.features-section {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}

.features-section h2 {
  text-align: center; font-size: 22px; font-weight: 700;
  margin-bottom: 32px; letter-spacing: -0.5px;
}

.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px;
}

.feat {
  text-align: center; padding: 24px 16px;
}

.feat-icon {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(165, 28, 48, 0.08); color: var(--accent);
  margin: 0 auto 12px;
}

[data-theme="dark"] .feat-icon {
  background: rgba(165, 28, 48, 0.15);
}

.feat h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.feat p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ---- AD SLOT ---- */
.ad-slot { padding: 20px 0; }
.ad-placeholder {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; font-size: 12px;
  color: var(--text-muted); min-height: 90px;
  display: flex; align-items: center; justify-content: center;
}

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--accent); color: white; border: none;
  padding: 8px 16px; border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); padding: 8px 16px;
  border-radius: var(--radius-xs); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
}
.btn-outline:hover { border-color: var(--text-muted); background: var(--bg-subtle); }

.btn-ghost {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: var(--radius-xs);
  display: flex; align-items: center; transition: color var(--transition);
}
.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- FOOTER ---- */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
}

.footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
}

.footer-inner nav { display: flex; gap: 16px; }
.footer-inner a { color: var(--text-muted); font-size: 13px; }
.footer-inner a:hover { color: var(--text); text-decoration: none; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; color: white; box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--indigo); }

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

/* ---- SPINNER ---- */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top: 2px solid var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--silver); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .hero { padding: 40px 0 24px; }
  .upload-card { padding: 32px 20px; }
  .options-grid { grid-template-columns: 1fr; }
  .trust-row { flex-direction: column; align-items: center; gap: 12px; }
  .features-grid { grid-template-columns: 1fr 1fr; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
}

@media (max-width: 420px) {
  .features-grid { grid-template-columns: 1fr; }
  .header-inner { height: 48px; }
  .logo-text { font-size: 16px; }
  .token-pill { font-size: 12px; padding: 3px 8px; }
  .check-row { flex-direction: column; gap: 4px; }
}

/* ---- PRINT ---- */
@media print {
  header, footer, .ad-slot, .theme-btn, .toast-container { display: none !important; }
  .preview-content { max-height: none; }
}

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