/*
 * js-tool.css - JavaScript Formatter & Minifier
 * ─────────────────────────────────────────────────────────────────
 * Aesthetic: "Amber Terminal" - dark studio with JS amber/gold accents.
 * All selectors scoped to #jst-root. Zero interference with other tools.
 * ─────────────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */
#jst-root {
  --jst-bg          : #080811;
  --jst-surface     : #0f0f1c;
  --jst-surface-2   : #141422;
  --jst-border      : #1c1c30;
  --jst-border-soft : rgba(255,255,255,0.06);

  --jst-amber       : #f59e0b;
  --jst-amber-light : #fbbf24;
  --jst-amber-glow  : rgba(245,158,11,0.15);
  --jst-amber-dark  : #d97706;

  --jst-green       : #22c55e;
  --jst-green-glow  : rgba(34,197,94,0.15);

  --jst-red         : #f87171;
  --jst-red-glow    : rgba(248,113,113,0.12);

  --jst-blue        : #60a5fa;
  --jst-blue-glow   : rgba(96,165,250,0.12);

  --jst-text        : #e2e2f0;
  --jst-text-soft   : #9394a8;
  --jst-text-muted  : #52526a;

  --jst-radius      : 10px;
  --jst-radius-lg   : 14px;
  --jst-shadow      : 0 4px 24px rgba(0,0,0,0.4);
  --jst-shadow-lg   : 0 8px 48px rgba(0,0,0,0.6);

  --jst-font-ui   : 'Sora', sans-serif;
  --jst-font-code : 'JetBrains Mono', monospace;

  font-family : var(--jst-font-ui);
  color       : var(--jst-text);
  background  : var(--jst-bg);
  min-height  : 100vh;
  padding-bottom: 80px;
}

/* ═══════════════════════════════════════════════════════════════
   HERO
═══════════════════════════════════════════════════════════════ */
.jst-hero {
  text-align : center;
  padding    : 52px 24px 40px;
  max-width  : 700px;
  margin     : 0 auto;
}

.jst-hero-badge {
  display        : inline-flex;
  align-items    : center;
  gap            : 7px;
  font-size      : 11.5px;
  font-weight    : 600;
  letter-spacing : 0.08em;
  text-transform : uppercase;
  color          : var(--jst-amber);
  background     : var(--jst-amber-glow);
  border         : 1px solid rgba(245,158,11,0.25);
  border-radius  : 100px;
  padding        : 6px 14px;
  margin-bottom  : 20px;
}

.jst-hero-badge svg {
  width  : 13px;
  height : 13px;
}

.jst-hero-title {
  font-size   : clamp(28px, 5vw, 44px);
  font-weight : 800;
  line-height : 1.15;
  margin      : 0 0 14px;
  color       : var(--jst-text);
  letter-spacing: -0.02em;
}

.jst-hero-title span {
  color              : var(--jst-amber);
  position           : relative;
}

.jst-hero-sub {
  font-size   : 15px;
  line-height : 1.7;
  color       : var(--jst-text-soft);
  margin      : 0;
}

/* ═══════════════════════════════════════════════════════════════
   WORKSPACE WRAP
═══════════════════════════════════════════════════════════════ */
.jst-workspace-wrap {
  max-width : 1440px;
  margin    : 0 auto;
  padding   : 0 20px;
}

/* ═══════════════════════════════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════════════════════════════ */
.jst-toolbar {
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  flex-wrap       : wrap;
  gap             : 8px;
  background      : var(--jst-surface);
  border          : 1px solid var(--jst-border);
  border-radius   : var(--jst-radius-lg) var(--jst-radius-lg) 0 0;
  padding         : 10px 14px;
}

.jst-toolbar-left,
.jst-toolbar-right {
  display     : flex;
  align-items : center;
  gap         : 6px;
  flex-wrap   : wrap;
}

