/* ============================================================
   Dilithion Block Explorer - Dark Theme
   Colors: #0a0e17 (bg), #111827 (secondary), #22c55e (accent)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --text-primary: #e5e7eb;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --accent-dim: rgba(34, 197, 94, 0.15);
    --border: #1f2937;
    --border-light: #374151;
    --danger: #ef4444;
    --warning: #eab308;
    --info: #3b82f6;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
    --transition: 150ms ease;
    --navbar-height: 64px;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    backdrop-filter: blur(8px);
}

.navbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 24px;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.navbar-logo {
    display: flex;
    align-items: center;
}

.navbar-logo img {
    border-radius: 4px;
}

.navbar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.navbar-title:hover {
    color: var(--accent);
    text-decoration: none;
}

.navbar-links {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    text-decoration: none;
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.navbar-right {
    flex: 1;
    max-width: 480px;
    min-width: 200px;
}

/* --- Search Bar --- */
.search-bar {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    height: 40px;
    padding: 0 16px 0 42px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: all var(--transition);
}

.search-bar input::placeholder {
    color: var(--text-dim);
    font-family: var(--font-body);
}

.search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* --- Main Content --- */
#app {
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--navbar-height) + 24px) 24px 80px;
    min-height: calc(100vh - 80px);
}

/* --- Stats Bar --- */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-value.mono {
    font-family: var(--font-mono);
    font-size: 16px;
}

/* --- Cards --- */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header .card-action {
    font-size: 13px;
    font-weight: 500;
}

.card-body {
    padding: 24px;
}

.card-body-flush {
    padding: 0;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-dim);
    text-align: left;
    padding: 12px 16px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--bg-tertiary);
}

.data-table th.right,
.data-table td.right {
    text-align: right;
}

.data-table th.center,
.data-table td.center {
    text-align: center;
}

/* --- Typography helpers --- */
.hash {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

a.hash {
    color: var(--accent);
}

a.hash:hover {
    color: var(--accent-hover);
}

.address {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
}

.address:hover {
    color: var(--accent-hover);
}

.amount {
    font-family: var(--font-mono);
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.amount-positive {
    color: var(--accent);
}

.amount-negative {
    color: var(--danger);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-warning {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.badge-muted {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.pagination a:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    text-decoration: none;
}

.pagination .active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 600;
}

.pagination .disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Detail Grid (block/tx detail pages) --- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    align-items: baseline;
}

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

.detail-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-dim);
    white-space: nowrap;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.5;
}

.detail-value.mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

/* --- Breadcrumb --- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-dim);
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb .separator {
    color: var(--text-dim);
    user-select: none;
}

.breadcrumb .current {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Loading --- */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
    gap: 16px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Copy Button --- */
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    vertical-align: middle;
    flex-shrink: 0;
}

.copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.copy-btn.copied {
    color: var(--accent);
    border-color: var(--accent);
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

/* --- Block Navigation --- */
.block-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.block-nav a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.block-nav a:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    text-decoration: none;
}

.block-nav .disabled {
    opacity: 0.3;
    pointer-events: none;
}

.block-nav .block-height {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Transaction I/O Visualization --- */
.tx-io {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: stretch;
}

.tx-io-inputs,
.tx-io-outputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
}

.tx-io-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--text-dim);
    font-size: 24px;
}

.tx-io-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tx-io-item .address {
    font-size: 12px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-io-item .amount {
    font-size: 13px;
    flex-shrink: 0;
}

.tx-io-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

/* --- Coinbase Label --- */
.coinbase-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
}

.coinbase-label svg {
    width: 14px;
    height: 14px;
}

/* --- Section Headings --- */
.section-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

/* --- Error State --- */
.error-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.error-message h2 {
    font-size: 20px;
    color: var(--danger);
    margin-bottom: 8px;
}

.error-message p {
    font-size: 14px;
    margin-bottom: 20px;
}

.error-message a {
    padding: 8px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 14px;
    display: inline-block;
}

.error-message a:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-dim);
    font-size: 14px;
}

/* --- Summary Row --- */
.summary-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    font-size: 13px;
}

.summary-bar .label {
    color: var(--text-dim);
    font-weight: 500;
}

.summary-bar .value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Inline value with copy --- */
.value-with-copy {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

/* --- Explanation/Info Text --- */
.info-text {
    padding: 16px 24px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.7;
    border-top: 1px solid var(--border);
}

.info-text strong {
    color: var(--text-primary);
}

/* --- Footer --- */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    padding: 24px;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-powered {
    color: var(--text-dim);
    font-size: 12px;
}

/* --- Page Header (used on blocks list, forks, etc.) --- */
.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .stats-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    .detail-row {
        grid-template-columns: 160px 1fr;
    }

    .tx-io {
        grid-template-columns: 1fr;
    }

    .tx-io-arrow {
        transform: rotate(90deg);
        padding: 8px 0;
    }
}

@media (max-width: 768px) {
    :root {
        --navbar-height: auto;
    }

    .navbar-inner {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 12px;
    }

    .navbar-left {
        width: 100%;
        justify-content: space-between;
    }

    .navbar-links {
        margin-left: 0;
    }

    .navbar-right {
        width: 100%;
        max-width: 100%;
    }

    #app {
        padding: 120px 16px 80px;
    }

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

    .stat-card {
        padding: 14px 16px;
    }

    .stat-value {
        font-size: 16px;
    }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 12px 16px;
    }

    .detail-label {
        font-size: 11px;
    }

    .card-header {
        padding: 14px 16px;
    }

    .card-body {
        padding: 16px;
    }

    .data-table td,
    .data-table th {
        padding: 10px 12px;
        font-size: 12px;
    }

    .hash {
        max-width: 120px;
        font-size: 12px;
    }

    .block-nav .block-height {
        font-size: 16px;
    }

    .footer-inner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .tx-io-item .address {
        max-width: 140px;
    }

    .pagination {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }

    .navbar-links {
        gap: 0;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* --- Utilities --- */
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
