/* ============================================================
   Design System — shadcn/ui inspired, black & white
   Light + Dark mode
   ============================================================ */

/* ── Dark mode (default) ─────────────────────────────────── */

:root,
[data-theme="dark"] {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-foreground: #fafafa;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --border: #27272a;
  --input: #27272a;
  --ring: #d4d4d8;
  --dot-color: rgba(255,255,255,0.03);
  --dropzone-hover-bg: #0c0c10;
  --dropzone-border: #3f3f46;
  --dropzone-border-hover: #52525b;
  --subtle-text: #52525b;
  --checker: rgba(255,255,255,0.015);
  --toast-bg: #fafafa;
  --toast-fg: #09090b;
  --shadow-toast: 0 4px 24px rgba(0,0,0,0.5);
}

/* ── Light mode ──────────────────────────────────────────── */

[data-theme="light"] {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --secondary: #f4f4f5;
  --secondary-foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #09090b;
  --destructive: #ef4444;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #a1a1aa;
  --dot-color: rgba(0,0,0,0.04);
  --dropzone-hover-bg: #fafafa;
  --dropzone-border: #d4d4d8;
  --dropzone-border-hover: #a1a1aa;
  --subtle-text: #a1a1aa;
  --checker: rgba(0,0,0,0.025);
  --toast-bg: #18181b;
  --toast-fg: #fafafa;
  --shadow-toast: 0 4px 24px rgba(0,0,0,0.12);
}

/* ── Shared tokens ───────────────────────────────────────── */

:root {
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 0.9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2.25rem;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* ============================================================
   Background — subtle dot grid
   ============================================================ */

.bg-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(var(--dot-color) 1px, transparent 1px);
  background-size: 24px 24px;
  transition: background-image 0.3s ease;
}

.blob, .noise-overlay {
  display: none;
}

/* ============================================================
   App Layout
   ============================================================ */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ============================================================
   Header
   ============================================================ */

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

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: inherit;
}

.logo-icon-wrapper {
  flex-shrink: 0;
}

.logo-img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  transition: transform var(--transition-fast), filter 0.3s ease;
}

[data-theme="light"] .logo-img {
  filter: brightness(0.12);
}

[data-theme="dark"] .logo-img {
  filter: brightness(1);
}

.logo:hover .logo-img {
  transform: scale(1.05);
}

.logo-text {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.03em;
}

.logo-badge {
  font-size: 0.625rem;
  font-weight: 600;
  background: var(--foreground);
  color: var(--background);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Theme Toggle ──────────────────────────────────────── */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.theme-toggle:hover {
  background: var(--secondary);
  border-color: var(--dropzone-border);
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  transition: opacity 0.2s ease, transform 0.3s ease;
}

/* Dark mode: show sun, hide moon */
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* Light mode: show moon, hide sun */
[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}



/* ============================================================
   Main
   ============================================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-2xl) 0;
  gap: var(--space-xl);
}

/* ============================================================
   Hero
   ============================================================ */

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

.hero-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.2;
  color: var(--foreground);
  margin-bottom: var(--space-sm);
}

.hero-highlight {
  color: var(--foreground);
  text-decoration: underline;
  text-decoration-color: var(--muted-foreground);
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.hero-subtitle {
  font-size: var(--font-size-sm);
  color: var(--muted-foreground);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.7;
}


/* ============================================================
   Drop Zone
   ============================================================ */

.dropzone-container {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dropzone {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-xl);
  border: 1px dashed var(--dropzone-border);
  border-radius: var(--radius-lg);
  background: var(--background);
  cursor: pointer;
  transition: all var(--transition-base);
  outline: none;
  overflow: hidden;
}

.dropzone::before,
.dropzone::after {
  display: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--dropzone-border-hover);
  background: var(--dropzone-hover-bg);
}

.dropzone.dragover {
  border-color: var(--foreground);
  border-style: solid;
  background: var(--secondary);
}

.dropzone.dragover .dropzone-icon {
  color: var(--foreground);
  transform: scale(1.05) translateY(-2px);
}

.dropzone-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  text-align: center;
}

.dropzone-icon-wrapper {
  margin-bottom: var(--space-md);
}

