/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables */
:root {
    /* Colors */
    --color-bg: #111111;
    --color-bg-light: rgba(26, 26, 26, 0.9);
    --color-text: #e0e0e0;
    --color-text-muted: #999999;
    --color-border: #2a2a2a;
    --color-accent: #3b82f6;
    --color-accent-hover: #2563eb;
    --color-success: #10b981;
    --color-error: #ef4444;
    
    /* Alpha/Overlay Colors */
    --color-overlay: rgba(26, 26, 26, 0.8);
    --color-overlay-accent: rgba(59, 130, 246, 0.1);
    --color-overlay-success: rgba(16, 185, 129, 0.1);
    --color-overlay-error: rgba(239, 68, 68, 0.1);
    --color-shadow: rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Borders */
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    
    /* Typography */
    --font-size-sm: 0.8rem;
    --font-size-base: 0.875rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.125rem;
    --font-size-2xl: 1.25rem;
    --font-size-3xl: 1.5rem;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: var(--font-size-base);
}

/* App Layout */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg) 100%);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xl);
    overflow: auto;
}

.logo {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    white-space: nowrap;
}

.logo a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.search-bar {
    flex: 1;
    max-width: 520px;
    display: flex;
    gap: var(--space-sm);
}

.search-input {
    flex: 1;
    padding: 0.75rem var(--space-md);
    background: var(--color-bg-light);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text);
    font-size: var(--font-size-base);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-light);
    box-shadow: 0 0 0 3px var(--color-overlay-accent);
}

.search-input::placeholder {
    color: var(--color-text-muted);
}

.search-button {
    padding: 0.75rem var(--space-md);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.search-button:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
}

.search-button:active {
    transform: translateY(0);
}

/* Main Content */
.main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    width: 100%;
}

.page {
    display: none;
}

.page:first-child {
    display: block;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: var(--space-md);
}

/* Cards */
.card {
    background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px var(--color-shadow);
}

.card-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-overlay);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text);
}

.card-content {
    padding: var(--space-lg);
}

/* Network Grid */
.network-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 1rem;
}

.network-item.offline {
    opacity: 0.6;
    border: 1px solid var(--color-error);
    padding: 0 .5rem;
}

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

.status-dot.online {
    background: var(--color-success);
}

.status-dot.offline {
    background: var(--color-error);
}

