/* ════════════════════════════════════════════════════════════
   DocMasker — Premium Dark UI
   ════════════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg:          #090c14;
  --bg-card:     #0f1421;
  --bg-glass:    rgba(255,255,255,0.04);
  --bg-hover:    rgba(255,255,255,0.07);
  --border:      rgba(255,255,255,0.08);
  --border-glow: rgba(99,102,241,0.35);
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-dim:    #334155;

  --indigo:  #6366f1;
  --violet:  #8b5cf6;
  --emerald: #10b981;
  --rose:    #f43f5e;
  --amber:   #f59e0b;
  --cyan:    #06b6d4;

  --gradient: linear-gradient(135deg, var(--indigo), var(--violet));
  --gradient-glow: 0 0 40px rgba(99,102,241,0.25), 0 0 80px rgba(139,92,246,0.12);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
  --shadow-glow: 0 8px 32px rgba(99,102,241,0.3);

  --font: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Background ── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
}

.orb {
  position: fixed; border-radius: 50%;
  filter: blur(100px); pointer-events: none; z-index: 0;
  animation: orb-drift 18s ease-in-out infinite alternate;
}
.orb-1 {
  width: 600px; height: 600px; top: -200px; right: -100px;
  background: radial-gradient(circle, rgba(99,102,241,0.18) 0%, transparent 70%);
  animation-duration: 20s;
}
.orb-2 {
  width: 500px; height: 500px; bottom: -100px; left: -150px;
  background: radial-gradient(circle, rgba(139,92,246,0.15) 0%, transparent 70%);
  animation-duration: 24s; animation-delay: -8s;
}
.orb-3 {
  width: 300px; height: 300px; top: 40%; left: 40%;
  background: radial-gradient(circle, rgba(6,182,212,0.1) 0%, transparent 70%);
  animation-duration: 16s; animation-delay: -4s;
}
@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.08); }
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  background: rgba(9,12,20,0.8);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.logo-icon {
  width: 38px; height: 38px;
  background: var(--gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.logo-icon svg { width: 20px; height: 20px; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.accent { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.header-badges { display: flex; gap: 8px; }
.badge {
  font-size: 0.7rem; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; letter-spacing: 0.04em; text-transform: uppercase;
}
.badge-ai    { background: rgba(99,102,241,0.15); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.badge-secure{ background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.25); }

/* ── Main ── */
.main {
  position: relative; z-index: 1;
  max-width: 1320px; margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Steps ── */
.steps-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-bottom: 48px;
}
.step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: relative; min-width: 80px;
  cursor: default;
}
.step-circle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  background: var(--bg-card); border: 2px solid var(--border);
  color: var(--text-muted); transition: all var(--transition);
}
.step span { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); transition: color var(--transition); }
.step.active .step-circle {
  background: var(--gradient); border-color: transparent;
  color: white; box-shadow: var(--shadow-glow);
}
.step.active span { color: var(--indigo); }
.step.done .step-circle { background: rgba(16,185,129,0.2); border-color: var(--emerald); color: var(--emerald); }
.step.done span { color: var(--emerald); }
.step-line {
  flex: 1; height: 2px; max-width: 80px;
  background: var(--border); border-radius: 2px;
  margin-bottom: 22px; transition: background var(--transition);
}

/* ── Panel ── */
.panel { animation: panel-in 0.5s cubic-bezier(0.4,0,0.2,1) both; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.hidden { display: none !important; }

/* ── Upload Panel ── */
.panel-hero {
  text-align: center; margin-bottom: 40px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 30%, #a5b4fc 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; line-height: 1.1;
}
.hero-sub {
  margin-top: 14px; font-size: 1.05rem; color: var(--text-muted);
  max-width: 520px; margin-inline: auto;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-glass);
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  max-width: 600px; margin: 0 auto 32px;
  position: relative; overflow: hidden;
}
.upload-zone::before {
  content: ''; position: absolute; inset: 0;
  background: var(--gradient); opacity: 0;
  transition: opacity var(--transition);
}
.upload-zone:hover { border-color: var(--indigo); box-shadow: var(--gradient-glow); }
.upload-zone:hover::before { opacity: 0.04; }
.upload-zone.drag-over { border-color: var(--violet); box-shadow: 0 0 60px rgba(139,92,246,0.3); }
.upload-icon { color: var(--indigo); opacity: 0.9; }
.upload-icon svg { width: 64px; height: 64px; }
.upload-text { display: flex; flex-direction: column; gap: 4px; }
.upload-text strong { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.upload-text span { font-size: 0.9rem; color: var(--text-muted); }
.upload-hint { font-size: 0.78rem; color: var(--text-dim); }
.upload-filename {
  background: rgba(99,102,241,0.15); color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 8px; padding: 8px 18px; font-size: 0.88rem;
  font-family: var(--font-mono); font-weight: 500;
}
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--indigo); font-size: inherit; font-family: inherit;
  text-decoration: underline; padding: 0;
  transition: color var(--transition);
}
.link-btn:hover { color: var(--violet); }

