/* ==========================================================================
   json_fixer.css — JSON Repair Tool
   SandBox Developer Tools Extension Stylesheet
   Scoped entirely under .json-repair-tool
   Tokens pulled directly from dashboard.css variable set:
     --bg, --bg-panel, --surface-0/1/2, --border-0/1/2
     --ink-0/1/2/6/7/8, --text, --text-soft, --text-muted
     --text-xs/sm/base/md/lg/xl/2xl/3xl/4xl
     --weight-medium/semi/bold
     --radius-md/lg/xl/2xl/pill
     --shadow-md/lg/xl
     --accent, --success
     --dur-fast/base/slow, --ease, --ease-spring
     --font, --sidebar-w, --topbar-h
   ========================================================================== */

/* ─── 1. PAGE SHELL ───────────────────────────────────────────────────────── */

.json-repair-tool {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 3vw, 2rem) 5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── 2. HERO ─────────────────────────────────────────────────────────────── */

.jf-hero {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  padding: 2rem 2rem 1.875rem;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%),
    var(--bg-panel);
  border: 1px solid var(--border-0);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
}

/* Ambient orb — matches dashboard hero */
.jf-hero::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.jf-hero-copy {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.jf-hero-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1rem;
  font-weight: var(--weight-bold);
  letter-spacing: -0.05em;
  color: var(--ink-1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin-top: 2px;
}

.jf-hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.025em;
  color: var(--ink-0);
  margin: 0 0 0.375rem;
  line-height: 1.15;
}

.jf-hero-desc {
  font-size: var(--text-sm);
  color: var(--text-soft);
  line-height: 1.7;
  margin: 0;
  max-width: 60ch;
}

/* ─── 3. FEATURE PILLS ────────────────────────────────────────────────────── */

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.feature-pill {
  font-size: 10px;
  font-weight: var(--weight-semi);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.625rem;
  line-height: 1.5;
}

/* ─── 4. QUICK EXAMPLES BAR ──────────────────────────────────────────────── */

.jf-examples-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  background: var(--surface-0);
  border: 1px solid var(--border-0);
  border-radius: var(--radius-lg);
}

.jf-examples-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4375rem;
}

.chip {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-soft);
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 0.28rem 0.65rem;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease-spring);
  line-height: 1.5;
  user-select: none;
}

.chip:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--ink-1);
  transform: translateY(-1px);
}

.chip:active,
.chip.chip--active {
  transform: translateY(0) scale(0.97);
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--ink-0);
}

/* ─── 5. MAIN WORKSPACE — Two-column side-by-side editors ────────────────── */

.jf-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border-0);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  overflow: hidden;
  transition: border-color var(--dur-base) var(--ease);
}

.jf-workspace:focus-within {
  border-color: var(--border-1);
}

/* ─── 6. EDITOR PANE ─────────────────────────────────────────────────────── */

.jf-editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Divider between left and right */
.jf-editor-pane + .jf-editor-pane {
  border-left: 1px solid var(--border-0);
}

/* ─── 7. EDITOR HEADER ───────────────────────────────────────────────────── */

.jf-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6875rem 1rem;
  background: var(--ink-7);
  border-bottom: 1px solid var(--border-0);
  flex-shrink: 0;
  min-height: 44px;
}

.jf-editor-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1;
}

.jf-editor-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.jf-output-actions {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
}

/* ─── 8. ICON BUTTONS (Copy / Download / Clear) ──────────────────────────── */

.jf-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: var(--weight-semi);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease-spring);
  white-space: nowrap;
  user-select: none;
}

.jf-icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--ink-1);
  transform: translateY(-1px);
}

.jf-icon-btn:active {
  transform: translateY(0) scale(0.95);
}

/* ─── 9. CODE EDITORS — Input & Output ───────────────────────────────────── */

.jf-code-editor {
  flex: 1;
  width: 100%;
  min-height: 420px;
  resize: none;
  background: rgba(0, 0, 0, 0.28);
  border: none;
  outline: none;
  color: var(--ink-1);
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Menlo', ui-monospace, monospace;
  font-size: 0.8125rem;
  line-height: 1.75;
  padding: 1rem 1.125rem;
  tab-size: 2;
  caret-color: var(--ink-0);
  transition: background var(--dur-base) var(--ease);
  box-sizing: border-box;
  display: block;
}

