/* ============================================================
   TXID -> R,S,Z + Private Key Recovery — tool styles
   Fully theme-driven: the result table mirrors the site's
   .keys-table / .keys-header look (see /private-keys/bitcoin)
   so it is native in BOTH light and dark mode. All colours come
   from the --cgt-* variables; only the shared brand accents
   (Bitcoin orange #f7931a, alert pink #e0245e, tool teal #00b894)
   are hard-coded, exactly as elsewhere on CryptographyTube.
   ============================================================ */

/* Page intro paragraph under the H1 — match the Address Analysis intro size
   (.875rem / 14px) instead of the Bootstrap 1rem (16px) default. Line-height
   stays 1.5 (→ 21px), same as that page. Only this page loads tool.css, so
   the header selector cannot leak elsewhere. */
header.text-center p.text-muted { font-size: .875rem; }

.tool-section {
    background: var(--cgt-card-bg);
    border: 1px solid var(--cgt-border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px var(--cgt-shadow);
}
.tool-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 .85rem;
    color: var(--cgt-text);
}

/* Input + button row */
.tool-input-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .85rem;
}
.tool-input-row .form-control {
    flex: 1 1 260px;
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    font-size: .875rem;
}
.tool-input-row .btn { white-space: nowrap; }

/* ---- Chain selector + search bar — same look/behaviour as Address Analysis.
        The base .chain-tabs / .chain-tab / .search-bar styling lives in the
        global style.min.css; these rules add the selected-chain accent ring and
        center the search bar, mirroring address-analysis.css (own #txr- ids). ---- */
#txr-controls { max-width: 760px; margin-left: auto; margin-right: auto; }
#txr-chain-tabs { margin-bottom: 1rem; }
#txr-chain-tabs .chain-tab {
    cursor: pointer;
    opacity: .72;
    transition: opacity .15s ease, box-shadow .15s ease, border-color .15s ease;
}
#txr-chain-tabs .chain-tab:hover { opacity: 1; }
/* Selected chain: full opacity + an accent ring in the chain's own colour
   (each tab sets --chain-color inline; falls back to the tool teal). */
#txr-chain-tabs .chain-tab.active {
    opacity: 1;
    font-weight: 600;
    border-color: var(--chain-color, #00b894) !important;
    box-shadow: 0 0 0 2px var(--chain-color, #00b894) inset;
}

/* "Transactions to fetch" — free-entry number input (any count) */
#txr-txlimit-wrap { color: var(--cgt-text-muted); }
#txr-tx-limit {
    width: auto;
    min-width: 118px;
    max-width: 170px;
    font-family: 'SF Mono', Consolas, Monaco, monospace;
}

/* ---- Output panel — a themed card, like the site's .keys-table ---- */
.tool-output {
    background: var(--cgt-card-bg);
    color: var(--cgt-text);
    border: 1px solid var(--cgt-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--cgt-shadow);
    overflow: hidden;
    min-height: 120px;
    font-size: .8rem;
    line-height: 1.55;
}
.tool-output pre {
    margin: 0;
    padding: .9rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    color: var(--cgt-text-muted);
    background: transparent;
}

