/* ── JSON / JWT / Base64 Formatter ──────────────────────────────────── */

/* Tabs */
.fmt-tabs {
  display: flex;
  gap: 0;
  margin-top: 20px;
  border-bottom: 2px solid var(--border);
  position: relative;
}
.fmt-tab {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  font-family: inherit;
}
.fmt-tab:hover {
  color: var(--text);
}
.fmt-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Panels */
.fmt-panel {
  margin-top: 16px;
  animation: fmtFadeIn .3s ease-out;
}
.fmt-panel:not(.active) {
  display: none;
}
@keyframes fmtFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Split pane (JSON + Base64) */
.fmt-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Labels */
.fmt-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}

/* Textarea */
.fmt-textarea {
  width: 100%;
  min-height: 220px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.fmt-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,138,248,.25);
}
.fmt-textarea::placeholder {
  color: var(--muted);
  opacity: .5;
}
.fmt-textarea--short {
  min-height: 100px;
}

/* Output area */
.fmt-output {
  width: 100%;
  min-height: 220px;
  max-height: 600px;
  overflow: auto;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  position: relative;
}
.fmt-output pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* Syntax highlighting */
.hl-key     { color: var(--accent); }
.hl-string  { color: #4ade80; }
.hl-number  { color: #22d3ee; }
.hl-bool    { color: #fb923c; }
.hl-null    { color: var(--muted); font-style: italic; }
.hl-bracket { color: var(--muted2); }
.hl-colon   { color: var(--muted); }
.hl-line-num {
  display: inline-block;
  min-width: 32px;
  padding-right: 12px;
  text-align: right;
  color: var(--muted);
  opacity: .4;
  user-select: none;
  font-size: 11px;
}

/* Status badges */
.fmt-status {
  min-height: 24px;
  margin: 8px 0 4px;
  font-size: 12px;
  font-weight: 600;
  transition: color .2s;
}
.fmt-status--valid {
  color: #22c55e;
}
.fmt-status--valid::before {
  content: '\2713 ';
}
.fmt-status--invalid {
  color: var(--danger);
}
.fmt-status--invalid::before {
  content: '\2717 ';
}

/* Button row */
.fmt-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

/* Buttons */
.fmt-btn-row .btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: opacity .2s, transform .15s, filter .2s, background .2s;
  white-space: nowrap;
  font-family: inherit;
}
.fmt-btn-row .btn:active {
  transform: scale(0.97);
}
.fmt-btn-row .btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.fmt-btn-row .btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: var(--white);
}
.fmt-btn-row .btn-primary:hover {
  filter: brightness(1.1);
}

.fmt-btn-row .btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}
.fmt-btn-row .btn-secondary:hover {
  background: var(--surface3, rgba(255,255,255,.08));
  border-color: var(--accent);
}

.fmt-btn-row .btn-ghost {
  background: transparent;
  color: var(--muted2);
}
.fmt-btn-row .btn-ghost:hover {
  color: var(--accent);
  background: rgba(91,138,248,.08);
}
.fmt-btn-row .btn-ghost.copied {
  color: #22c55e;
}

/* Select (indent) */
.fmt-select {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .2s;
}
.fmt-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Byte size display */
.fmt-byte-size {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  min-height: 16px;
}

/* ── JWT ───────────────────────────────────────────────────────────── */
.jwt-results {
  margin-top: 20px;
  animation: fmtFadeIn .3s ease-out;
}
.jwt-section {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.jwt-section:last-child {
  margin-bottom: 0;
}
.jwt-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.jwt-section-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.jwt-algo {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  background: rgba(91,138,248,.12);
  color: var(--accent);
  border-radius: 6px;
}
.jwt-expiry-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  border-radius: 6px;
}
.jwt-expiry-badge--valid {
  background: rgba(34,197,94,.12);
  color: #22c55e;
}
.jwt-expiry-badge--expired {
  background: rgba(239,68,68,.12);
  color: var(--danger);
}
.jwt-section .fmt-output {
  min-height: 60px;
  max-height: 300px;
}
.jwt-sig-note {
  font-size: 13px;
  color: var(--muted2);
  line-height: 1.6;
  margin: 0;
}

