/* --- GLOBAL & ROOT --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0a0;
    --accent-yellow: #f9b208;
    --accent-blue: #3498db;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    --border-color: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

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

a:hover {
    text-decoration: underline;
}

/* --- LAYOUT & NAVIGATION --- */

nav {
    background-color: var(--bg-card);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

nav .brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}
nav .brand span {
    color: var(--accent-yellow);
}

nav form {
    display: flex;
    flex-grow: 0.5;
}

nav input[type="search"] {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-right: none;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border-radius: 4px 0 0 4px;
    font-size: 1rem;
}
nav input[type="search"]:focus {
    outline: none;
    border-color: var(--accent-yellow);
}

nav button {
    padding: 0.6rem 1.5rem;
    border: 1px solid var(--accent-yellow);
    background-color: var(--accent-yellow);
    color: var(--bg-dark);
    font-weight: bold;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}
nav button:hover {
    background-color: #ffc107;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

footer {
    text-align: center;
    margin-top: 4rem;
    padding: 2rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
}

/* --- GENERAL COMPONENTS --- */

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
}
.card.error { border-left: 5px solid var(--accent-red); }

h1, h2, h3 { color: var(--text-primary); }
h1 { font-size: 2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
h1 .icon { font-size: 1.5rem; color: var(--accent-yellow); }
h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}
.header { text-align: center; margin-bottom: 3rem; }
.header p { color: var(--text-secondary); font-size: 1.1rem; }

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

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Roboto Mono', monospace;
}
th {
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.8rem;
}
tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}
td a {
    word-break: break-all;
}

.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.8em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
    font-family: 'Inter', sans-serif;
}
.badge-yellow {
    color: #121212;
    background-color: var(--accent-yellow);
}
.badge-green {
    color: #fff;
    background-color: var(--accent-green);
}
.badge-blue {
    color: #fff;
    background-color: var(--accent-blue);
}

/* --- SPECIFIC PAGE LAYOUTS --- */

.info-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1rem;
    align-items: center;
}
.info-grid .label {
    font-weight: bold;
    color: var(--text-secondary);
}
.info-grid .value {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-dark);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    word-break: break-all;
}

.tx-details { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 2rem; }
.tx-details .arrow { font-size: 3rem; color: var(--accent-yellow); text-align: center; margin-top: 2rem; }
.io-item { border: 1px solid var(--border-color); border-radius: 5px; padding: 1.5rem; margin-bottom: 1rem; }
.io-item p { margin: 0; }
.io-item .address { font-family: 'Roboto Mono', monospace; word-break: break-all; }
.io-item .address a { color: var(--text-primary); }
.io-item .amount { font-weight: bold; color: var(--accent-yellow); margin-top: 0.5rem; }

/* --- HOMEPAGE DASHBOARD --- */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        "mempool-blocks center-line mined-blocks"
        "fee-card fee-card fee-card"
        "difficulty-card difficulty-card difficulty-card";
    gap: 1.5rem;
    align-items: center;
}

.mempool-blocks-container { grid-area: mempool-blocks; }
.mined-blocks-container { grid-area: mined-blocks; }
.fee-card { grid-area: fee-card; }
.difficulty-card { grid-area: difficulty-card; }

.center-line {
    grid-area: center-line;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--border-color), transparent);
    justify-self: center;
}

.mempool-blocks-container, .mined-blocks-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.block-card {
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
}

.block-mempool {
    background-color: #2c3e50;
    border-left: 5px solid var(--accent-blue);
    color: var(--text-secondary);
}
.block-mempool .total-fees {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-blue);
}

.block-mined {
    background-color: var(--bg-card);
    border-left: 5px solid var(--accent-yellow);
}
.block-mined .block-height a {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-primary);
}
.block-mined .total-fees {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-yellow);
}
.block-mined .pool-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}
.block-card .fee-range, .block-card .median-fee, .block-card .time-since { font-size: 0.9rem; color: var(--text-secondary); }
.block-card .tx-count { font-size: 0.9rem; margin-bottom: 0.5rem; }

.fee-card, .difficulty-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    margin-top: 1rem;
}
.fee-card h2, .difficulty-card h2 {
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin-bottom: 1.5rem;
}
.fee-levels {
    display: flex;
    justify-content: space-around;
    text-align: center;
    flex-wrap: wrap;
    gap: 1rem;
}
.fee-level .level-title {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.fee-level .fee-rate {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.difficulty-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.difficulty-details .change-percent.positive { color: var(--accent-green); }
.difficulty-details .change-percent.negative { color: var(--accent-red); }
.difficulty-details .time-estimate { text-align: right; }
.difficulty-details .time-estimate span { font-size: 0.9rem; color: var(--text-secondary); display: block; }

.progress-bar-container {
    height: 10px;
    width: 100%;
    background-color: var(--bg-dark);
    border-radius: 5px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background-color: var(--accent-yellow);
    border-radius: 5px;
}

/* --- RESPONSIVE MEDIA QUERIES --- */

@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "mined-blocks"
            "mempool-blocks"
            "fee-card"
            "difficulty-card";
    }
    .center-line { display: none; }
    .tx-details { grid-template-columns: 1fr; }
    .tx-details .arrow { transform: rotate(90deg); margin: 1rem auto; }
}

@media (max-width: 768px) {
    nav { flex-direction: column; gap: 1rem; }
    nav form { width: 100%; }
    .info-grid { grid-template-columns: 1fr; }
    .info-grid .label { font-weight: normal; color: var(--text-secondary); }
}