.upload-features {
  display: flex; gap: 16px; justify-content: center;
  flex-wrap: wrap; max-width: 600px; margin: 0 auto 36px;
}
.feature-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 20px; flex: 1; min-width: 160px;
  transition: border-color var(--transition);
}
.feature-card:hover { border-color: rgba(99,102,241,0.3); }
.feature-icon { font-size: 1.5rem; }
.feature-text { display: flex; flex-direction: column; gap: 1px; }
.feature-text strong { font-size: 0.88rem; font-weight: 600; }
.feature-text span { font-size: 0.75rem; color: var(--text-muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: 0.95rem; font-weight: 600;
  border-radius: var(--radius); border: none; cursor: pointer;
  text-decoration: none; transition: all var(--transition);
  white-space: nowrap;
}
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-primary {
  background: var(--gradient); color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  display: flex; margin: 0 auto;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.btn-primary:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none;
  box-shadow: none;
}
.btn-danger {
  background: linear-gradient(135deg, #f43f5e, #e11d48); color: white;
  box-shadow: 0 4px 16px rgba(244,63,94,0.3);
  width: 100%; justify-content: center;
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(244,63,94,0.4); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: var(--bg-glass); color: var(--text);
  border: 1px solid var(--border);
  justify-content: center;
}
.btn-ghost:hover { background: var(--bg-hover); border-color: rgba(255,255,255,0.15); }
.sm-btn {
  font-family: var(--font); font-size: 0.75rem; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-glass); color: var(--text-muted); cursor: pointer;
  transition: all var(--transition);
}
.sm-btn:hover { background: var(--bg-hover); color: var(--text); border-color: rgba(255,255,255,0.15); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-glass); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ── Processing ── */
.processing-card {
  max-width: 480px; margin: 60px auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 52px 44px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.processing-spinner {
  position: relative; width: 100px; height: 100px;
  margin: 0 auto 28px;
}
.spinner-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--indigo);
  animation: spin 1.2s linear infinite;
}
.ring-2 {
  inset: 12px;
  border-top-color: var(--violet);
  animation-duration: 0.8s; animation-direction: reverse;
}
.spinner-core {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  color: var(--indigo);
}
@keyframes spin { to { transform: rotate(360deg); } }

.processing-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.processing-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }
.progress-bar {
  height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 28px;
}
.progress-fill {
  height: 100%; width: 0%; background: var(--gradient);
  border-radius: 4px; transition: width 0.6s ease;
}
.processing-steps { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.proc-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.88rem; color: var(--text-dim);
  transition: color var(--transition);
}
.proc-step.active { color: var(--text); }
.proc-step.done { color: var(--emerald); }
.proc-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0;
  transition: background var(--transition);
}
.proc-step.active .proc-dot { background: var(--indigo); box-shadow: 0 0 8px var(--indigo); animation: pulse-dot 1s ease-in-out infinite; }
.proc-step.done .proc-dot { background: var(--emerald); box-shadow: none; animation: none; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Review Layout ── */
.review-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .review-layout { grid-template-columns: 1fr; }
}

.preview-pane, .entity-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.pane-title { font-size: 1rem; font-weight: 700; }
.page-nav { display: flex; align-items: center; gap: 10px; }
.page-counter { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.entity-actions { display: flex; gap: 8px; }

/* ── PDF Canvas ── */
.pdf-canvas-wrap {
  position: relative; overflow: auto;
  max-height: calc(100vh - 280px); min-height: 400px;
  background: #1a1d2e;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 16px;
}
#pdf-canvas {
  display: block; max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.highlight-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}
.hl-rect {
  position: absolute; border-radius: 3px;
  transition: opacity var(--transition);
  cursor: pointer; pointer-events: all;
}
.hl-rect:hover { filter: brightness(1.3); }

/* Draw mode */
.draw-mode-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font); font-size: 0.72rem; font-weight: 700;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  background: var(--bg-glass); color: var(--text-muted);
  border: 1px solid var(--border); transition: all var(--transition);
}
.draw-mode-btn:hover { background: var(--bg-hover); color: var(--text); }
.draw-mode-btn.active {
  background: rgba(245,158,11,0.15); color: var(--amber);
  border-color: rgba(245,158,11,0.4);
}
.pdf-canvas-wrap.draw-active,
.pdf-canvas-wrap.draw-active canvas { cursor: crosshair; }

.draw-select-rect {
  position: absolute; pointer-events: none;
  border: 2px dashed var(--amber);
  background: rgba(245,158,11,0.12);
  border-radius: 2px; z-index: 10;
}