/* ── Info section ──────────────────────────────────────────────────── */
.info-section {
  margin-top: 32px;
}
.info-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(91,138,248,.15);
}
.info-section p {
  font-size: 14px;
  color: var(--muted2);
  line-height: 1.7;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .fmt-pane {
    grid-template-columns: 1fr;
  }
  .fmt-tabs {
    gap: 0;
  }
  .fmt-tab {
    padding: 10px 16px;
    font-size: 13px;
  }
  .fmt-textarea {
    min-height: 160px;
  }
  .fmt-output {
    min-height: 160px;
  }
  .fmt-btn-row {
    gap: 6px;
  }
  .fmt-btn-row .btn {
    padding: 7px 14px;
    font-size: 12px;
  }
}
@media (max-width: 480px) {
  .fmt-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
  .fmt-btn-row {
    flex-wrap: wrap;
  }
}


/* ── Placeholder example text ──────────────────────────────────────── */
.fmt-textarea.fmt-placeholder {
  color: var(--muted);
  opacity: .45;
}


/* ── Hash tab ─────────────────────────────────────────────────────── */
.fmt-pane--single { display: block; }
.fmt-pane--single .fmt-input-col { max-width: 100%; }
.hash-info { font-size: 12px; color: var(--muted); margin: 12px 0 8px; }
.hash-results { margin-top: 12px; display: flex; flex-direction: column; gap: 0; }
.hash-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.hash-row:last-child { border-bottom: none; }
.hash-algo { font-size: 11px; font-weight: 700; color: var(--muted); min-width: 60px; text-transform: uppercase; }
.hash-val { font-family: monospace; font-size: 12px; color: var(--text); flex: 1; word-break: break-all; background: var(--surface2); padding: 4px 8px; border-radius: 4px; }
.hash-copy-btn { flex-shrink: 0; }

/* ── Punycode tab ────────────────────────────────────────────────── */
.mono { font-family: monospace; }
.fmt-status--ok { color: var(--success, #22c55e); }
.fmt-status--error { color: var(--danger, var(--danger)); }

/* ── Password strength ──────────────────────────────────────────── */
.pwd-meter-wrap { display: flex; align-items: center; gap: 12px; margin: 16px 0 12px; }
.pwd-meter-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.pwd-meter-fill { height: 100%; border-radius: 4px; transition: width .3s, background .3s; }
.pwd-score-label { font-weight: 700; font-size: 14px; min-width: 100px; }
.pwd-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.pwd-stat { display: flex; align-items: center; gap: 6px; background: var(--surface2); border-radius: 6px; padding: 6px 12px; }
.pwd-stat-label { font-size: 12px; color: var(--muted); }
.pwd-stat-val { font-size: 12px; font-weight: 700; }
.pwd-stat-val--ok  { color: #22c55e; }
.pwd-stat-val--bad { color: var(--danger); }

/* ── URL Expander ────────────────────────────────────────────────── */
.urlexp-chain { display: flex; flex-direction: column; gap: 0; margin-top: 12px; }
.urlexp-hop { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.urlexp-hop:last-child { border-bottom: none; }
.urlexp-hop--final { background: rgba(74,222,128,.05); border-radius: 6px; padding: 10px; border: 1px solid rgba(74,222,128,.2); }
.urlexp-hop-num { font-size: 11px; font-weight: 700; color: var(--muted); min-width: 80px; padding-top: 2px; }
.urlexp-status { font-size: 12px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.urlexp-status--ok       { background: rgba(74,222,128,.15); color: #4ade80; }
.urlexp-status--redirect { background: rgba(251,191,36,.15); color: #fbbf24; }
.urlexp-status--error    { background: rgba(239,68,68,.15); color: var(--danger); }
.urlexp-url { font-size: 13px; word-break: break-all; color: var(--accent); flex: 1; }