/*
 * devtoken.tools — shared design system
 * All tool pages link to this stylesheet.
 * ─────────────────────────────────────────────────────────────────────────────
 * Colour coding convention:
 *   Purple  (#7c3aed) — structural / headers
 *   Cyan    (#0ea5e9) — data / payload
 *   Orange  (#f97316) — signatures / warnings (high)
 *   Green   (#22c55e) — success / safe
 *   Amber   (#f59e0b) — caution / warnings (medium)
 *   Red     (#ef4444) — danger / critical
 * ─────────────────────────────────────────────────────────────────────────────
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Backgrounds */
  --bg:         #0a0c10;
  --bg2:        #111318;
  --bg3:        #181b22;

  /* Borders */
  --border:     #252830;
  --border2:    #2e333d;

  /* Text */
  --text:       #e2e4ea;
  --muted:      #6b7280;

  /* Semantic colours */
  --ok:         #22c55e;
  --warn:       #f59e0b;
  --danger:     #ef4444;
  --info:       #0ea5e9;

  /* Brand / role colours */
  --accent:     #4ade80;
  --accent-dim: #166534;
  --header-col: #7c3aed;
  --payload:    #0ea5e9;
  --sig:        #f97316;

  /* Typography */
  --mono:   'IBM Plex Mono', monospace;
  --sans:   'IBM Plex Sans', sans-serif;

  /* Layout */
  --radius: 6px;
  --wrap:   860px;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── CSS grid background overlay ─────────────────────────────────────────── */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

/* ── Layout wrapper ───────────────────────────────────────────────────────── */

.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ── Site header / nav ────────────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  display: block;
}

.logo-wordmark {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-wordmark span {
  color: var(--accent);
}

.nav-tools-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px 12px;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.nav-tools-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Tool page header (h1 + tagline) ─────────────────────────────────────── */

.tool-header {
  margin-bottom: 28px;
}

h1 {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.tagline {
  font-size: 14px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ── Privacy notice ───────────────────────────────────────────────────────── */

.privacy-note {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 8px 12px;
  background: var(--bg3);
  border-radius: 4px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy-note::before {
  content: '🔒';
  font-size: 12px;
  flex-shrink: 0;
}

/* ── Form elements ────────────────────────────────────────────────────────── */

label.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
}

textarea::placeholder,
input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

button {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  transition: opacity 0.15s, background 0.15s;
}

button:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: #0a1a0f;
}

.btn-ghost {
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border2);
}

.btn-sample {
  background: transparent;
  color: var(--payload);
  border: 1px solid #0369a1;
  font-size: 12px;
  padding: 6px 14px;
}

.btn-copy {
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--border2);
  font-size: 12px;
  padding: 5px 12px;
}

.btn-copy.copied {
  color: var(--ok);
  border-color: var(--accent-dim);
}

.input-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.input-section {
  margin-bottom: 28px;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */

.panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 16px;
}

/* ── Dot indicators ───────────────────────────────────────────────────────── */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-purple  { background: var(--header-col); box-shadow: 0 0 6px var(--header-col); }
.dot-cyan    { background: var(--payload);    box-shadow: 0 0 6px var(--payload); }
.dot-orange  { background: var(--sig);        box-shadow: 0 0 6px var(--sig); }
.dot-amber   { background: var(--warn);       box-shadow: 0 0 6px var(--warn); }
.dot-green   { background: var(--ok);         box-shadow: 0 0 6px var(--ok); }

/* Legacy aliases used by jwt-decoder.html */
.dot-header  { background: var(--header-col); box-shadow: 0 0 6px var(--header-col); }
.dot-payload { background: var(--payload);    box-shadow: 0 0 6px var(--payload); }
.dot-sig     { background: var(--sig);        box-shadow: 0 0 6px var(--sig); }
.dot-audit   { background: var(--warn);       box-shadow: 0 0 6px var(--warn); }

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 6px;
}

.badge-ok     { background: #14532d; color: #86efac; }
.badge-warn   { background: #451a03; color: #fcd34d; }
.badge-danger { background: #450a0a; color: #fca5a5; }
.badge-info   { background: #0c1a2e; color: #7dd3fc; }
.badge-purple { background: #2e1065; color: #c4b5fd; }

/* ── Audit / finding items (coloured left-border strips) ─────────────────── */

.audit-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.audit-item.ok     { background: #0d2018; border-color: var(--ok); }
.audit-item.warn   { background: #1c1200; border-color: var(--warn); }
.audit-item.danger { background: #1a0505; border-color: var(--danger); }
.audit-item.info   { background: #050e1a; border-color: var(--payload); }

.audit-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  font-family: var(--mono);
}

.audit-text {
  font-size: 13px;
}

.audit-text strong {
  display: block;
  font-weight: 600;
  margin-bottom: 2px;
}

.audit-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  display: block;
}

/* ── JSON table ───────────────────────────────────────────────────────────── */

.json-table {
  width: 100%;
  border-collapse: collapse;
}

.json-table tr + tr td {
  border-top: 1px solid var(--border);
}

.json-table td {
  padding: 8px 0;
  vertical-align: top;
}

.json-key {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  width: 120px;
  padding-right: 16px;
  white-space: nowrap;
}

.json-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.json-val .string { color: #86efac; }
.json-val .number { color: #93c5fd; }
.json-val .bool   { color: #f9a8d4; }

.claim-note {
  font-family: var(--sans);
  font-size: 11px;
  margin-top: 3px;
  color: var(--muted);
}

/* ── Output / code display areas ──────────────────────────────────────────── */

.output-block {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  line-height: 1.7;
  white-space: pre-wrap;
}

.output-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.output-row:last-child {
  margin-bottom: 0;
}

.output-row .output-block {
  flex: 1;
  margin-bottom: 0;
}

/* ── Error state ──────────────────────────────────────────────────────────── */

.error-msg {
  display: none;
  background: #1a0505;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: #fca5a5;
  margin-bottom: 20px;
}

.error-msg.visible {
  display: block;
}

/* ── Results container (hidden until populated) ───────────────────────────── */

.results {
  display: none;
  gap: 20px;
  flex-direction: column;
}

.results.visible {
  display: flex;
}

/* ── Strength / progress meters ───────────────────────────────────────────── */

.meter-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease, background 0.3s ease;
}

/* ── Toggle / option rows ─────────────────────────────────────────────────── */

.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.option-row label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.option-row input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.option-row select {
  width: auto;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Stats / summary row ──────────────────────────────────────────────────── */

.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 100px;
}

.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.footer-text a {
  color: var(--accent);
  text-decoration: none;
}

.footer-text a:hover {
  text-decoration: underline;
}

.kofi-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.kofi-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  h1 { font-size: 18px; }
  .json-key { width: 90px; }
  .input-actions { flex-direction: column; }
  button { width: 100%; }
  .stat-row { flex-direction: column; }
  .output-row { flex-direction: column; }
  .site-header { flex-direction: column; align-items: flex-start; }
}