.ocr-badge {
  padding: 8px 18px; background: rgba(245,158,11,0.1);
  border-top: 1px solid rgba(245,158,11,0.2);
  font-size: 0.78rem; color: var(--amber);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

/* ── Filter Pills ── */
.filter-pills {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.pill {
  font-family: var(--font); font-size: 0.72rem; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); transition: all var(--transition);
  white-space: nowrap;
}
.pill:hover { background: var(--bg-hover); color: var(--text); }
.pill.active { border-color: var(--indigo); background: rgba(99,102,241,0.15); color: #a5b4fc; }

/* ── Stats Bar ── */
.stats-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
}
.stat-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-val { font-size: 1.4rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }

/* ── Search & Redact Bar ── */
.search-redact-bar {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: rgba(245,158,11,0.04);
}
.search-redact-input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-sm); padding: 6px 10px;
  transition: border-color var(--transition);
}
.search-redact-input-wrap:focus-within { border-color: rgba(245,158,11,0.55); }
.search-icon { color: var(--amber); flex-shrink: 0; }
.search-input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font-mono); font-size: 0.82rem; color: var(--text);
  placeholder-color: var(--text-dim);
}
.search-input::placeholder { color: var(--text-dim); }
.search-btn {
  font-family: var(--font); font-size: 0.72rem; font-weight: 700;
  padding: 4px 10px; border-radius: 5px; cursor: pointer;
  background: rgba(245,158,11,0.15); color: var(--amber);
  border: 1px solid rgba(245,158,11,0.3);
  transition: all var(--transition); white-space: nowrap;
}
.search-btn:hover { background: rgba(245,158,11,0.25); }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.search-hint {
  font-size: 0.68rem; color: var(--text-dim); margin-top: 6px;
  padding-left: 2px;
}

/* ── Entity List ── */
.entity-list {
  overflow-y: auto; max-height: 420px;
  display: flex; flex-direction: column; gap: 0;
}
.entity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer; transition: background var(--transition);
  position: relative;
}
.entity-item:hover { background: var(--bg-hover); }
.entity-item.selected { background: rgba(99,102,241,0.08); }
.entity-item.hidden-filter { display: none !important; }

.entity-checkbox {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  appearance: none; -webkit-appearance: none;
  border: 2px solid var(--border); border-radius: 5px;
  background: transparent; cursor: pointer;
  transition: all var(--transition); position: relative;
}
.entity-checkbox:checked {
  background: var(--indigo); border-color: var(--indigo);
}
.entity-checkbox:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px;
  width: 6px; height: 10px;
  border: 2px solid white; border-top: none; border-left: none;
  transform: rotate(45deg);
}

.entity-color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.entity-body { flex: 1; min-width: 0; }
.entity-text {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  font-family: var(--font-mono); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.entity-meta { display: flex; gap: 8px; margin-top: 4px; align-items: center; flex-wrap: wrap; }
.entity-type {
  font-size: 0.68rem; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.entity-score { font-size: 0.72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.entity-pages { font-size: 0.7rem; color: var(--text-dim); }

/* ── Done Panel ── */
.done-card {
  max-width: 760px; margin: 40px auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 48px 48px 44px;
  text-align: center; box-shadow: var(--shadow-card);
}
@media (max-width: 820px) { .done-card { padding: 36px 24px; } }
.done-icon {
  color: var(--emerald); margin-bottom: 20px;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}
.done-title { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 8px; }
.done-sub { color: var(--text-muted); margin-bottom: 20px; }
.done-stats {
  display: flex; gap: 16px; justify-content: center;
  margin-bottom: 28px; flex-wrap: wrap;
}
.done-stat {
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 20px;
  display: flex; flex-direction: column; gap: 2px;
}
.done-stat-val { font-size: 1.5rem; font-weight: 800; color: var(--indigo); }
.done-stat-lbl { font-size: 0.75rem; color: var(--text-muted); }

/* Redacted preview inside done card */
.redacted-preview-wrap {
  background: #0b0e1a; border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 28px; text-align: left;
}
.redacted-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.redacted-preview-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
}
.redacted-page-nav { display: flex; align-items: center; gap: 10px; }
.redacted-canvas-wrap {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 20px; overflow: auto; max-height: 500px;
  background: #111420;
}
#rdone-canvas {
  display: block; max-width: 100%; border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}

.done-actions { display: flex; flex-direction: column; gap: 12px; }


/* ── Toast ── */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 24px;
  font-size: 0.9rem; font-weight: 500; color: var(--text);
  box-shadow: var(--shadow-card); z-index: 9999;
  opacity: 0; transition: all 0.3s ease;
  pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(244,63,94,0.4); color: #fda4af; }
.toast.success { border-color: rgba(16,185,129,0.4); color: #6ee7b7; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
