/* sols.stream Program Explorer - Dark theme */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --yellow: #d29922;
    --red: #f85149;
    --gray: #6e7681;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header / Nav */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 4px;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

nav a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

nav a.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Main content */
main {
    padding: 24px 0;
}

/* Card / Section */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 16px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 13px;
}

th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-tertiary);
}

tr.clickable {
    cursor: pointer;
}

/* Key-value table for detail views */
.kv-table {
    width: 100%;
}

.kv-table td {
    padding: 8px 12px;
}

.kv-table td:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    width: 240px;
    font-family: var(--font-sans);
    font-size: 13px;
}

.kv-table td:last-child {
    font-family: var(--font-mono);
    word-break: break-all;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-sans);
}

.badge-open {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-closing {
    background: rgba(210, 153, 34, 0.15);
    color: var(--yellow);
    border: 1px solid rgba(210, 153, 34, 0.3);
}

.badge-closed {
    background: rgba(110, 118, 129, 0.15);
    color: var(--gray);
    border: 1px solid rgba(110, 118, 129, 0.3);
}

.badge-active {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.badge-disabled {
    background: rgba(248, 81, 73, 0.15);
    color: var(--red);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

/* Links */
a {
    color: var(--accent);
    text-decoration: none;
}

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

/* Pubkey display */
.pubkey {
    font-family: var(--font-mono);
    font-size: 13px;
}

.pubkey-full {
    word-break: break-all;
}

/* Amount display */
.amount {
    font-family: var(--font-mono);
    text-align: right;
}

/* Loading / Error states */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--text-secondary);
    gap: 12px;
}

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

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

.error-box {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--red);
    padding: 12px 16px;
    border-radius: 6px;
    margin: 16px 0;
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

/* Cluster selector */
.cluster-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cluster-selector select,
.cluster-selector input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-mono);
    outline: none;
}

.cluster-selector select:focus,
.cluster-selector input:focus {
    border-color: var(--accent);
}

.cluster-selector input {
    width: 280px;
}

.cluster-selector label {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Section titles */
h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

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

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

.mb-16 {
    margin-bottom: 16px;
}

/* Cache status indicators */
.cache-updating {
    font-size: 11px;
    font-weight: normal;
    color: var(--yellow);
    margin-left: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

.cache-age {
    font-size: 11px;
    font-weight: normal;
    color: var(--text-muted);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.btn-clear-cache {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
}
.btn-clear-cache:hover {
    background: #c82333;
}

/* Phase D — Manual refresh button (lives in card-header next to the title) */
.btn-refresh {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
}
.btn-refresh:hover:not(:disabled) {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--accent);
}
.btn-refresh:disabled {
    cursor: progress;
    opacity: 0.7;
}
.btn-refresh-glyph {
    display: inline-block;
    transform: translateY(-1px);
}
.btn-refresh-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Phase C — Live mode toggle */
.cluster-selector-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}
.live-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}
.live-mode-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.live-mode-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.live-mode-radio input[type="radio"] {
    accent-color: var(--accent);
    margin: 0;
}

/* Phase C — Costs dashboard */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
}
.stat-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.stat-card-value {
    font-family: var(--font-mono);
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.stat-card-caveat {
    font-size: 11px;
    color: var(--text-muted);
}

/* Phase C — Tx feed */
.tx-detail-row td {
    background: var(--bg-primary) !important;
    padding: 12px 16px;
}
.tx-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tx-detail-meta {
    color: var(--text-secondary);
    font-size: 12px;
}
.ix-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}
.ix-card-name {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 8px;
}
.ix-card-section {
    margin-top: 8px;
}
.ix-card-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.ix-card-table {
    width: 100%;
    font-size: 12px;
}
.ix-card-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
}
.ix-card-table td.ix-card-key {
    width: 200px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
}
.role-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-signer {
    background: rgba(88, 166, 255, 0.15);
    color: var(--accent);
}
.role-writable {
    background: rgba(210, 153, 34, 0.15);
    color: var(--yellow);
}
.role-readonly {
    background: rgba(110, 118, 129, 0.15);
    color: var(--gray);
}
.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }
.status-ok { color: var(--green); font-weight: bold; }
.status-fail { color: var(--red); font-weight: bold; }
.event-row {
    margin-top: 8px;
}
.event-body {
    background: var(--bg-tertiary);
    padding: 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    overflow-x: auto;
    color: var(--text-primary);
}
.btn-load-older {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-load-older:hover { border-color: var(--accent); }
.btn-load-older:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.ws-dot {
    color: var(--green);
    margin-left: 6px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 12px;
    }

    header .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .cluster-selector {
        flex-wrap: wrap;
    }

    .cluster-selector input {
        width: 100%;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 6px 8px;
    }

    .kv-table td:first-child {
        width: 140px;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
    .cluster-selector-wrap {
        align-items: flex-start;
    }
}
