/* Clark Moody Bitcoin Style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Kode Mono", monospace;
    background: #ffffff;
    color: #24292f;
    line-height: 1.6;
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode styles - optimized for OLED */
body.dark-mode {
    background: #000000;
    color: #c9d1d9;
}

body.dark-mode .stat-card,
body.dark-mode .battle-widget,
body.dark-mode .chart-section {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

body.dark-mode .battle-widget:hover,
body.dark-mode .chart-section:hover {
    border-color: #c9d1d9;
}

body.dark-mode header h1,
body.dark-mode .stat-number,
body.dark-mode .battle-widget h2,
body.dark-mode .chart-section h2,
body.dark-mode .implementation-name {
    color: #c9d1d9;
}

body.dark-mode .stat-card h3,
body.dark-mode .widget-subtitle,
body.dark-mode .battle-subtitle,
body.dark-mode .implementation-stats {
    color: #8b949e;
}

body.dark-mode .battle-bar,
body.dark-mode .progress-bar {
    background: #1a1a1a;
}


body.dark-mode .implementation-item {
    border-color: #2a2a2a;
}

body.dark-mode .battle-logo img {
    background: #ffffff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    padding: 25px 0;
    margin-bottom: 30px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 42px;
}

.logo-section {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

header h1 {
    font-optical-sizing: auto;
    font-size: 32px;
    font-weight: 500;
    font-style: normal;
    color: #24292f;
    margin: 0;
    line-height: 1;
}

.pulse-square {
    width: 12px;
    height: 12px;
    background: #dc3545; /* Red by default (disconnected) */
    border-radius: 0;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
    margin-top: -3px;
}

.pulse-square.connected {
    background: #28a745; /* Green when connected */
    animation: pulse 2s infinite;
}

.pulse-square.connecting {
    background: #ffc107; /* Yellow when connecting */
    animation: pulse 1s infinite;
}

header p {
    font-size: 16px;
    color: #57606a;
    font-weight: 400;
}

.header-buttons {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.donation-buttons-row {
    display: flex;
    flex-direction: row;
    gap: 5px;
    justify-content: center;
    margin-bottom: 12px;
}

.dark-mode-toggle {
    width: 60px;
    height: 36px;
    border: 1px solid #d1d5da;
    background: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 0;
    transition: border-color 0.2s ease, background-color 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.donate-btn {
    width: auto;
    padding: 0 16px;
    font-size: 12px;
}

.dark-mode-toggle:hover {
    border-color: #000000;
}

body.dark-mode .dark-mode-toggle {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

body.dark-mode .dark-mode-toggle:hover {
    border-color: #c9d1d9;
}

.mode-text {
    display: inline-block;
    line-height: 1;
    color: #24292f;
}

body.dark-mode .mode-text {
    color: #c9d1d9;
}


@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 0;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 120px;
    transition: border-color 0.2s ease;
}

.stat-card:hover {
    border-color: #000000;
}

body.dark-mode .stat-card:hover {
    border-color: #c9d1d9;
}

.stat-card h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #57606a;
    margin: 0;
    letter-spacing: 0.5px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-number {
    font-size: 32px;
    font-weight: 600;
    color: #24292f;
    font-feature-settings: 'tnum';
    margin-top: 12px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Default color for stat numbers */
.stat-card.race-leader .stat-number {
    font-weight: 600;
    transition: color 0.3s ease;
}

.stat-card.race-leader .leader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 12px;
}

/* Make race leader cards clickable */

.leader-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Two-column layout: battles left, charts right */
.widgets-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: flex-start;
}

.widgets-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widgets-col-left {
    flex: 1 1 55%;
}

.widgets-col-right {
    flex: 1 1 45%;
    position: sticky;
    top: 20px;
}

/* Battle Widget */
.battle-widget {
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 0;
    padding: 24px;
    transition: border-color 0.2s ease;
}

.battle-widget:hover {
    border-color: #000000;
}

.battle-widget h2 {
    font-size: 18px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 28px;
}

.widget-subtitle {
    font-size: 12px;
    color: #57606a;
    font-style: italic;
    margin-top: -18px;
    margin-bottom: 24px;
}

.battle-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.battle-participant {
    text-align: center;
    flex: 1;
}

/* Implementation-specific participant colors removed; fallback is inherited text color */

.battle-stats.three-way {
    justify-content: space-around;
}

.battle-vs {
    font-size: 14px;
    font-weight: 600;
    color: #57606a;
    margin: 0 20px;
}

.battle-logo {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 40px; /* Reserve space even when no logo */
}

.battle-logo img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 50%;
    padding: 1px;
}

.battle-logo img[src*="libre"] {
    outline: 1px solid #f7931a;
    outline-offset: 0;
    padding: 0;
}

body.dark-mode .battle-logo img[src*="libre"] {
    outline-color: #ffffff;
}

.logo-badge-wrap {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}

.logo-badge {
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 3px;
    background: #e91e8c;
    color: #ffffff;
    white-space: nowrap;
    pointer-events: none;
}

.battle-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
}

.battle-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: #666666;
    margin-top: -12px;
    margin-bottom: 16px;
    font-style: italic;
}