.jf-code-editor::placeholder {
  color: var(--text-muted);
  opacity: 0.45;
  font-family: inherit;
}

.jf-code-editor:focus {
  background: rgba(0, 0, 0, 0.38);
  outline: none;
}

/* Output — green tint, read-only */
.jf-code-editor--output {
  background: rgba(0, 0, 0, 0.36);
  color: #4ade80;
  cursor: default;
}

.jf-code-editor--output::placeholder {
  color: var(--text-muted);
  opacity: 0.3;
}

.jf-code-editor--output:focus {
  background: rgba(0, 0, 0, 0.36);
}

/* Scrollbars — match dashboard global style */
.jf-code-editor::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.jf-code-editor::-webkit-scrollbar-track {
  background: transparent;
}

.jf-code-editor::-webkit-scrollbar-thumb {
  background: var(--border-1);
  border-radius: 10px;
}

.jf-code-editor::-webkit-scrollbar-thumb:hover {
  background: var(--border-2);
}

/* ─── 10. OUTPUT HINT OVERLAY ────────────────────────────────────────────── */

.jf-output-hint {
  position: absolute;
  inset: 44px 0 0 0; /* below editor header */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: var(--text-sm);
  pointer-events: none;
  opacity: 0.45;
}

.jf-output-hint-icon {
  font-family: 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 1.5rem;
  font-weight: var(--weight-bold);
  letter-spacing: -0.05em;
  opacity: 0.4;
}

/* Hide hint when output has content — JS removes hidden attr on status-card
   but we also hide the hint when the textarea is not empty via JS adding a class */
.jf-output-hint[hidden] {
  display: none;
}

/* ─── 11. UPLOAD STRIP ───────────────────────────────────────────────────── */

.jf-upload-strip {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  background: var(--ink-7);
  border-top: 1px solid var(--border-0);
  min-height: 56px;
  flex-wrap: wrap;
}

.jf-upload-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--dur-fast) var(--ease);
}

.jf-upload-trigger:hover {
  opacity: 0.8;
}


.jf-upload-icon {
  font-size: 1rem;
  color: var(--text-soft);
}

.jf-upload-trigger-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.jf-upload-types {
  font-size: 0.75rem;
  color: var(--text-muted);
}
/* File badge — shown after upload */
.jf-file-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-pill);
    animation: jf-fade-in var(--dur-base) var(--ease) both;
}

.jf-file-badge[hidden] {
  display: none;
}

.jf-file-badge-icon {
  font-size: 0.9rem;
  color: #4ade80;
  line-height: 1;
}

.jf-file-badge-name {
  font-size: 0.9rem;
  font-weight: var(--weight-semi);
  color: #4ade80;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
}

.jf-file-remove {
  font-size: 0.9rem;
  font-weight: var(--weight-semi);
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color var(--dur-fast) var(--ease);
  line-height: 1;
  letter-spacing: 0.03em;
}

.jf-file-remove:hover {
  color: #f87171;
}

/* Visually hidden — for accessible file input */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ─── 12. ACTION ROW — Repair button ─────────────────────────────────────── */

.jf-action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0;
}

/* Extends dashboard .btn and .btn-primary — layout only */
.json-repair-tool .repair-action-btn {
  min-width: 220px;
  min-height: 48px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
}

.json-repair-tool .repair-action-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* ─── 13. STATUS CARD ─────────────────────────────────────────────────────── */

.jf-status-card {
  padding: 1.25rem 1.5rem;
  background: rgba(74, 222, 128, 0.04);
  border: 1px solid rgba(74, 222, 128, 0.18);
  border-radius: var(--radius-xl);
  animation: jf-slide-in var(--dur-base) var(--ease) both;
}

.jf-status-card[hidden] {
  display: none;
}

.jf-status-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}

.jf-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 50%;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.jf-status-icon--success {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.22);
}

.jf-status-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: #4ade80;
  margin: 0;
}

.jf-status-body {
  padding-left: 2.25rem; /* align under title, past icon */
}

.jf-status-subtitle {
  font-size: 0.9rem;
  font-weight: var(--weight-semi);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.jf-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.jf-status-list li {
  font-size: var(--text-sm);
  color: var(--text-soft);
  padding-left: 1rem;
  position: relative;
  line-height: 1.5;
}

.jf-status-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: #4ade80;
  font-size: 0.65rem;
  top: 0.22em;
}

