/* =================================================================
   SCREENSHOT READER — DESIGN TOKEN SYSTEM
   Dark Premium SaaS (matches Clean Image)
   ================================================================= */
:root {
  --bg-root: #0a0a0d;
  --bg-surface: #121215;
  --bg-elevated: #1a1a1f;
  --bg-overlay: #1e1e24;
  --bg-modal: rgba(6, 6, 10, 0.94);
  --border-subtle: #222229;
  --border-active: #333340;
  --border-glow: #7c3aed;
  --border-danger: rgba(255, 71, 87, 0.28);
  --text-primary: #eaeaef;
  --text-secondary: #90909e;
  --text-muted: #5e5e6d;
  --text-accent: #a78bfa;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --accent-glow: rgba(124, 58, 237, 0.35);
  --accent-dim: rgba(124, 58, 237, 0.12);
  --success: #2ed573;
  --danger: #ff4757;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-glow: 0 0 50px var(--accent-glow), 0 0 100px rgba(124, 58, 237, 0.08);
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.022) 1px, transparent 0);
  background-size: 32px 32px;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* =================================================================
   HEADER
   ================================================================= */
.app-header {
  width: 100%;
  max-width: 1100px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.66rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}

.header-veloce-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-accent);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 180ms var(--ease-out);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.header-veloce-link:hover {
  border-color: var(--border-glow);
  background: var(--accent-dim);
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.18);
  transform: translateY(-1px);
}

.header-privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(46, 213, 115, 0.07);
  border: 1px solid rgba(46, 213, 115, 0.18);
  border-radius: 999px;
  color: var(--success);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(46, 213, 115, 0.5);
  animation: beat 2s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* =================================================================
   MAIN
   ================================================================= */
.main-container {
  width: 100%;
  max-width: 1100px;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
  z-index: 10;
}

/* =================================================================
   UPLOAD ZONE
   ================================================================= */
.upload-zone {
  width: 100%;
  border: 2px dashed var(--border-active);
  border-radius: var(--radius-lg);
  padding: 54px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 280ms var(--ease-out);
  background: var(--bg-surface);
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.upload-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 60% at 50% 50%, var(--accent-dim) 0%, transparent 80%);
  opacity: 0;
  transition: opacity 450ms var(--ease-out);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--border-glow);
  background: var(--bg-elevated);
  box-shadow: 0 0 50px rgba(124, 58, 237, 0.07);
}

.upload-zone:hover::after,
.upload-zone.drag-over::after {
  opacity: 1;
}

.upload-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  position: relative;
  z-index: 1;
  transition: all 280ms var(--ease-out);
}

.upload-zone:hover .upload-icon {
  border-color: var(--border-glow);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-3px);
}

.upload-text {
  font-size: 0.98rem;
  color: var(--text-secondary);
  text-align: center;
  position: relative;
  z-index: 1;
}

.upload-text strong {
  color: var(--text-accent);
  font-weight: 700;
}

.upload-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.upload-input {
  display: none;
}

/* =================================================================
   WORKSPACE
   ================================================================= */
.workspace {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.workspace.active {
  display: flex;
}

.canvas-panel {
  position: relative;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background-image:
    linear-gradient(45deg, #1a1a1f 25%, transparent 25%),
    linear-gradient(-45deg, #1a1a1f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1a1f 75%),
    linear-gradient(-45deg, transparent 75%, #1a1a1f 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.canvas-stack {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.canvas-stack canvas {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
}

/* =================================================================
   TOOLBAR
   ================================================================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-spacer {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 160ms var(--ease-out);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg-overlay);
  border-color: var(--border-active);
}

.btn:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-active);
}

.btn-danger {
  border-color: var(--border-danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 71, 87, 0.07);
  border-color: rgba(255, 71, 87, 0.45);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 11px 24px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 24px var(--accent-glow), 0 2px 10px rgba(0, 0, 0, 0.35);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 36px var(--accent-glow), 0 4px 14px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

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

.btn-download {
  background: var(--success);
  border-color: var(--success);
  color: #000;
  font-weight: 800;
  box-shadow: 0 0 18px rgba(46, 213, 115, 0.22);
}

.btn-download:hover {
  box-shadow: 0 0 28px rgba(46, 213, 115, 0.35);
  transform: translateY(-2px);
}

.processing-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-accent);
  font-weight: 600;
}

.processing-indicator.active {
  display: flex;
}

.processing-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-active);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* =================================================================
   TRANSCRIPT PANEL
   ================================================================= */
.transcript-panel {
  display: none;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.transcript-panel.active {
  display: flex;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.transcript-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-accent);
}

.transcript-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.transcript-output {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-root);
  padding: 20px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =================================================================
   DOCS
   ================================================================= */
.docs-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 30px;
}

.docs-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.docs-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 200ms var(--ease-out);
}

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

.docs-card-icon {
  font-size: 1.5rem;
}

.docs-card-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.docs-card-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =================================================================
   FOOTER
   ================================================================= */
.app-footer {
  width: 100%;
  margin-top: 28px;
  padding: 32px 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  position: relative;
  z-index: 10;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.footer-legal {
  text-align: center;
  font-size: 0.66rem;
  color: var(--text-muted);
  line-height: 2;
}

.footer-legal a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 150ms ease;
}

.footer-legal a:hover {
  color: var(--text-accent);
}

/* =================================================================
   PROGRESS OVERLAY
   ================================================================= */
.progress-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.progress-overlay.active {
  display: flex;
}

.progress-modal {
  width: 100%;
  max-width: 460px;
  padding: 40px 36px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
}

.progress-icon-wrap {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  border: 1px solid rgba(124, 58, 237, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  position: relative;
}

.progress-icon-wrap::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spinner-ring 1.6s linear infinite;
}

@keyframes spinner-ring {
  to { transform: rotate(360deg); }
}

.progress-title {
  font-size: 0.98rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

.progress-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
  min-height: 2.4em;
}

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

.progress-bar-inner {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  width: 0%;
  transition: width 0.35s var(--ease-out);
  position: relative;
}

.progress-percent {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-accent);
}

/* =================================================================
   TOAST
   ================================================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-overlay);
  border: 1px solid var(--border-active);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  transform: translateY(160%);
  opacity: 0;
  transition: all 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
  pointer-events: none;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(255, 71, 87, 0.3);
  color: var(--danger);
}

.toast.success {
  border-color: rgba(46, 213, 115, 0.3);
  color: var(--success);
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group {
    justify-content: center;
  }

  .toolbar-spacer {
    display: none;
  }

  .docs-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .progress-modal {
    margin: 14px;
    padding: 28px 20px;
  }

  .main-container {
    padding: 0 10px 24px;
  }
}