body.dark-mode .battle-subtitle {
    color: #8b949e;
}

.battle-count {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
    font-feature-settings: 'tnum';
}

.battle-percentage {
    font-size: 16px;
    font-weight: 500;
    color: #57606a;
    font-feature-settings: 'tnum';
}

body.dark-mode .battle-percentage {
    color: #8b949e;
}

.battle-bar {
    height: 10px;
    background: #f6f8fa;
    border-radius: 0;
    overflow: hidden;
    margin-bottom: 16px;
    display: flex;
}

.battle-progress {
    height: 100%;
    transition: width 0.3s ease;
    background: #d1d5da; /* Generic fallback until config-driven color arrives */
    position: relative;
}

.battle-history {
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
    margin-top: 4px;
}

body.dark-mode .battle-history {
    border-top-color: #1a1a1a;
}

.battle-history-label {
    font-size: 10px;
    color: #57606a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

body.dark-mode .battle-history-label {
    color: #8b949e;
}

.battle-history-canvas-wrap {
    width: 100%;
    height: 88px;
}

/* Hide mobile labels on desktop */
.mobile-bar-label {
    display: none;
}
/* Implementation-specific progress colors removed; JS sets backgroundColor per config */

.battle-total {
    text-align: center;
    font-size: 12px;
    color: #57606a;
    font-weight: 500;
}

/* Chart Widgets (donut, trend, list) */
.chart-widget {
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 0;
    padding: 24px;
    transition: border-color 0.2s ease;
}

.chart-widget:hover {
    border-color: #000000;
}

body.dark-mode .chart-widget {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

body.dark-mode .chart-widget:hover {
    border-color: #c9d1d9;
}

.chart-widget h2 {
    font-size: 18px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 28px;
}

body.dark-mode .chart-widget h2 {
    color: #c9d1d9;
}

/* Donut chart layout — stacked in sidebar */
.donut-canvas-wrap {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
}

.donut-legend {
    min-width: 0;
}

.trend-canvas-wrap {
    width: 100%;
    height: 280px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 12px;
}

.legend-row:last-child {
    border-bottom: none;
}

body.dark-mode .legend-row {
    border-bottom-color: #1a1a1a;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    font-weight: 500;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
    line-height: 1.3;
}

.legend-value {
    font-feature-settings: 'tnum';
    font-weight: 600;
    color: #24292f;
    flex-shrink: 0;
}

body.dark-mode .legend-value {
    color: #c9d1d9;
}

.legend-pct {
    font-feature-settings: 'tnum';
    color: #57606a;
    min-width: 55px;
    text-align: right;
    flex-shrink: 0;
}

body.dark-mode .legend-pct {
    color: #8b949e;
}

/* Legacy compat */
.charts-container {
    margin-bottom: 30px;
}

.chart-section {
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 0;
    padding: 24px;
    transition: border-color 0.2s ease;
}

.chart-section:hover {
    border-color: #000000;
}

.chart-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: #24292f;
    margin-bottom: 20px;
}

.implementation-list {
    /* No scroll - show all implementations */
}

.implementation-item {
    padding: 12px 0;
    border-bottom: 1px solid #d1d5da;
}

.implementation-item:last-child {
    border-bottom: none;
}

/* Collapsible UI removed */

.implementation-item.minor {
    padding: 8px 0;
    font-size: 12px;
}

.implementation-item.minor .implementation-name {
    font-size: 13px;
}

.implementation-item.minor .implementation-stats {
    font-size: 11px;
}

.implementation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.implementation-name {
    font-weight: 600;
    font-size: 14px;
    color: #24292f;
}

.implementation-stats {
    font-size: 12px;
    color: #57606a;
    font-feature-settings: 'tnum';
}

.progress-bar {
    height: 10px;
    background: #f6f8fa;
    border-radius: 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #d1d5da;
    transition: width 0.3s ease;
}

/* Recent Nodes */
.recent-nodes {
    background: #ffffff;
    border: 1px solid #d1d5da;
    border-radius: 0;
    margin-bottom: 30px;
}

.recent-nodes h2 {
    font-size: 18px;
    font-weight: 600;
    color: #24292f;
    padding: 20px 24px 0;
    margin-bottom: 16px;
}

.nodes-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead th {
    background: #f6f8fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #24292f;
    border-bottom: 1px solid #d1d5da;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #d1d5da;
    color: #24292f;
}

tbody tr:hover {
    background: #f6f8fa;
}

.node-address {
    font-size: 11px;
}

.user-agent {
    font-size: 11px;
    color: #0969da;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.active {
    background: #dafbe1;
    color: #1a7f37;
}

.status-badge.explored {
    background: #fff8c5;
    color: #9a6700;
}

.timestamp {
    color: #57606a;
    font-size: 11px;
}


/* Footer */
footer {
    text-align: center;
    padding: 20px 0 40px 0;
    margin-top: 20px;
}

footer p {
    font-size: 14px;
    color: #57606a;
}

.footer-content {
    text-align: center;
}

.footer-content p {
    margin: 0;
    font-size: 14px;
    color: #57606a;
}

.footer-content .last-updated {
    margin-top: 6px;
    font-size: 13px;
}

.footer-content a {
    color: inherit;
    text-decoration: none;
    font-weight: inherit;
    transition: opacity 0.2s ease;
}

.footer-content a:hover {
    opacity: 0.6;
    text-decoration: none;
}

body.dark-mode .footer-content p {
    color: #8b949e;
}

body.dark-mode .footer-content a {
    color: inherit;
}

body.dark-mode .footer-content a:hover {
    opacity: 0.6;
}

.bitcoin-address {
    font-size: 13px;
    color: #f7931e;
    text-decoration: none;
    padding: 4px 8px;
    background: #fff8e1;
    border-radius: 0;
    transition: all 0.2s ease;
}

.bitcoin-address:hover {
    background: #f7931e;
    color: #ffffff;
    text-decoration: none;
}


/* Responsive */
@media (max-width: 1024px) {
    .widgets-layout {
        flex-direction: column;
    }

    .widgets-col-left,
    .widgets-col-right {
        flex: 1 1 100%;
        width: 100%;
        position: static;
    }
}

@media (max-width: 899px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header {
        padding: 16px 0;
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    /* Keep battle stats horizontal on mobile */
    .battle-stats {
        flex-direction: row;
        gap: 10px;
        margin-bottom: 8px;
    }

    /* Make battle participants with bigger logos on mobile */
    .battle-participant {
        flex: 1;
    }

    .battle-logo {
        width: 40px;
        height: 40px;
        margin: 0 auto 8px;
    }

    .battle-logo img {
        width: 36px;
        height: 36px;
    }

    .battle-name {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .battle-subtitle {
        font-size: 10px;
        margin-bottom: 8px;
    }

    .battle-count {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .battle-percentage {
        font-size: 12px;
    }

    /* Keep original bar appearance on mobile */
    .battle-bar {
        height: 10px;
        margin-bottom: 16px;
    }

    .battle-widget {
        padding: 16px;
    }

    .battle-history-canvas-wrap {
        height: 74px;
    }

    /* Keep labels hidden on mobile */
    .mobile-bar-label {
        display: none;
    }

    .stat-number {
        font-size: 28px;
    }

    .chart-widget {
        padding: 16px;
    }

    .donut-canvas-wrap {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
        max-width: 300px;
        margin: 0 auto 16px;
    }

    .trend-canvas-wrap {
        height: 240px;
    }

    table {
        font-size: 11px;
    }
    
    thead th,
    tbody td {
        padding: 8px 12px;
    }
    
    .bitcoin-address {
        font-size: 11px;
        display: inline-block;
        word-break: break-all;
        max-width: 90%;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5da;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #586069;
}
/* BIP-110 Miner Signaling Widget */
.miner-signaling-content {
    padding: 10px 0 0;
}

.miner-block-mosaic {
    display: grid;
    grid-template-columns: repeat(56, minmax(0, 1fr));
    justify-content: center;
    align-items: center;
    gap: 2px;
    margin: 18px 0 0;
    line-height: 0;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.miner-sig-battle-bar {
    margin-bottom: 0;
}

.miner-block-link {
    display: block;
    min-width: 0;
    line-height: 0;
    text-decoration: none;
}

.miner-block-cell {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #d1d5da;
}

.miner-block-cell.signaling {
    background: #e91e8c;
    border-color: #e91e8c;
}

.miner-block-cell.not-signaling {
    background: #d0d7de;
    border-color: #d0d7de;
}

.miner-block-cell.missing {
    background: #ffc107;
    border-color: #ffc107;
}

.miner-block-cell.pending {
    background: #ffffff;
    border-color: #d1d5da;
    opacity: 0.45;
}

.miner-block-cell.next-block {
    animation: next-block-pulse 1.1s ease-in-out infinite;
    background: #8c959f;
    border-color: #8c959f;
    opacity: 1;
}

@keyframes next-block-pulse {
    0%, 100% {
        background: #8c959f;
        border-color: #8c959f;
    }
    50% {
        background: #d0d7de;
        border-color: #d0d7de;
    }
}

body.dark-mode .miner-block-cell {
    background: #161b22;
    border-color: #2a2a2a;
}

body.dark-mode .miner-block-cell.signaling {
    background: #e91e8c;
    border-color: #e91e8c;
}

body.dark-mode .miner-block-cell.not-signaling {
    background: #484f58;
    border-color: #6e7681;
}

body.dark-mode .miner-block-cell.missing {
    background: #ffc107;
    border-color: #ffc107;
}

body.dark-mode .miner-block-cell.pending {
    background: #30363d;
    border-color: #484f58;
}

@media (max-width: 768px) {
    .miner-block-mosaic {
        gap: 1px;
    }
}