.network-stats {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.network-stats div {
    margin-bottom: 0.25rem;
}

/* Lists */
.list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.list-item {
    padding: 1rem;
    background: var(--color-overlay);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.list-item:hover {
    background: var(--color-overlay-accent);
    border-color: var(--color-accent);
    transform: translateX(4px);
}

.list-item.loading {
    cursor: default;
    color: var(--color-text-muted);
    font-style: italic;
}

.list-item.loading:hover {
    background: var(--color-overlay);
    border-color: var(--color-border);
    transform: none;
}

/* Block Item */
.block-item .block-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.block-time {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.block-hash {
    font-family: monospace;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Transaction Item */
.transaction-item .tx-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.tx-network {
    font-weight: 600;
    color: var(--color-text);
}

.tx-amount {
    font-size: var(--font-size-base);
    color: var(--color-success);
    font-weight: 500;
}

.tx-hash {
    font-family: monospace;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}


.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Detail Cards */
.detail-card {
    background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg) 100%);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.detail-card h3 {
    padding: 1rem 1.5rem;
    background: var(--color-overlay);
    border-bottom: 1px solid var(--color-border);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.detail-row {
    display: flex;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

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

.detail-label {
    min-width: 143px;
    color: var(--color-text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.detail-value {
    flex: 1;
    color: var(--color-text);
    word-break: break-all;
    margin-left: 1rem;
}

/* Hash Links */
.hash {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: var(--color-accent);
    cursor: pointer;
    transition: color 0.2s ease;
}

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

.hash-truncate {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.hash-truncate a {
    color: inherit;
    text-decoration: none;
}

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

.address-link, .block-link {
    color: var(--color-accent);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.address-link:hover, .block-link:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* Make list items and transaction blocks clickable as full blocks */
a.list-item, a.tx-in-block {
    display: block;
    text-decoration: none;
    color: inherit;
}

a.list-item:hover, a.tx-in-block:hover {
    text-decoration: none;
}

/* Input/Output Tables */
.io-tables {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 950px) {
    .io-tables {
        grid-template-columns: 1fr;
    }
}

.io-section {
    background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg) 100%);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.io-header {
    padding: 1rem 1.5rem;
    background: var(--color-overlay);
    border-bottom: 1px solid var(--color-border);
}

.io-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.count-badge {
    background: var(--color-text-muted);
    color: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.io-table {
    width: 100%;
    border-collapse: collapse;
}

.io-table thead th {
    background: var(--color-bg-light);
    color: var(--color-text-muted);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
}

.io-table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.io-table tbody tr:last-child td {
    border-bottom: none;
}

.io-table tbody tr:hover {
    background: var(--color-overlay-accent);
}

.status-cell {
    width: 40px;
    text-align: center;
}

.index-cell {
    width: 50px;
    text-align: center;
    font-family: monospace;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.address-cell {
    min-width: 200px;
    font-family: monospace;
    font-size: var(--font-size-sm);
}

.amount-cell {
    width: 200px;
    text-align: right;
    font-weight: 600;
    color: var(--color-text);
    font-family: monospace;
    font-size: var(--font-size-base);
}

.amount-cell .usd-value {
    display: block;
}

.chain-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--color-accent);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: bold;
    transition: all 0.2s ease;
}

.chain-link:hover {
    background: var(--color-accent-hover);
    transform: scale(1.1);
}

.chain-link.spent {
    background: var(--color-success);
}

.script-tooltip {
    position: relative;
}

.script-tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 20px;
    background: var(--color-bg);
    color: var(--color-text);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: 500;
    box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.4);
}

.summary-label {
    width: 120px;
    color: var(--color-text-muted);
    font-weight: 500;
    padding: 0.75rem 1rem;
}

.summary-value {
    color: var(--color-text);
    padding: 0.75rem 1rem;
    word-break: break-all;
}

.address-link {
    color: var(--color-accent);
    text-decoration: none;
    word-break: break-all;
    transition: color 0.2s ease;
}

.address-link:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.coinbase-label {
    color: var(--color-success);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.coinbase-data {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-family: monospace;
    word-break: break-all;
}

.no-address {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-style: italic;
}

.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    font-style: italic;
}

.hash-cell {
    font-family: monospace;
    font-size: var(--font-size-sm);
    max-width: 200px;
}

.hash-link {
    color: var(--color-accent);
    text-decoration: none;
    word-break: break-all;
    transition: color 0.2s ease;
}

.hash-link:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.loading-amount, .loading-outputs {
    color: var(--color-text-muted);
    font-style: italic;
}

.outputs-cell {
    width: 80px;
    text-align: right;
    color: var(--color-text-muted);
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background: var(--color-overlay-accent) !important;
}

.type-cell {
    width: 80px;
}

.tx-type {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tx-type.inbound {
    background: var(--color-overlay-success);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.tx-type.outbound {
    background: var(--color-overlay-error);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.confirmed {
    background: var(--color-overlay-success);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.status-badge.unconfirmed {
    background: var(--color-overlay-error);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.time-cell {
    width: 120px;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* Address Summary Layout */
.address-summary-layout {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    padding: 1.5rem;
    align-items: start;
}

@media (max-width: 768px) {
    .address-summary-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.address-info-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.address-display {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.address-badge {
    display: flex;
    align-items: center;
}

.network-badge {
    background: var(--color-accent);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.address-main {
    font-family: monospace;
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-bg-light);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    word-break: break-all;
}

.balance-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.balance-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.balance-crypto {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: monospace;
}

.address-stats-table {
    width: 100%;
    border-collapse: collapse;
}

.address-stats-table td {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.address-stats-table tr:last-child td {
    border-bottom: none;
}

.stat-label {
    color: var(--color-text-muted);
    font-weight: 500;
    width: 40%;
}

.stat-value {
    color: var(--color-text);
    font-family: monospace;
    font-size: var(--font-size-base);
    text-align: right;
}

.qr-section {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.qr-container {
    background: white;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
}

.qr-code {
    display: block;
    border-radius: 0.25rem;
}


/* Transaction List */
.tx-list {
    display: flex;
    flex-direction: column;
}

.tx-in-block {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}

.tx-in-block:last-child {
    border-bottom: none;
}

.tx-in-block:hover {
    background: var(--color-overlay-accent);
}

/* Warning Messages */
.warning-section {
    margin-bottom: 1rem;
}

.warning-message {
    background: var(--color-overlay-error);
    border: 1px solid var(--color-error);
    color: var(--color-error);
    padding: 1rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-base);
}

/* Loading and Error States */
.loading {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem;
    font-style: italic;
}

.error {
    background: linear-gradient(135deg, var(--color-overlay-error) 0%, var(--color-overlay-error) 100%);
    border: 1px solid var(--color-error);
    color: var(--color-error);
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* Utility Classes */
.text-muted {
    color: var(--color-text-muted);
}

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

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

.text-red {
    color: var(--color-error);
}

.text-green {
    color: var(--color-success);
}

.text-small {
    font-size: var(--font-size-sm);
}

.text-xs {
    font-size: var(--font-size-sm);
}

.text-bold {
    font-weight: 600;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.text-right {
    text-align: right;
}

.offline-text {
    color: var(--color-error);
}

.usd-value {
    color: var(--color-text-muted);
}

/* Confirmation Status */
.confirmation-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.confirmation-status.confirmed {
    background: var(--color-overlay-success);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.confirmation-status.unconfirmed {
    background: var(--color-overlay-error);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.confirmation-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.confirmation-status.confirmed .confirmation-status-dot {
    background: var(--color-success);
}

.confirmation-status.unconfirmed .confirmation-status-dot {
    background: var(--color-error);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

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

.loading-content h1 {
    font-size: var(--font-size-3xl);
    color: var(--color-text);
    margin-bottom: var(--space-xl);
}

.loading-content p {
    color: var(--color-text-muted);
    margin-top: var(--space-lg);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Light Mode */
@media (prefers-color-scheme: light) {
    :root {
        /* Colors */
        --color-bg: #fafafa;
        --color-bg-light: rgba(240, 240, 240, 0.9);
        --color-text: #2a2a2a;
        --color-text-muted: #757575;
        --color-border: #d0d0d0;
        
        /* Alpha/Overlay Colors */
        --color-overlay: rgba(240, 240, 240, 0.8);
        --color-overlay-accent: rgba(59, 130, 246, 0.1);
        --color-overlay-success: rgba(16, 185, 129, 0.1);
        --color-overlay-error: rgba(239, 68, 68, 0.1);
        --color-shadow: rgba(0, 0, 0, 0.1);
    }
}

/* Footer */
.footer {
    margin-top: auto;
    padding: var(--space-lg) 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background-color: var(--color-bg);
}

.footer p {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

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

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