/* ─── 14. COMMON ISSUES SECTION ───────────────────────────────────────────── */

.jf-issues-section {
  width: 100%;
}

.jf-issues-header {
  margin-bottom: 1.25rem;
}

.jf-issues-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--ink-0);
  margin: 0 0 0.375rem;
}

.jf-issues-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* 3-column grid — matches .metrics-row pattern from dashboard */
.jf-issues-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
}

/* ─── 15. ISSUE CARDS ─────────────────────────────────────────────────────── */

/* Extends dashboard .metric-card — only adds tool-specific parts */
.jf-issue-card {
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Disable the upward lift on hover for info cards */
.jf-issue-card:hover {
  transform: none;
}

.jf-issue-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.jf-issue-compare {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.jf-issue-arrow {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.5;
  font-weight: var(--weight-bold);
}

/* Inline code fence blocks */
.jf-issue-broken,
.jf-issue-fixed {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6875rem;
  line-height: 1.5;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: inline-block;
}

.jf-issue-broken {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.18);
  color: #f87171;
  text-decoration: line-through;
  text-decoration-color: rgba(239, 68, 68, 0.4);
}

.jf-issue-fixed {
  background: rgba(74, 222, 128, 0.07);
  border: 1px solid rgba(74, 222, 128, 0.17);
  color: #4ade80;
}
.jf-output-hint.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
/* ─── 16. ANIMATIONS ─────────────────────────────────────────────────────── */

@keyframes jf-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes jf-slide-in {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── 17. RESPONSIVE — Tablet (≤ 1024px) ────────────────────────────────── */

@media (max-width: 1024px) {
  .jf-workspace {
    grid-template-columns: 1fr;
    border-radius: var(--radius-xl);
  }

  .jf-editor-pane + .jf-editor-pane {
    border-left: none;
    border-top: 1px solid var(--border-0);
  }

  .jf-issues-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .jf-hero-desc {
    max-width: 100%;
  }
}

/* ─── 18. RESPONSIVE — Mobile (≤ 768px) ─────────────────────────────────── */

@media (max-width: 768px) {
  .json-repair-tool {
    padding: 1.25rem 0 3.5rem;
    gap: 1rem;
  }

  .jf-hero {
    padding: 1.375rem 1.25rem 1.25rem;
  }

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

  .jf-hero-copy {
    flex-direction: column;
    gap: 0.75rem;
  }

  .jf-code-editor {
    min-height: 260px;
    font-size: 0.75rem;
  }

  .jf-issues-grid {
    grid-template-columns: 1fr;
  }

  .jf-action-row {
    padding: 0;
  }

  .json-repair-tool .repair-action-btn {
    width: 100%;
    min-width: unset;
  }

  .jf-examples-bar {
    gap: 0.5rem;
  }

  .jf-output-actions {
    gap: 0.25rem;
  }
}

/* ─── 19. RESPONSIVE — Small mobile (≤ 480px) ───────────────────────────── */

@media (max-width: 480px) {
  .jf-hero-title {
    font-size: var(--text-lg);
  }

  .chip-group {
    gap: 0.3125rem;
  }

  .chip {
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
  }

  .jf-icon-btn {
    font-size: 0.9rem;
    padding: 0 0.5rem;
    height: 1.75rem;
  }

  .jf-upload-types {
    display: none;
  }

  .feature-pills {
    gap: 0.375rem;
  }

  .jf-status-body {
    padding-left: 0;
  }
}

/* ─── 20. FOCUS VISIBLE — Accessibility ─────────────────────────────────── */

.json-repair-tool .jf-code-editor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.json-repair-tool .jf-icon-btn:focus-visible,
.json-repair-tool .chip:focus-visible,
.json-repair-tool .jf-upload-trigger:focus-visible,
.json-repair-tool .jf-file-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* ── Bookmark button ── */
.jf-bookmark-btn {
  color: var(--text-muted);
}
.jf-bookmark-btn:hover {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.28);
  color: #f59e0b;
}
.jf-bookmark-btn.is-bookmarked {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.32);
  color: #f59e0b;
}
.jf-bookmark-btn[hidden] {
  display: none;
}