.jst-toolbar-sep {
  width        : 1px;
  height       : 22px;
  background   : var(--jst-border);
  margin       : 0 4px;
  flex-shrink  : 0;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.jst-btn {
  display         : inline-flex;
  align-items     : center;
  gap             : 6px;
  border          : none;
  border-radius   : 7px;
  font-family     : var(--jst-font-ui);
  font-size       : 13px;
  font-weight     : 600;
  cursor          : pointer;
  padding         : 7px 14px;
  transition      : background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s, transform 0.1s;
  white-space     : nowrap;
  position        : relative;
  overflow        : hidden;
}

.jst-btn svg {
  width       : 14px;
  height      : 14px;
  flex-shrink : 0;
}

.jst-btn:active:not(:disabled) {
  transform : scale(0.97);
}

.jst-btn:disabled {
  opacity : 0.5;
  cursor  : not-allowed;
}

/* Primary - amber */
.jst-btn-primary {
  background  : var(--jst-amber);
  color       : #0a0a0f;
}

.jst-btn-primary:hover:not(:disabled) {
  background  : var(--jst-amber-light);
  box-shadow  : 0 0 20px var(--jst-amber-glow);
}

/* Secondary - outline amber */
.jst-btn-secondary {
  background  : transparent;
  color       : var(--jst-amber);
  border      : 1.5px solid rgba(245,158,11,0.4);
}

.jst-btn-secondary:hover:not(:disabled) {
  background : var(--jst-amber-glow);
  border-color: var(--jst-amber);
}

/* Ghost */
.jst-btn-ghost {
  background  : transparent;
  color       : var(--jst-text-soft);
  border      : 1.5px solid var(--jst-border);
}

.jst-btn-ghost:hover:not(:disabled) {
  background  : var(--jst-surface-2);
  color       : var(--jst-text);
  border-color: rgba(255,255,255,0.15);
}

/* Danger */
.jst-btn-danger {
  background  : transparent;
  color       : var(--jst-red);
  border      : 1.5px solid rgba(248,113,113,0.25);
}

.jst-btn-danger:hover:not(:disabled) {
  background   : var(--jst-red-glow);
  border-color : var(--jst-red);
}

/* Small variant */
.jst-btn-sm {
  font-size : 12px;
  padding   : 6px 11px;
}

/* ── Copy button states ──────────────────────────────────────── */
.jst-btn .jst-icon-check { display: none; }

.jst-btn.jst-copied {
  background   : var(--jst-green-glow) !important;
  color        : var(--jst-green) !important;
  border-color : rgba(34,197,94,0.4) !important;
}

.jst-btn.jst-copied .jst-icon-copy  { display: none; }
.jst-btn.jst-copied .jst-icon-check { display: block; }

/* ── Loading spinner ─────────────────────────────────────────── */
.jst-btn-loader {
  display    : none;
  width      : 12px;
  height     : 12px;
  border     : 2px solid rgba(255,255,255,0.25);
  border-top : 2px solid currentColor;
  border-radius: 50%;
  animation  : jst-spin 0.7s linear infinite;
}

.jst-btn.jst-loading .jst-btn-loader { display: block; }
.jst-btn.jst-loading > svg           { display: none; }
.jst-btn.jst-loading > span:not(.jst-btn-loader) { display: none; }

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

/* ═══════════════════════════════════════════════════════════════
   OPTIONS PANEL
═══════════════════════════════════════════════════════════════ */
.jst-opts-container {
  position : relative;
}

.jst-opts-chevron {
  width      : 13px !important;
  height     : 13px !important;
  transition : transform 0.2s;
  margin-left: 2px;
}

#jst-opts-panel.jst-visible ~ * .jst-opts-chevron,
.jst-opts-container:has(.jst-visible) .jst-opts-chevron {
  transform : rotate(180deg);
}

.jst-opts-panel {
  position      : absolute;
  top           : calc(100% + 8px);
  right         : 0;
  z-index       : 200;
  width         : 260px;
  background    : var(--jst-surface-2);
  border        : 1px solid var(--jst-border);
  border-radius : var(--jst-radius-lg);
  box-shadow    : var(--jst-shadow-lg);
  padding       : 6px 0 2px;
  transform     : translateY(-8px) scale(0.97);
  opacity       : 0;
  pointer-events: none;
  transition    : opacity 0.18s, transform 0.18s;
}

.jst-opts-panel.jst-visible {
  opacity       : 1;
  transform     : translateY(0) scale(1);
  pointer-events: auto;
}

.jst-opts-header {
  font-size   : 10.5px;
  font-weight : 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color       : var(--jst-text-muted);
  padding     : 6px 16px 10px;
}

.jst-opt-group {
  padding     : 8px 16px;
  border-bottom: 1px solid var(--jst-border-soft);
}

.jst-opt-group-last {
  border-bottom: none;
  padding-bottom: 12px;
}

.jst-opt-label {
  font-size  : 13px;
  font-weight: 500;
  color      : var(--jst-text);
  display    : block;
  margin-bottom: 8px;
}

.jst-opt-hint {
  font-size  : 11.5px;
  color      : var(--jst-text-muted);
  margin     : 4px 0 0;
}

.jst-toggle-row {
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  cursor          : pointer;
}

.jst-toggle-row .jst-opt-label {
  margin-bottom : 0;
}

/* Segmented control */
.jst-seg {
  display        : flex;
  background     : var(--jst-bg);
  border         : 1px solid var(--jst-border);
  border-radius  : 7px;
  overflow       : hidden;
}

.jst-seg-btn {
  flex           : 1;
  background     : transparent;
  border         : none;
  color          : var(--jst-text-soft);
  font-family    : var(--jst-font-ui);
  font-size      : 12px;
  font-weight    : 500;
  padding        : 6px 8px;
  cursor         : pointer;
  transition     : background 0.15s, color 0.15s;
}

.jst-seg-btn:hover  { color: var(--jst-text); }

.jst-seg-btn.jst-active {
  background : var(--jst-amber-glow);
  color      : var(--jst-amber);
  font-weight: 600;
}

/* Toggle switch */
.jst-switch {
  cursor      : pointer;
  user-select : none;
}

.jst-switch input { display: none; }

.jst-switch-track {
  display       : block;
  width         : 36px;
  height        : 20px;
  background    : var(--jst-border);
  border-radius : 100px;
  position      : relative;
  transition    : background 0.2s;
}

.jst-switch-track::after {
  content       : '';
  position      : absolute;
  top           : 3px;
  left          : 3px;
  width         : 14px;
  height        : 14px;
  background    : var(--jst-text-muted);
  border-radius : 50%;
  transition    : left 0.2s, background 0.2s;
}

.jst-switch input:checked + .jst-switch-track {
  background : var(--jst-amber-glow);
  border     : 1.5px solid rgba(245,158,11,0.5);
}

.jst-switch input:checked + .jst-switch-track::after {
  left       : 17px;
  background : var(--jst-amber);
}

/* ═══════════════════════════════════════════════════════════════
   EDITOR WORKSPACE (SPLIT)
═══════════════════════════════════════════════════════════════ */
.jst-workspace {
  display          : grid;
  grid-template-columns: 1fr 32px 1fr;
  align-items      : stretch;
  min-height       : 440px;
  border           : 1px solid var(--jst-border);
  border-top       : none;
  background       : var(--jst-surface);
}

/* Panel */
.jst-panel {
  display        : flex;
  flex-direction : column;
  min-width      : 0;
  transition     : box-shadow 0.3s;
}

.jst-panel-header {
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  padding         : 9px 14px;
  border-bottom   : 1px solid var(--jst-border);
  background      : rgba(255,255,255,0.02);
}

.jst-panel-label {
  display     : flex;
  align-items : center;
  gap         : 8px;
  font-size   : 12px;
  font-weight : 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color       : var(--jst-text-soft);
}

.jst-panel-dot {
  width         : 8px;
  height        : 8px;
  border-radius : 50%;
  flex-shrink   : 0;
}

.jst-dot-amber { background: var(--jst-amber); box-shadow: 0 0 6px var(--jst-amber-glow); }
.jst-dot-green { background: var(--jst-green);  box-shadow: 0 0 6px var(--jst-green-glow); }

.jst-panel-meta {
  display     : flex;
  align-items : center;
  gap         : 4px;
  flex-wrap   : wrap;
}

.jst-meta-item {
  font-size  : 11.5px;
  color      : var(--jst-text-muted);
  font-family: var(--jst-font-code);
}

.jst-meta-sep {
  color      : var(--jst-text-muted);
  font-size  : 11px;
  opacity    : 0.5;
}

.jst-savings-badge {
  display        : inline-flex;
  align-items    : center;
  background     : var(--jst-green-glow);
  color          : var(--jst-green);
  border         : 1px solid rgba(34,197,94,0.25);
  border-radius  : 100px;
  font-size      : 10.5px;
  font-weight    : 700;
  padding        : 1px 8px;
  margin-left    : 4px;
}

/* Panel flash animation */
@keyframes jst-flash {
  0%   { box-shadow: inset 0 0 0 1.5px var(--jst-green); }
  100% { box-shadow: inset 0 0 0 1.5px transparent; }
}

.jst-panel.jst-flash {
  animation: jst-flash 0.6s ease-out forwards;
}

/* Divider */
.jst-panel-divider {
  display         : flex;
  align-items     : center;
  justify-content : center;
  border-left     : 1px solid var(--jst-border);
  border-right    : 1px solid var(--jst-border);
  background      : var(--jst-surface-2);
}

.jst-divider-icon {
  width       : 14px;
  height      : 14px;
  color       : var(--jst-text-muted);
  flex-shrink : 0;
}

/* Editor wrap - fills the panel */
.jst-editor-wrap {
  flex    : 1;
  display : flex;
  flex-direction: column;
}

.jst-editor-wrap .CodeMirror {
  flex        : 1;
  height      : 100%;
  min-height  : 380px;
  font-family : var(--jst-font-code);
  font-size   : 13.5px;
  line-height : 1.65;
}

.jst-editor-out .CodeMirror-cursor {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOM CODEMIRROR THEME: jstool
═══════════════════════════════════════════════════════════════ */
.cm-s-jstool.CodeMirror {
  background  : #080811;
  color       : #c8c8e0;
  border-color: transparent;
}

.cm-s-jstool .CodeMirror-gutters {
  background   : #0c0c18;
  border-right : 1px solid #1a1a2c;
  min-width    : 46px;
}

.cm-s-jstool .CodeMirror-linenumber {
  color       : #3a3a56;
  font-size   : 12px;
  padding     : 0 10px 0 6px;
  user-select : none;
}

.cm-s-jstool .CodeMirror-activeline-background { background: rgba(245,158,11,0.05); }
.cm-s-jstool .CodeMirror-selected { background: rgba(96,165,250,0.18) !important; }
.cm-s-jstool .CodeMirror-focused .CodeMirror-selected { background: rgba(96,165,250,0.22) !important; }
.cm-s-jstool .CodeMirror-cursor { border-left: 2px solid var(--jst-amber); }

.cm-s-jstool .CodeMirror-matchingbracket {
  background    : rgba(245,158,11,0.2);
  color         : var(--jst-amber) !important;
  border-radius : 2px;
  outline       : 1px solid rgba(245,158,11,0.4);
}

/* Syntax tokens */
.cm-s-jstool span.cm-keyword    { color: #f59e0b; font-weight: 600; }
.cm-s-jstool span.cm-atom       { color: #f87171; }
.cm-s-jstool span.cm-number     { color: #fb923c; }
.cm-s-jstool span.cm-def        { color: #60a5fa; }
.cm-s-jstool span.cm-variable   { color: #c8c8e0; }
.cm-s-jstool span.cm-variable-2 { color: #a5b4fc; }
.cm-s-jstool span.cm-variable-3 { color: #67e8f9; }
.cm-s-jstool span.cm-property   { color: #c4b5fd; }
.cm-s-jstool span.cm-operator   { color: #94a3b8; }
.cm-s-jstool span.cm-comment    { color: #4a4a66; font-style: italic; }
.cm-s-jstool span.cm-string     { color: #86efac; }
.cm-s-jstool span.cm-string-2   { color: #6ee7b7; }
.cm-s-jstool span.cm-qualifier  { color: #fbbf24; }
.cm-s-jstool span.cm-type       { color: #67e8f9; font-style: italic; }
.cm-s-jstool span.cm-tag        { color: #f87171; }
.cm-s-jstool span.cm-bracket    { color: #7c7c9a; }
.cm-s-jstool span.cm-error      { color: #f87171; border-bottom: 1px wavy #f87171; }
.cm-s-jstool span.cm-builtin    { color: #fbbf24; }

/* Scrollbars */
.cm-s-jstool .CodeMirror-scroll::-webkit-scrollbar       { width: 8px; height: 8px; }
.cm-s-jstool .CodeMirror-scroll::-webkit-scrollbar-track { background: transparent; }
.cm-s-jstool .CodeMirror-scroll::-webkit-scrollbar-thumb { background: #2a2a3e; border-radius: 4px; }
.cm-s-jstool .CodeMirror-scroll::-webkit-scrollbar-thumb:hover { background: #3a3a56; }

/* Placeholder */
.CodeMirror pre.CodeMirror-placeholder { color: #3a3a56 !important; }

/* ═══════════════════════════════════════════════════════════════
   STATUS BAR
═══════════════════════════════════════════════════════════════ */
.jst-status {
  display     : flex;
  align-items : center;
  gap         : 8px;
  padding     : 10px 16px;
  border      : 1px solid var(--jst-border);
  border-top  : none;
  border-radius: 0 0 var(--jst-radius-lg) var(--jst-radius-lg);
  background  : var(--jst-surface);
  font-size   : 13px;
  font-weight : 500;
  max-height  : 0;
  overflow    : hidden;
  opacity     : 0;
  padding-top : 0;
  padding-bottom: 0;
  transition  : max-height 0.25s, opacity 0.25s, padding 0.25s;
}

.jst-status.jst-visible {
  max-height  : 60px;
  opacity     : 1;
  padding-top : 10px;
  padding-bottom: 10px;
}

.jst-status-icon {
  width       : 15px;
  height      : 15px;
  flex-shrink : 0;
}

.jst-status-icon .jst-icon-ok,
.jst-status-icon .jst-icon-err,
.jst-status-icon .jst-icon-info {
  display: none;
}

/* Status types */
.jst-status-success {
  background   : rgba(34,197,94,0.08);
  border-color : rgba(34,197,94,0.2);
  color        : var(--jst-green);
}

.jst-status-success .jst-icon-ok  { display: inline; }

.jst-status-error {
  background   : rgba(248,113,113,0.08);
  border-color : rgba(248,113,113,0.2);
  color        : var(--jst-red);
}

.jst-status-error .jst-icon-err   { display: inline; }

.jst-status-warn {
  background   : rgba(245,158,11,0.08);
  border-color : rgba(245,158,11,0.2);
  color        : var(--jst-amber);
}

.jst-status-warn .jst-icon-info   { display: inline; }

.jst-status-info {
  background   : rgba(96,165,250,0.08);
  border-color : rgba(96,165,250,0.2);
  color        : var(--jst-blue);
}

.jst-status-info .jst-icon-info   { display: inline; }

/* ═══════════════════════════════════════════════════════════════
   INFO GRID (SEO)
═══════════════════════════════════════════════════════════════ */
.jst-info-grid {
  max-width      : 1440px;
  margin         : 40px auto 0;
  padding        : 0 20px;
  display        : grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap            : 14px;
}

.jst-info-card {
  background    : var(--jst-surface);
  border        : 1px solid var(--jst-border);
  border-radius : var(--jst-radius-lg);
  padding       : 22px;
  transition    : border-color 0.2s;
}

.jst-info-card:hover {
  border-color : rgba(245,158,11,0.2);
}

.jst-info-icon {
  width         : 36px;
  height        : 36px;
  background    : var(--jst-amber-glow);
  border        : 1px solid rgba(245,158,11,0.2);
  border-radius : 8px;
  display       : flex;
  align-items   : center;
  justify-content: center;
  margin-bottom : 14px;
  color         : var(--jst-amber);
}

.jst-info-icon svg {
  width  : 16px;
  height : 16px;
}

.jst-info-card h3 {
  font-size   : 15px;
  font-weight : 700;
  color       : var(--jst-text);
  margin      : 0 0 8px;
}

.jst-info-card p {
  font-size   : 13.5px;
  line-height : 1.7;
  color       : var(--jst-text-soft);
  margin      : 0;
}

/* ═══════════════════════════════════════════════════════════════
   FAQ
═══════════════════════════════════════════════════════════════ */
.jst-faq-section {
  max-width : 760px;
  margin    : 40px auto 0;
  padding   : 0 20px;
}

.jst-faq-title {
  font-size   : 22px;
  font-weight : 800;
  color       : var(--jst-text);
  margin      : 0 0 20px;
  letter-spacing: -0.01em;
}

.jst-faq-list {
  display       : flex;
  flex-direction: column;
  gap           : 1px;
  border        : 1px solid var(--jst-border);
  border-radius : var(--jst-radius-lg);
  overflow      : hidden;
}

.jst-faq-item {
  background : var(--jst-surface);
  border-bottom: 1px solid var(--jst-border-soft);
}

.jst-faq-item:last-child { border-bottom: none; }

.jst-faq-q {
  width           : 100%;
  display         : flex;
  align-items     : center;
  justify-content : space-between;
  gap             : 12px;
  background      : transparent;
  border          : none;
  padding         : 16px 20px;
  font-family     : var(--jst-font-ui);
  font-size       : 14px;
  font-weight     : 600;
  color           : var(--jst-text);
  cursor          : pointer;
  text-align      : left;
  transition      : color 0.15s, background 0.15s;
}

.jst-faq-q svg {
  width      : 16px;
  height     : 16px;
  flex-shrink: 0;
  color      : var(--jst-text-muted);
  transition : transform 0.25s;
}

.jst-faq-q:hover {
  color      : var(--jst-amber);
  background : rgba(245,158,11,0.04);
}

.jst-faq-item.jst-open .jst-faq-q { color: var(--jst-amber); }
.jst-faq-item.jst-open .jst-faq-q svg { transform: rotate(180deg); color: var(--jst-amber); }

.jst-faq-a {
  max-height  : 0;
  overflow    : hidden;
  transition  : max-height 0.3s ease, padding 0.3s;
  font-size   : 13.5px;
  line-height : 1.7;
  color       : var(--jst-text-soft);
  padding     : 0 20px;
}

.jst-faq-item.jst-open .jst-faq-a {
  max-height : 200px;
  padding    : 0 20px 18px;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .jst-hero { padding: 36px 16px 28px; }

  .jst-workspace-wrap { padding: 0 12px; }

  .jst-toolbar {
    border-radius: var(--jst-radius-lg);
    margin-bottom: 1px;
    flex-direction: column;
    align-items: stretch;
  }

  .jst-toolbar-left,
  .jst-toolbar-right {
    flex-wrap : wrap;
  }

  .jst-workspace {
    grid-template-columns: 1fr;
    grid-template-rows   : auto 28px auto;
    border-top: none;
  }

  .jst-panel-divider {
    border       : none;
    border-top   : 1px solid var(--jst-border);
    border-bottom: 1px solid var(--jst-border);
    justify-content: flex-start;
    padding-left : 16px;
  }

  .jst-divider-icon {
    transform : rotate(90deg);
  }

  .jst-editor-wrap .CodeMirror {
    min-height : 260px;
  }

  .jst-opts-panel {
    right : auto;
    left  : 0;
    width : calc(100vw - 24px);
    max-width: 320px;
  }

  .jst-toolbar-sep { display: none; }

  .jst-btn span { display: none; }
  .jst-btn      { padding: 8px 10px; }

  /* Show labels for primary action buttons on mobile */
  .jst-btn-primary span,
  .jst-btn-secondary span,
  .jst-copy-label { display: inline; }

  .jst-info-grid { padding: 0 12px; }
  .jst-faq-section { padding: 0 12px; }
}

@media (max-width: 480px) {
  .jst-hero-title { font-size: 26px; }
  .jst-hero-sub   { font-size: 13.5px; }
}
