/* ── Ethereum Wallet Visualizer ───────────────────────────────────────────── */

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

html, body {
    height: 100%;
    background: #0d1117;
    color: #e6edf3;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ── Page wrapper ─────────────────────────────────────────────────────────── */

.page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px 14px 0;
}

.app-layout {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
    padding-bottom: 10px;
}

/* ── Left panel ───────────────────────────────────────────────────────────── */

.left-panel {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */

.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    flex-shrink: 0;
}

.back-to-projects {
    display: inline-block;
    padding: 6px 12px;
    color: #627eea;
    text-decoration: none;
    font-size: 12px;
    border: 1px solid rgba(98,126,234,0.35);
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.back-to-projects:hover { background: rgba(98,126,234,0.12); border-color: #627eea; }

/* ── Help button & dropdown ───────────────────────────────────────────────── */

.help-wrapper {
    position: relative;
}

.btn-help {
    padding: 6px 12px;
    background: rgba(13,17,23,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(230,237,243,0.7);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.btn-help:hover,
.btn-help.active { background: rgba(98,126,234,0.18); color: #627eea; border-color: rgba(98,126,234,0.5); }

.help-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 270px;
    background: #161b22;
    border: 1px solid rgba(98,126,234,0.4);
    border-radius: 8px;
    padding: 14px 16px;
    z-index: 200;
    box-shadow: 0 8px 28px rgba(0,0,0,0.55);
}
.help-dropdown.help-open { display: block; }

.help-about {
    font-size: 12px;
    color: rgba(230,237,243,0.6);
    line-height: 1.6;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.help-dropdown h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 10px;
}

.help-dropdown ul {
    padding-left: 16px;
    font-size: 12px;
    color: rgba(230,237,243,0.65);
    line-height: 1.9;
}

.help-dropdown ul strong { color: #e6edf3; }

/* ── Header ───────────────────────────────────────────────────────────────── */

.project-header h1 {
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, #627eea, #a78bfa, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.project-header .subtitle {
    margin-top: 5px;
    color: rgba(230,237,243,0.5);
    font-size: 0.78rem;
    line-height: 1.45;
}

/* ── Search section ───────────────────────────────────────────────────────── */

.search-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-row input {
    width: 100%;
    padding: 10px 13px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #e6edf3;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    outline: none;
    transition: border-color 0.2s;
}
.input-row input:focus { border-color: #627eea; }
.input-row input::placeholder { color: rgba(230,237,243,0.3); }

.btn-visualize {
    width: 100%;
    padding: 10px;
    background: #627eea;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-visualize:hover    { background: #4c6bd6; }
.btn-visualize:active   { transform: scale(0.98); }
.btn-visualize:disabled { background: #333; color: #666; cursor: not-allowed; }

/* Status */

.status-msg {
    display: none;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
}
.status-loading { color: #fbbf24; background: rgba(251,191,36,0.1);  border: 1px solid rgba(251,191,36,0.3); }
.status-error   { color: #f87171; background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); }
.status-success { color: #4ade80; background: rgba(74,222,128,0.1);  border: 1px solid rgba(74,222,128,0.3); }
.status-info    { color: #38bdf8; background: rgba(56,189,248,0.1);  border: 1px solid rgba(56,189,248,0.3); }

/* ── Filter ───────────────────────────────────────────────────────────────── */

.filters-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    transition: color 0.2s;
}
.filters-toggle:hover { color: rgba(230,237,243,0.65); }

.filters-chevron {
    font-size: 10px;
    transition: transform 0.2s;
    margin-left: 6px;
}
.filters-toggle.open .filters-chevron { transform: rotate(90deg); }

.filters-body { margin-top: 10px; display: flex; flex-direction: column; gap: 16px; }

.filter-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}

#ethSlider,
#walletSlider {
    width: 100%;
    accent-color: #627eea;
    cursor: pointer;
    height: 4px;
    margin-bottom: 8px;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-row input[type="number"] {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #e6edf3;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    outline: none;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
}
.filter-row input[type="number"]::-webkit-outer-spin-button,
.filter-row input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.filter-row input[type="number"]:focus { border-color: #627eea; }
.filter-row input[type="number"]::placeholder { color: rgba(230,237,243,0.3); }

.filter-sep {
    color: rgba(230,237,243,0.4);
    font-size: 14px;
    flex-shrink: 0;
}

.filter-hint {
    font-size: 11px;
    color: rgba(230,237,243,0.35);
    margin-top: 4px;
}

/* ── Examples ─────────────────────────────────────────────────────────────── */

.examples-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}

.examples-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    transition: color 0.2s;
}
.examples-toggle:hover { color: rgba(230,237,243,0.65); }

.examples-chevron {
    font-size: 10px;
    transition: transform 0.2s;
    margin-left: 6px;
}
.examples-toggle.open .examples-chevron { transform: rotate(90deg); }

.examples-body { margin-top: 10px; }

.examples-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(230,237,243,0.3);
    margin: 10px 0 5px;
}
.examples-group-label:first-of-type { margin-top: 2px; }

.example-chips {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.example-chip {
    padding: 8px 12px;
    background: rgba(98,126,234,0.08);
    border: 1px solid rgba(98,126,234,0.25);
    border-radius: 8px;
    color: #627eea;
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, border-color 0.2s;
}
.example-chip:hover { background: rgba(98,126,234,0.18); border-color: #627eea; }
.example-chip--flagged { color: #e06c75; border-color: rgba(224,108,117,0.35); background: rgba(224,108,117,0.08); }
.example-chip--flagged:hover { background: rgba(224,108,117,0.18); border-color: #e06c75; }

/* ── Node info panel ──────────────────────────────────────────────────────── */

.node-info-panel {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 12px;
    background: #161b22;
}
.node-info-panel h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}
.node-info-addr {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: #e6edf3;
    word-break: break-all;
    margin-bottom: 6px;
}
.node-info-row {
    font-size: 12px;
    color: rgba(230,237,243,0.6);
    margin-bottom: 3px;
}
.node-info-row span { color: #e6edf3; }

/* ── Right panel ──────────────────────────────────────────────────────────── */

.right-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 300px;
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 12px;
    gap: 10px;
    color: rgba(230,237,243,0.35);
}
.empty-icon  { font-size: 3rem; opacity: 0.5; }
.empty-state p { font-size: 14px; }
.empty-hint  { font-size: 12px !important; }

.graph-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 400px;
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    overflow: hidden;
}

#graphCanvas {
    width: 100%;
    height: 100%;
}

/* ── Graph overlays ───────────────────────────────────────────────────────── */

.wallet-display {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(13,17,23,0.82);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-family: monospace;
    color: rgba(230,237,243,0.7);
    pointer-events: none;
    display: none;
}
.wallet-display.visible { display: block; }

.graph-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(13,17,23,0.82);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 8px 10px;
    pointer-events: none;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: rgba(230,237,243,0.6);
}
.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-wallet { background: #38bdf8; }
.legend-edge {
    width: 22px;
    height: 2px;
    background: rgba(98,126,234,0.7);
    flex-shrink: 0;
    border-radius: 1px;
}
.legend-arrow { font-size: 14px; color: rgba(230,237,243,0.5); }

.graph-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
}

.btn-tool {
    padding: 6px 12px;
    background: rgba(13,17,23,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(230,237,243,0.7);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-tool:hover { background: rgba(98,126,234,0.18); color: #627eea; border-color: rgba(98,126,234,0.5); }

.graph-stats {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: rgba(230,237,243,0.4);
    background: rgba(13,17,23,0.7);
    padding: 4px 10px;
    border-radius: 6px;
}
.stat-item span { color: rgba(230,237,243,0.8); font-weight: 600; }

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

@media (max-width: 768px) {
    .page-wrapper { height: auto; }
    .app-layout   { flex-direction: column; height: auto; }
    .left-panel   { width: 100%; overflow-y: visible; }
    .canvas-wrapper { min-height: 60vh; }
}

@media (max-width: 480px) {
    .canvas-wrapper { min-height: 55vh; }
    .graph-stats    { display: none; }
}

/* ── Balance chart ────────────────────────────────────────────────────────── */

/* ── Top transactions ─────────────────────────────────────────────────────── */

.top-txs-container {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.top-txs-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}

.top-tx-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 11px;
}
.top-tx-row:last-child { border-bottom: none; }

.top-tx-amount {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    white-space: nowrap;
}
.top-tx-amount.in  { color: #4ade80; }
.top-tx-amount.out { color: #f87171; }

.top-tx-date {
    color: rgba(230,237,243,0.4);
    font-size: 11px;
    text-align: right;
}

.top-tx-hash {
    color: rgba(98,126,234,0.7);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    text-decoration: none;
    white-space: nowrap;
}
.top-tx-hash:hover { color: #627eea; text-decoration: underline; }

/* ── Balance chart ────────────────────────────────────────────────────────── */

.balance-chart-container {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.balance-chart-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}

.balance-chart-status {
    font-size: 12px;
    color: #8b949e;
    padding: 6px 0;
}

#balanceChart {
    width: 100% !important;
    height: 180px !important;
    display: block;
}

.balance-chart-note {
    font-size: 11px;
    color: #f59e0b;
    margin-top: 6px;
    line-height: 1.4;
}

.balance-scrollbar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin-top: 6px;
    display: block;
}
.balance-scrollbar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 6px;
    background: #627eea;
    border-radius: 3px;
    cursor: grab;
}
.balance-scrollbar::-webkit-slider-thumb:active { cursor: grabbing; }
.balance-scrollbar::-moz-range-thumb {
    width: 28px;
    height: 6px;
    background: #627eea;
    border-radius: 3px;
    border: none;
    cursor: grab;
}

/* ── Edge info panel ──────────────────────────────────────────────────────── */

.node-addr-link {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    color: #627eea;
    word-break: break-all;
    text-decoration: none;
}
.node-addr-link:hover { text-decoration: underline; }

.edge-tx-list {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.edge-tx-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.4);
    margin-bottom: 8px;
}

.edge-tx-loading {
    font-size: 12px;
    color: rgba(230,237,243,0.4);
}

.edge-tx-row {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 11px;
}
.edge-tx-row:last-child { border-bottom: none; }

.edge-tx-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.edge-tx-dir {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
}
.edge-tx-dir.in  { background: rgba(52,211,153,0.15); color: #34d399; }
.edge-tx-dir.out { background: rgba(251,191,36,0.15);  color: #fbbf24; }

.edge-tx-amount {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-weight: 600;
    color: #e6edf3;
    flex: 1;
}

.edge-tx-date {
    color: rgba(230,237,243,0.4);
    white-space: nowrap;
}

.edge-tx-hash {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 10px;
    color: #627eea;
    text-decoration: none;
}
.edge-tx-hash:hover { text-decoration: underline; }
