/* ================================================================
   Knexplorer v2.0 — Feature-Specific Styles
   Organized: Theme Transitions → Light Theme → Header Tools →
   View Tabs → Stats → Account Enrichment → Flow → DAG →
   Animations → Responsive
   ================================================================ */

/* ======= SMOOTH THEME TRANSITIONS ======= */
body, .header, .search-section, .content-panel, .footer,
.feed-item, .account-stat, .stat-pill, .view-tabs, .stat-card,
.flow-node, .dag-tooltip, .block-field {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ======= LIGHT THEME ======= */
[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f8f8f8;
    --text: #1a1a1a;
    --text-dim: #555;
    --text-muted: #888;
    --border: rgba(255,140,0,0.2);
    --border-strong: rgba(255,140,0,0.35);
    --glow-orange: 0 0 8px rgba(255,140,0,0.2);
    --glow-gold: 0 0 8px rgba(255,215,0,0.15);
}

[data-theme="light"] .logo-icon {
    box-shadow: 0 2px 8px rgba(255,140,0,0.3);
}

[data-theme="light"] .header {
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="light"] .search-box {
    background: #fff;
}

[data-theme="light"] .content-panel {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .feed-item:hover {
    background: #f8f3ee;
}

[data-theme="light"] .account-qr {
    background: #fff;
    border: 1px solid var(--border);
}

[data-theme="light"] #dagContainer {
    background: #fafafa;
}

[data-theme="light"] .dag-tooltip {
    background: rgba(255,255,255,0.95);
    border-color: var(--border-strong);
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

[data-theme="light"] .stat-card {
    background: #fff;
}

[data-theme="light"] .modal-card {
    background: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

[data-theme="light"] .error-banner {
    background: rgba(255,59,59,0.08);
}

[data-theme="light"] .toast {
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

[data-theme="light"] .search-suggestions {
    background: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

[data-theme="light"] .richlist-row:hover {
    background: #f8f8f8;
}

[data-theme="light"] .feed-type-badge.send { background: rgba(255,59,59,0.08); }
[data-theme="light"] .feed-type-badge.receive { background: rgba(0,230,118,0.08); }
[data-theme="light"] .feed-type-badge.change { background: rgba(187,134,252,0.08); }
[data-theme="light"] .feed-type-badge.open { background: rgba(68,138,255,0.08); }

[data-theme="light"] .filter-chip.active { background: rgba(255,140,0,0.08); }

/* ======= HEADER TOOL BUTTONS ======= */
.header-tool-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-tool-btn svg {
    width: 16px;
    height: 16px;
}

.header-tool-btn:hover {
    background: rgba(255,140,0,0.15);
    color: var(--orange);
    border-color: transparent;
}

/* ======= VIEW TABS ======= */
.view-tabs {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.view-tabs::-webkit-scrollbar {
    display: none;
}

.tabs-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    gap: 0;
    padding: 0 20px;
}

.view-tab {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.view-tab:hover {
    color: var(--orange);
}

.view-tab.active {
    color: var(--orange);
    border-bottom-color: var(--orange);
}

.view-tab svg {
    opacity: 0.6;
}

.view-tab.active svg {
    opacity: 1;
}

/* ======= STATS DASHBOARD ======= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
}

.stat-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.stat-card-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gold);
    margin: 8px 0 4px;
}

.stat-card-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* TPS Gauge */
.stats-tps-gauge {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.tps-gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), var(--gold));
    border-radius: 2px;
    width: 0;
    transition: width 0.5s ease;
}

/* Health Indicator */
.stats-health-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.health-dot.yellow { background: #ffc107; box-shadow: 0 0 8px #ffc107; }
.health-dot.red { background: var(--red); box-shadow: 0 0 8px var(--red); }

.health-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* Sparkline Canvas */
.stats-sparkline {
    width: 100%;
    height: 40px;
    margin-top: 8px;
    border-radius: var(--radius-sm);
}

/* ======= ACCOUNT ENRICHMENT ======= */
.account-enrichment {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 0 0;
    align-items: flex-start;
}

.account-enrichment:empty {
    display: none;
}

.account-qr {
    background: #fff;
    padding: 8px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.known-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    vertical-align: middle;
}

.account-lifetime-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    width: 100%;
}

.lifetime-stat {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.lifetime-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.lifetime-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.lifetime-value.positive { color: var(--green); }
.lifetime-value.negative { color: var(--red); }

.account-sparkline-wrapper {
    width: 100%;
}

.sparkline-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.account-sparkline {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-sm);
}

/* ======= TRANSACTION FLOW ======= */
#blockFlowContainer {
    padding: 0 20px;
}

.flow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
}

.flow-node {
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    min-width: 130px;
    background: rgba(255,255,255,0.02);
    transition: border-color 0.2s, transform 0.2s;
}

.flow-node:hover {
    border-color: var(--orange);
    transform: translateY(-2px);
}

.flow-node-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.flow-node-addr {
    font-size: 12px;
    color: var(--orange);
    margin-top: 6px;
    word-break: break-all;
}

.flow-sender .flow-node-addr { color: var(--red); }
.flow-receiver .flow-node-addr { color: var(--green); }
.flow-source .flow-node-addr { color: var(--text-dim); }

.flow-arrow {
    flex: 1;
    min-width: 80px;
    max-width: 200px;
    text-align: center;
    position: relative;
}

.flow-arrow-svg {
    width: 100%;
    height: 40px;
}

.flow-amount {
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
    margin-top: -2px;
}

.flow-line-anim {
    stroke-dasharray: 8 4;
    animation: flowDash 1s linear infinite;
}

@keyframes flowDash {
    to { stroke-dashoffset: -24; }
}

/* ======= DAG VISUALIZER ======= */
#dagContainer {
    width: 100%;
    height: 500px;
    background: var(--bg);
    position: relative;
    cursor: grab;
}

#dagContainer:active {
    cursor: grabbing;
}

.dag-legend {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-dim);
    flex-wrap: wrap;
}

.dag-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dag-node-count {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
}

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

.dag-tooltip {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    background: rgba(0,0,0,0.92);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 11px;
    color: var(--text);
    max-width: 300px;
    line-height: 1.6;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.dag-tooltip.hidden {
    display: none;
}

.dag-tooltip div {
    margin-bottom: 3px;
}

.dag-tooltip div:last-child {
    margin-bottom: 0;
}

.dag-tooltip strong {
    color: var(--orange);
}

/* ======= ANIMATIONS ======= */
.content-panel:not(.hidden) {
    animation: panelFadeIn 0.25s ease;
}

@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.04) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
    .tabs-inner {
        padding: 0 12px;
    }

    .view-tab {
        font-size: 11px;
        padding: 8px 12px;
        gap: 4px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        padding: 12px;
        gap: 10px;
    }

    #dagContainer {
        height: 350px;
    }

    .dag-legend {
        flex-wrap: wrap;
        gap: 10px;
    }

    .flow-diagram {
        padding: 16px 12px;
    }

    .flow-node {
        min-width: 100px;
        padding: 10px 12px;
    }

    .account-enrichment {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .view-tab svg {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    #dagContainer {
        height: 280px;
    }

    .flow-diagram {
        flex-direction: column;
        gap: 0;
    }

    .flow-arrow {
        transform: rotate(90deg);
        min-width: auto;
        width: 100px;
        margin: 4px 0;
    }

    .flow-node {
        min-width: 160px;
    }
}
