/* ============================================
   PDF2MD.AI - Design System & Styles
   ============================================ */

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

/* --- Design Tokens --- */
:root {
  /* Colors - Light, warm foundation */
  --bg: #fafaf8;
  --bg-subtle: #f5f5f3;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #059669;
  --error: #dc2626;
  --border: #e5e5e5;

  /* Typography - Single family */
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --size-sm: 0.875rem;
  --size-base: 1rem;
  --size-lg: 1.25rem;
  --size-xl: 1.5rem;
  --size-2xl: 2rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
  --space-12: 4rem;

  /* Effects */
  --radius: 8px;
  --transition: 150ms ease-out;
}

/* --- Base --- */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* --- Layout --- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-6);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-8);
}

/* --- Header --- */
.header {
  text-align: center;
}

.logo {
  font-family: var(--font);
  font-size: var(--size-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

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

.tagline {
  font-family: var(--font);
  font-size: var(--size-base);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.subtagline {
  font-size: var(--size-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
  letter-spacing: 0.02em;
}

/* --- Drop Zone --- */
.dropzone {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-8);
  text-align: center;
  cursor: pointer;
  position: relative;
  transition:
    border-color var(--transition),
    background-color var(--transition);
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

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

.dropzone.drag-active {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.dropzone-icon {
  font-size: 2.5rem;
  opacity: 0.6;
}

.dropzone-text {
  font-family: var(--font);
  font-size: var(--size-lg);
  font-weight: 500;
  color: var(--text);
}

.dropzone-hint {
  font-size: var(--size-sm);
  color: var(--text-muted);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* --- Drop Zone States --- */
.dropzone-selected {
  background: var(--surface);
  border-color: var(--success);
}

.dropzone-converting {
  background: var(--surface);
  border-color: var(--accent);
}

.dropzone-error {
  background: var(--surface);
  border-color: var(--error);
}

.dropzone-icon-success {
  color: var(--success);
  animation: none;
}

.dropzone-icon-error {
  color: var(--error);
}

.dropzone-filename {
  font-size: var(--size-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
  margin-top: var(--space-1);
}

.dropzone-error-message {
  font-size: var(--size-sm);
  color: var(--error);
  font-family: var(--font-mono);
  margin-top: var(--space-2);
  word-break: break-word;
}

.error-retry-status {
  font-size: var(--size-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.error-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

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

/* --- Buttons --- */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: calc(var(--radius) / 2);
  font-family: var(--font-mono);
  font-size: var(--size-sm);
  cursor: pointer;
  transition:
    background-color var(--transition),
    color var(--transition);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  margin-top: var(--space-3);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
}

/* --- Footer --- */
.footer {
  text-align: center;
}

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

/* --- Micro-Steps (Progress) --- */
.micro-steps {
  text-align: center;
  width: 100%;
  margin: 0 auto var(--space-3);
}

.micro-step {
  font-family: var(--font);
  font-size: var(--size-sm);
  color: var(--text-muted);
  margin: var(--space-1) 0;
  opacity: 0.5;
  transition: opacity 150ms ease-out, color 150ms ease-out;
}

.micro-step-active {
  color: var(--text);
  opacity: 1;
}

/* --- Spinner (kept for fallback) --- */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  margin: 0 auto;
}

/* --- Animations --- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

/* Mobile (320px - 639px) */
@media (max-width: 639px) {
  .container {
    padding: 1rem;
    gap: 1.5rem;
  }

  .dropzone {
    padding: 1.5rem;
  }

  .dropzone-icon {
    font-size: 2.5rem;
  }

  .dropzone-filename {
    font-size: 0.75rem;
  }

  .btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .logo {
    font-size: 2rem;
  }

  .result-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .result-header-left {
    justify-content: space-between;
  }

  .result-header-right {
    justify-content: space-between;
  }

  .result-actions {
    gap: var(--space-1);
  }

  .result-content,
  .result-rendered {
    max-height: 50vh;
    padding: 1rem;
  }

  .spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }
}

/* Tablet (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  .container {
    padding: 1.5rem;
    gap: 2rem;
  }

  .dropzone {
    padding: 2.5rem;
  }

  .dropzone-icon {
    font-size: 2.75rem;
  }

  .logo {
    font-size: 2.25rem;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .container {
    padding: 2rem;
    gap: 3rem;
  }

  .dropzone {
    padding: 4rem;
  }

  .dropzone-icon {
    font-size: 3rem;
  }

  .logo {
    font-size: var(--size-2xl);
  }

  .result-content,
  .result-rendered {
    max-height: 60vh;
    padding: var(--space-4);
  }
}

/* --- Result --- */
.result-container {
  width: 100%;
  max-width: 100%;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}

.result-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.result-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.result-filename {
  font-family: var(--font-mono);
  font-size: var(--size-sm);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.streaming-indicator {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Icon buttons - minimal, ghost style */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), background-color var(--transition);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.icon-btn:active {
  background: var(--border);
}

/* Text button - minimal */
.text-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.text-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background: var(--bg-subtle);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.result-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
}

.result-content code {
  font-family: var(--font-mono);
  font-size: var(--size-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- View Toggle --- */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toggle-link {
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  opacity: 0.6;
}

.toggle-link:hover {
  opacity: 1;
}

.toggle-link.active {
  color: var(--text);
  opacity: 1;
}

.toggle-sep {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.4;
  user-select: none;
}

/* --- Rendered Markdown View --- */
.result-rendered {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;
  max-height: 60vh;
  overflow-y: auto;
  font-family: var(--font);
  font-size: var(--size-base);
  line-height: 1.7;
  color: var(--text);
}

.result-rendered h1,
.result-rendered h2,
.result-rendered h3,
.result-rendered h4,
.result-rendered h5,
.result-rendered h6 {
  font-family: var(--font);
  font-weight: 600;
  margin: 1.2em 0 0.5em;
  color: var(--text);
}

.result-rendered h1 { font-size: 1.6rem; }
.result-rendered h2 { font-size: 1.35rem; }
.result-rendered h3 { font-size: 1.15rem; }
.result-rendered h4 { font-size: 1rem; }

.result-rendered p {
  margin: 0.6em 0;
}

.result-rendered code {
  background: var(--bg-subtle);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.result-rendered pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1em;
  overflow-x: auto;
  margin: 1em 0;
}

.result-rendered pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
}

.result-rendered ul,
.result-rendered ol {
  padding-left: 1.5em;
  margin: 0.6em 0;
}

.result-rendered li {
  margin: 0.3em 0;
}

.result-rendered blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--text-muted);
  font-style: italic;
}

.result-rendered a {
  color: var(--accent);
  text-decoration: none;
}

.result-rendered a:hover {
  text-decoration: underline;
}

.result-rendered hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.result-rendered table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}

.result-rendered th,
.result-rendered td {
  border: 1px solid var(--border);
  padding: 0.5em 0.75em;
  text-align: left;
}

.result-rendered th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.result-rendered strong {
  font-weight: 600;
}

.result-rendered em {
  font-style: italic;
}

/* --- Next Steps Section --- */
.next-steps-section {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}

.next-steps-title {
  font-family: var(--font);
  font-size: var(--size-base);
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-4);
}

.next-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space-4);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color var(--transition),
    background-color var(--transition);
}

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

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

.action-card-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-2);
  display: block;
}

.action-card-title {
  font-family: var(--font-mono);
  font-size: var(--size-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.action-card-description {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

/* Mobile (320px - 639px) */
@media (max-width: 639px) {
  .next-steps-grid {
    grid-template-columns: 1fr;
  }

  .next-steps-title {
    font-size: var(--size-base);
  }
}

/* Tablet (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  .next-steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .next-steps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