/* Brand strip emitted by the engine */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .7rem 1rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--cgt-text);
    background: linear-gradient(135deg, var(--cgt-bg-tertiary) 0, var(--cgt-card-bg) 100%);
    border-bottom: 1px solid var(--cgt-border);
    box-shadow: inset 3px 0 0 #f7931a;
}
.result-header .tool-tag {
    font-weight: 500;
    font-size: .72rem;
    letter-spacing: .02em;
    color: var(--cgt-text-muted);
    text-transform: uppercase;
}
.download-tools { display: flex; gap: .5rem; padding: .7rem 1rem 0; }
.btn-small {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: transparent;
    border: 1px solid var(--cgt-border);
    color: var(--cgt-text);
    border-radius: 6px;
    padding: .3rem .6rem;
    font-size: .72rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-small:hover {
    border-color: var(--cgt-primary);
    color: var(--cgt-primary);
    background: rgba(var(--cgt-primary-rgb), .08);
}
.btn-small img { filter: none; }
[data-bs-theme="dark"] .btn-small img { filter: invert(1); }

/* ---- Status / empty / error ---- */
.rsz-status { padding: .9rem 1rem; color: var(--cgt-text-muted); font-size: .85rem; }
.rsz-error {
    display: flex; align-items: center; gap: .4rem;
    margin: .75rem 1rem; padding: .6rem .8rem;
    border: 1px solid rgba(224, 36, 94, .4);
    border-radius: 6px;
    background: rgba(224, 36, 94, .08);
    color: #e0245e;
    font-size: .8rem;
    word-break: break-word;
}
[data-bs-theme="dark"] .rsz-error img { filter: invert(1); }

/* ---- Summary chips ---- */
.rsz-summary { display: flex; flex-wrap: wrap; gap: .5rem; padding: .8rem 1rem .25rem; }
.rsz-chip {
    font-size: .68rem; font-weight: 600;
    padding: .22rem .6rem; border-radius: 999px;
    background: var(--cgt-bg-tertiary); color: var(--cgt-text-muted);
    border: 1px solid var(--cgt-border);
    text-transform: uppercase; letter-spacing: .03em;
}
.rsz-chip-ok { color: #00b894; border-color: rgba(0, 184, 148, .45); }
.rsz-chip-danger { color: #e0245e; border-color: rgba(224, 36, 94, .45); }

/* ---- Recovered private key box ---- */
.rsz-vuln-box {
    margin: .75rem 1rem;
    padding: .7rem .85rem;
    border: 1px solid rgba(224, 36, 94, .45);
    border-left: 3px solid #e0245e;
    border-radius: 8px;
    background: rgba(224, 36, 94, .06);
}
.rsz-vuln-title {
    display: flex; align-items: center; gap: .4rem;
    font-weight: 700; font-size: .8rem; color: #e0245e; margin-bottom: .45rem;
}
[data-bs-theme="dark"] .rsz-vuln-title img { filter: invert(38%) sepia(64%) saturate(3200%) hue-rotate(320deg); }
.rsz-vuln-key { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Recovered key highlight (only the recovered key uses .private-key here) */
.private-key {
    color: #f7931a;
    font-weight: 700;
    word-break: break-all;
    background: rgba(247, 147, 26, .12);
    border-radius: 4px;
    padding: 0 .3rem;
}

/* ---- Results table (same grid model as .keys-table, own classes to
        avoid the global !important grid on .key-row) ---- */
.rsz-thead, .rsz-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(230px, 1.7fr) minmax(200px, 1.4fr);
    gap: 1rem;
    align-items: start;
}
.rsz-thead {
    padding: .7rem 1rem;
    margin-top: .75rem;
    background: linear-gradient(135deg, var(--cgt-bg-tertiary) 0, var(--cgt-card-bg) 100%);
    border-top: 1px solid var(--cgt-border);
    border-bottom: 2px solid var(--cgt-border);
    font-size: .7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .03em;
    color: var(--cgt-text-muted);
}
.rsz-thead img { vertical-align: -2px; opacity: .75; }
[data-bs-theme="dark"] .rsz-thead img { filter: invert(1); }

.rsz-row {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--cgt-border);
    font-size: .78rem;
}
.rsz-row:last-child { border-bottom: 0; }
.rsz-row:hover { background: rgba(var(--cgt-primary-rgb), .04); }
.rsz-row-vuln { background: rgba(224, 36, 94, .06); }
.rsz-row-vuln:hover { background: rgba(224, 36, 94, .1); }

/* ---- Public Key Toolkit: coordinates / HASH160 / address results are
        label -> value pairs, not the 3-column R·S·Z table. Let the row span
        the full card width and give the label a real column (the labels here
        are long — "Native SegWit (bc1…)" — unlike R/S/Z). ---- */
.rsz-thead.rsz-full,
.rsz-row.rsz-full { grid-template-columns: 1fr; }
.rsz-line .pkt-tag {
    width: 168px;
    white-space: normal;
    line-height: 1.25;
    letter-spacing: .02em;
}
/* Live per-address balance shown under each derived address. Aligns under the
   value column (past the label); turns green when the address has received coins. */
.pkt-addr-stats {
    margin: -.15rem 0 .65rem;
    padding-left: calc(168px + .4rem);
    font-size: .72rem;
    color: var(--cgt-text-muted);
}
.pkt-addr-stats b { color: var(--cgt-text); font-weight: 600; }
.pkt-addr-stats.pkt-has-funds b { color: #22c55e; }
.pkt-addr-stats.pkt-bal-na { font-style: italic; opacity: .85; }

/* Balance-check spinner — the rotating wheel shown while an explorer request is in
   flight (same idea as the private-keys balance column). Self-contained: own
   keyframes + explicit tint so the global .fa-icon filters never recolour it. */
.pkt-spin {
    display: inline-block;
    vertical-align: -2px;
    animation: pkt-spin .8s linear infinite;
    filter: invert(48%);                 /* black source SVG -> muted grey */
}
[data-bs-theme="dark"] .pkt-spin { filter: invert(78%); }
@keyframes pkt-spin { to { transform: rotate(360deg); } }

/* Funded top-summary amounts use the private-keys balance green (#22c55e). */
.stat-value.has-balance { color: #22c55e !important; font-weight: 700; }
@media (max-width: 768px) {
    /* Stack label over value: on a narrow flex row a 100%-wide label collapses
       the mono value column to ~0px, so break-all puts one character per line.
       Wrapping lets the value keep the full row width. Keep section titles too. */
    .rsz-line { flex-wrap: wrap; }
    .rsz-line .pkt-tag { width: 100%; margin-bottom: .15rem; }
    .rsz-line .rsz-val { flex: 1 1 0; }
    .rsz-thead.rsz-full { display: block; }
    .pkt-addr-stats { padding-left: 0; margin-top: .1rem; }
}

.rsz-col { min-width: 0; }
.rsz-line { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .3rem; }
.rsz-line:last-child { margin-bottom: 0; }
.rsz-tag {
    flex: 0 0 auto; width: 2.4em;
    font-size: .6rem; font-weight: 700;
    color: var(--cgt-text-muted); text-transform: uppercase;
}
.key-label {
    display: block;
    color: var(--cgt-text-muted);
    font-size: .6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em;
    margin-bottom: .2rem;
}
.rsz-val {
    font-family: 'SF Mono', Consolas, Monaco, monospace;
    word-break: break-all;
    color: var(--cgt-text);
    min-width: 0;
}
.rsz-txid { color: var(--cgt-primary); }
.rsz-addr-val { color: var(--cgt-key-address); }

/* Copy button (visual clone of the site's .copy-btn, own class so it
   doesn't hook the global copy handler) */
.rsz-copy {
    flex: 0 0 auto;
    padding: .1rem .3rem;
    background: 0 0; border: none; border-radius: 4px;
    color: var(--cgt-text-muted); cursor: pointer;
    opacity: .45; transition: opacity .15s, color .15s;
}
.rsz-row:hover .rsz-copy, .rsz-vuln-key .rsz-copy, .rsz-copy:hover { opacity: 1; }
.rsz-copy:hover { color: var(--cgt-primary); }
.rsz-copy.copied { color: #00b894; opacity: 1; }
[data-bs-theme="dark"] .rsz-copy img { filter: invert(1); }

/* ---- Mobile: stack the three columns ---- */
@media (max-width: 768px) {
    .rsz-thead { display: none; }
    .rsz-row { grid-template-columns: 1fr; gap: .7rem; }
    .rsz-col-rsz, .rsz-col-addr { padding-top: .1rem; }
}
