/* =============================================================
   Translator CSV — Shadcn-style dark design system (offline)
   Glassmorphism, tokeny, badge jakości, paleta poleceń, FAB,
   graf kontekstu, diff viewer, siatka wirtualna.
   ============================================================= */

:root {
  --bg: #020617;
  --bg-elevated: #0b1120;
  --surface: rgba(15, 23, 42, 0.72);
  --surface-solid: #0f172a;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --violet: #8b5cf6;
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-glass: 0 8px 32px rgba(2, 6, 23, 0.55);
  --font-ui: 'Satoshi', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ── Tło ambient (TsParticles) ─────────────────────────── */
#particles-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 10;
}

/* ── Glassmorphism ─────────────────────────────────────── */
.glass {
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
}

.glass-panel {
  background: linear-gradient(160deg, rgba(30, 41, 59, 0.65), rgba(2, 6, 23, 0.55));
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
}

/* ── Badge jakości (zielony ≥85 / żółty ≥70 / czerwony <70) ── */
.q-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  font-family: var(--font-ui);
  white-space: nowrap;
  cursor: help;
}
.q-badge.q-green { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.4); }
.q-badge.q-yellow { background: rgba(245, 158, 11, 0.14); color: #fcd34d; border-color: rgba(251, 191, 36, 0.4); }
.q-badge.q-red { background: rgba(239, 68, 68, 0.14); color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); }
.q-badge .dot { width: 0.4rem; height: 0.4rem; border-radius: 999px; background: currentColor; }

/* Tooltip rozbicia score'u (COMET-QE / similarity / confidence) */
.q-breakdown {
  position: fixed;
  z-index: 99998;
  min-width: 220px;
  padding: 0.6rem 0.75rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-glass);
  font-size: 0.72rem;
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.q-breakdown.show { opacity: 1; }
.q-breakdown .row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.1rem 0; }
.q-breakdown .row span:first-child { color: var(--text-muted); }
.q-breakdown .row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Paleta poleceń (Cmd+K) ────────────────────────────── */
#command-palette {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(4px);
}
#command-palette.open { display: flex; }
.cp-panel {
  width: min(560px, 92vw);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 0.9rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.cp-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  font-family: var(--font-ui);
}
.cp-list { max-height: 320px; overflow-y: auto; padding: 0.35rem; }
.cp-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  border: none;
  background: transparent;
  font-family: var(--font-ui);
}
.cp-item .kbd { margin-left: auto; font-size: 0.68rem; color: var(--text-faint); }
.cp-item:hover, .cp-item.active { background: var(--accent-soft); color: #fff; }
.cp-empty { padding: 1rem; text-align: center; color: var(--text-faint); font-size: 0.8rem; }

/* ── Floating Action Bar (Motion.dev) ──────────────────── */
#fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}
.fab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-glass);
  transition: transform 0.15s ease, background 0.15s ease;
}
.fab-btn:hover { background: rgba(30, 41, 59, 0.9); transform: translateY(-1px); }
.fab-btn.primary { background: linear-gradient(135deg, #2563eb, #7c3aed); border-color: transparent; color: #fff; }
.fab-btn.danger { background: rgba(239, 68, 68, 0.18); border-color: rgba(248, 113, 113, 0.5); color: #fca5a5; }
.fab-btn svg { width: 1.1rem; height: 1.1rem; }

/* ── Graf kontekstu ────────────────────────────────────── */
#graph-view {
  position: fixed;
  inset: 0;
  z-index: 99980;
  display: none;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(8px);
}
#graph-view.open { display: block; }
.graph-canvas { width: 100%; height: 100%; position: relative; overflow: hidden; }
.graph-node {
  position: absolute;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.75rem;
  font-family: var(--font-ui);
  transform: translate(-50%, -50%);
  white-space: nowrap;
}
.graph-node.role-key { border-color: rgba(139, 92, 246, 0.6); }
.graph-node.role-language { border-color: rgba(59, 130, 246, 0.6); }
.graph-node.role-title { border-color: rgba(52, 211, 153, 0.55); }
.graph-node.role-description { border-color: rgba(251, 191, 36, 0.5); }
.graph-edge {
  position: absolute;
  height: 1px;
  transform-origin: 0 0;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.6), rgba(139, 92, 246, 0.6));
  pointer-events: none;
}

/* ── Diff viewer (Anime.js) ────────────────────────────── */
#diff-modal {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
  padding: 2rem;
}
#diff-modal.open { display: flex; }
.diff-panel {
  width: min(880px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.diff-body { display: grid; grid-template-columns: 1fr 1fr; gap: 0; overflow: auto; }
.diff-col { padding: 1rem; min-height: 160px; }
.diff-col.source { border-right: 1px solid var(--border); }
.diff-col h4 {
  margin: 0 0 0.6rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-family: var(--font-ui);
}
.diff-text { font-size: 0.9rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; }
.diff-token.added { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; border-radius: 3px; }
.diff-token.removed { background: rgba(248, 113, 113, 0.18); color: #fca5a5; border-radius: 3px; text-decoration: line-through; }

/* ── Siatka wirtualna ──────────────────────────────────── */
#virtual-grid {
  position: fixed;
  inset: 0;
  z-index: 99970;
  display: none;
  flex-direction: column;
  background: rgba(2, 6, 23, 0.94);
  backdrop-filter: blur(8px);
}
#virtual-grid.open { display: flex; }
.vg-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-ui);
}
.vg-scroll { flex: 1; overflow: auto; position: relative; }
.vg-spacer { width: 100%; }
.vg-rows { position: absolute; top: 0; left: 0; right: 0; }
.vg-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  font-size: 0.75rem;
  font-family: var(--font-ui);
}
.vg-row:hover { background: rgba(30, 41, 59, 0.4); }
.vg-cell {
  padding: 0.35rem 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid rgba(148, 163, 184, 0.06);
  color: var(--text);
}
.vg-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  background: rgba(15, 23, 42, 0.98);
  border-bottom: 1px solid var(--border-strong);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: var(--font-ui);
}
.vg-hcell {
  padding: 0.45rem 0.6rem;
  border-right: 1px solid rgba(148, 163, 184, 0.06);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Kontrolki Shadcn-like ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: rgba(30, 41, 59, 0.9); border-color: rgba(148, 163, 184, 0.4); }
.btn.primary { background: linear-gradient(135deg, #2563eb, #7c3aed); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(30, 41, 59, 0.5); }

/* Pasek postępu glass */
.progress-track { height: 0.4rem; border-radius: 999px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #34d399);
  transition: width 0.3s ease;
}
