/* ==========================================================================
   Vizora — App Shell Styles
   Brand tokens per Brand Bible / Design System:
   bg #FAFAF8, surface #FFFFFF, text #111111, muted #6B7280, border #E5E7EB,
   accent #2563EB (hover #1D4ED8), teal #0EA5A4, success #16A34A, error #DC2626
   Headings: Geist/Inter Display · Body: Inter · Code: JetBrains Mono
   No purple gradients, no glassmorphism, no sparkles.
   ========================================================================== */

:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --text: #111111;
  --muted: #6B7280;
  --border: #E5E7EB;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-pressed: #1E40AF;
  --teal: #0EA5A4;
  --success: #16A34A;
  --warning: #F59E0B;
  --error: #DC2626;
  --radius-input: 12px;
  --radius-card: 16px;
  --radius-dialog: 20px;
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.05);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Nav ---------- */
.topnav {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.brand-dot { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; }

.credit-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.credit-pill #creditCount { color: var(--accent); }
.credit-pill.low #creditCount { color: var(--warning); }
.credit-pill.critical #creditCount { color: var(--error); }

.low-credit-banner {
  background: #FFFBEB;
  border-bottom: 1px solid #FDE68A;
  color: #92400E;
  text-align: center;
  font-size: 14px;
  padding: 10px 16px;
}
.low-credit-banner.critical {
  background: #FEF2F2;
  border-bottom: 1px solid #FECACA;
  color: #991B1B;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-input);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  cursor: pointer;
  transition: background 150ms ease-out, transform 150ms ease-out, border-color 150ms ease-out;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-pressed); }
.btn-primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg); }

/* ---------- Layout ---------- */
.main-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.view { padding: 64px 0; }

/* ---------- Hero / upload ---------- */
.hero-copy { max-width: 640px; margin: 0 auto 48px; text-align: center; }
.eyebrow {
  display: inline-block; color: var(--accent); font-weight: 600; font-size: 13px;
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 16px;
}
.hero-copy h1 {
  font-size: clamp(32px, 4.5vw, 48px); font-weight: 700; letter-spacing: -0.03em;
  margin: 0 0 16px; line-height: 1.15;
}
.hero-copy .sub { color: var(--muted); font-size: 17px; margin: 0; }

.dropzone {
  max-width: 640px; margin: 0 auto;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-card);
  padding: 56px 32px;
  text-align: center;
  transition: border-color 150ms ease-out, background 150ms ease-out;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: #F8FAFF;
}
.dropzone-icon {
  width: 48px; height: 48px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--accent);
}
.dropzone-title { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.dropzone-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.processing {
  max-width: 640px; margin: 32px auto 0; text-align: center; color: var(--muted);
}
.spinner {
  width: 28px; height: 28px; margin: 0 auto 16px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  max-width: 640px; margin: 24px auto 0;
  background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B;
  border-radius: var(--radius-card); padding: 16px 20px; font-size: 14px;
  display: flex; flex-direction: column; gap: 4px;
}

/* ---------- Result view ---------- */
.result-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; margin-bottom: 28px; flex-wrap: wrap;
}
.result-toolbar h2 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.02em; }
.result-sub { color: var(--muted); margin: 0; font-size: 14px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.preview-frame-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
#previewFrame { width: 100%; height: 70vh; min-height: 480px; border: none; display: block; }

/* ---------- History ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.history-item-title { font-weight: 600; margin: 0 0 4px; }
.history-item-meta { color: var(--muted); font-size: 13px; margin: 0; }
.history-empty { color: var(--muted); text-align: center; padding: 48px 0; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,17,17,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 24px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-dialog);
  max-width: 560px; width: 100%; padding: 32px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.10);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.modal-close {
  background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-sub { color: var(--muted); font-size: 14px; margin: 8px 0 24px; }
.modal-note { color: var(--muted); font-size: 12px; margin: 20px 0 0; text-align: center; }
.modal-note code {
  font-family: 'JetBrains Mono', monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px;
}

.packages-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.package-card {
  border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px;
  text-align: left; background: var(--bg); cursor: pointer;
  transition: border-color 150ms ease-out, transform 150ms ease-out;
}
.package-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.package-name { font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.package-credits { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.package-price { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow-md); z-index: 60;
  animation: toast-in 200ms ease-out;
}
.toast.error { background: var(--error); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 640px) {
  .packages-grid { grid-template-columns: 1fr; }
  .nav-right { gap: 8px; }
  .credit-pill { padding: 6px 10px; font-size: 12px; }
}
