/* Minimal custom styling on top of Pico.css */

/* ====================== Global overflow safety ====================== */
/*
 * Long unbreakable content (64-char hex hashes, Bech32 addresses,
 * JSON-serialized pubkey arrays) is pervasive in this UI.  Without
 * explicit wrap rules, these push the page wider than the viewport
 * on narrow screens.  Rules below make wrap-or-scroll local to the
 * offending element rather than dragging the whole page horizontally.
 */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  max-width: 100%;
  overflow-x: auto;
}
pre code {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* Tables that would otherwise exceed viewport get local horizontal
 * scroll rather than pushing the page wide.  Pico wraps tables in a
 * scroll container already, but be explicit for safety. */
table {
  font-size: 0.9rem;
  width: 100%;
}

/* ====================== Chrome ====================== */

.chain-label {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  margin-left: 0.4rem;
  font-size: 0.8rem;
  font-weight: normal;
  background: var(--pico-secondary-background);
  color: var(--pico-secondary-inverse);
  border-radius: 0.3rem;
  vertical-align: middle;
}

.muted  { color: var(--pico-muted-color); }
.ok     { color: #22c55e; }
.err    { color: #ef4444; }
.right  { text-align: right; }

.hash {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.85em;
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* ====================== Key-value dl ====================== */

dl.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.4rem 1rem;
  margin: 0.5rem 0;
}
dl.kv dt {
  font-weight: 600;
  color: var(--pico-muted-color);
}
dl.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ====================== Dashboard per-node cards ====================== */

.node-card {
  padding: 1rem;
  border-left: 4px solid var(--pico-muted-border-color);
  margin: 0;
  min-width: 0;
  overflow: hidden;
}
.node-card.node-leader { border-left-color: #22c55e; }
.node-card.node-error  { border-left-color: #ef4444; opacity: 0.7; }

/* Use flex instead of float:right so the role badge doesn't escape
 * the card and the URL wraps properly on narrow viewports. */
.node-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.node-card header strong {
  overflow-wrap: anywhere;
  word-break: break-all;
  min-width: 0;
  flex: 1 1 auto;
}

.role {
  padding: 0.1rem 0.5rem;
  border-radius: 0.3rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.role-leader    { background: #22c55e22; color: #22c55e; }
.role-follower  { background: #3b82f622; color: #3b82f6; }
.role-candidate { background: #eab30822; color: #eab308; }
.role-error     { background: #ef444422; color: #ef4444; }

/* ====================== Alerts ====================== */

.alert {
  border-left: 4px solid #eab308;
  padding: 0.75rem 1rem;
}
.alert-critical {
  border-left-color: #ef4444;
  background: #ef444411;
}

/* ====================== Pagination ====================== */

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pagination a {
  display: inline-block;
  padding: 0.5rem 1rem;
}

/* ====================== Wallet page ====================== */

.hidden { display: none !important; }

.button-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
}
.button-row button {
  width: auto;
}

.ok-alert {
  border-left-color: #22c55e;
  background: #22c55e11;
}

/* Tighter form sections inside <details> */
details > form {
  margin-top: 0.75rem;
}
details {
  margin-bottom: 0.5rem;
}

/* Test parity page — green/red row backgrounds */
tr.pass > td:first-child { color: #22c55e; font-weight: bold; }
tr.fail > td:first-child { color: #ef4444; font-weight: bold; }
tr.fail { background: #ef444411; }