.dropzone-icon-ring {
  display: none;
}

.dropzone-icon {
  color: var(--subtle-text);
  transition: all var(--transition-base);
}

.dropzone:hover .dropzone-icon {
  color: var(--muted-foreground);
  transform: translateY(-2px);
}

.dropzone-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--foreground);
}

.dropzone-subtitle {
  font-size: var(--font-size-sm);
  color: var(--muted-foreground);
}

.dropzone-link {
  color: var(--foreground);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dropzone-formats {
  display: flex;
  gap: 6px;
  margin-top: var(--space-sm);
}

.format-tag {
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: var(--muted-foreground);
  text-transform: uppercase;
}

.paste-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  font-size: var(--font-size-xs);
  color: var(--subtle-text);
}

.paste-hint svg {
  opacity: 0.5;
}

.paste-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--font-family);
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--secondary);
  border: 1px solid var(--dropzone-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted-foreground);
}

/* ============================================================
   Workspace
   ============================================================ */

.workspace {
  width: 100%;
  animation: slideUp 0.3s ease;
}

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

.workspace-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.panel {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition-fast);
}

.panel:hover {
  border-color: var(--dropzone-border);
}

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

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--muted-foreground);
}

.panel-title svg {
  color: var(--muted-foreground);
  opacity: 0.6;
}

.panel-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--secondary);
  color: var(--destructive);
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action:hover:not(:disabled) {
  background: var(--secondary);
  border-color: var(--dropzone-border);
}

.btn-action:active:not(:disabled) {
  transform: scale(0.97);
}

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

.panel-body {
  flex: 1;
  min-height: 300px;
}

/* Image Preview */
.image-preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: repeating-conic-gradient(
    var(--checker) 0% 25%,
    transparent 0% 50%
  ) 50% / 16px 16px;
}

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

/* Progress */
.progress-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: var(--space-lg);
  padding: var(--space-xl);
}

.progress-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  stroke: var(--secondary);
}

.progress-ring-fill {
  stroke: var(--foreground);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

.progress-percent {
  position: absolute;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--foreground);
}

.progress-status {
  font-size: var(--font-size-sm);
  color: var(--muted-foreground);
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

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

/* Result */
.result-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.result-text {
  flex: 1;
  width: 100%;
  min-height: 280px;
  padding: var(--space-lg);
  background: transparent;
  border: none;
  color: var(--foreground);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.8;
  resize: none;
  outline: none;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.result-text::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.result-text::placeholder {
  color: var(--subtle-text);
}

.result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-xs);
  color: var(--subtle-text);
}

.result-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Empty state */
.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: var(--space-md);
  color: var(--subtle-text);
  padding: var(--space-xl);
}

.empty-result svg {
  opacity: 0.2;
}

.empty-result p {
  font-size: var(--font-size-sm);
}

/* ============================================================
   Confidence Bar
   ============================================================ */

.confidence-bar {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: slideUp 0.3s ease;
}

.confidence-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--muted-foreground);
}

.confidence-value {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--foreground) !important;
}

.confidence-track {
  height: 4px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--foreground);
  transition: width 0.5s ease;
}

.confidence-fill::after {
  display: none;
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
}

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

.footer-credit {
  font-size: var(--font-size-xs);
  color: var(--subtle-text);
}

.footer a {
  color: var(--muted-foreground);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: var(--foreground);
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 10px 20px;
  background: var(--toast-bg);
  color: var(--toast-fg);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-toast);
  z-index: 1000;
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: none;
  white-space: nowrap;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success,
.toast.toast-error {
  background: var(--toast-bg);
}

/* ============================================================
   Utility
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .app {
    padding: 0 var(--space-md);
  }

  .header {
    flex-direction: column;
    gap: var(--space-md);
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .workspace-panels {
    grid-template-columns: 1fr;
  }

  .dropzone {
    padding: var(--space-2xl) var(--space-lg);
  }

  .logo-name {
    font-size: var(--font-size-lg);
  }

  .hero-title {
    font-size: var(--font-size-xl);
  }

  .panel-body {
    min-height: 200px;
  }

  .panel-header {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .paste-hint {
    display: none;
  }
}
