* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: #0f172a;
    color: #f1f5f9;
    font-family: Arial, sans-serif;
}

header {
    padding: 20px 5%;
    border-bottom: 1px solid #334155;
    color: #38bdf8;
}

main {
    max-width: 1200px;
    margin: auto;
    padding: 40px 20px;
}

.hero {
    text-align: center;
    padding: 60px 0;
}

.hero h1 {
    font-size: 3rem;
    margin: 20px 0;
}

.hero span {
    color: #38bdf8;
    letter-spacing: 3px;
    font-size: 0.8rem;
}

p {
    color: #94a3b8;
    line-height: 1.6;
}

.widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.widget {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 25px;
    transition: 0.2s;
}

.widget:hover {
    border-color: #38bdf8;
    transform: translateY(-4px);
}

.widget span {
    color: #38bdf8;
}

footer {
    text-align: center;
    color: #94a3b8;
    padding: 30px;
    margin-top: 50px;
    border-top: 1px solid #334155;
}

/* Sorting visualizer */

header a,
.widget a {
    color: #38bdf8;
    text-decoration: none;
}

.sort-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background-color: #1e293b;
    border-radius: 12px;
    margin: 30px 0;
}

.sort-controls label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

input[type="range"] {
    accent-color: #38bdf8;
}

button {
    background-color: #38bdf8;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    padding: 12px 18px;
    font-weight: bold;
    cursor: pointer;
}

button:hover {
    background-color: #7dd3fc;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sort-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.sort-card {
    min-width: 0;
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 220px;
    background-color: #0f172a;
    border-radius: 8px;
    padding: 10px;
    margin: 20px 0;
}

.bar {
    flex: 1;
    min-width: 0;
    background-color: #38bdf8;
    border-radius: 3px 3px 0 0;
}

.bar.compare {
    background-color: #f59e0b;
}

.bar.swap {
    background-color: #a855f7;
}

.bar.sorted {
    background-color: #22c55e;
}

.sort-stats {
    border-top: 1px solid #334155;
    margin-bottom: 20px;
}

.sort-stats span {
    color: #f1f5f9;
    font-weight: bold;
}

details summary {
    color: #38bdf8;
    cursor: pointer;
}

pre {
    background-color: #0f172a;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
}

code {
    font-family: Consolas, monospace;
    font-size: 0.85rem;
}

/* Go source code highlighting */

.go-keyword {
    color: #c084fc;
}

.go-type {
    color: #38bdf8;
}

.go-string {
    color: #86efac;
}

.go-comment {
    color: #94a3b8;
    font-style: italic;
}

.go-value {
    color: #fbbf24;
}

.copy-source {
    margin-top: 15px;
    padding: 8px 12px;
    background-color: #334155;
    color: #f1f5f9;
    font-size: 0.8rem;
}

.copy-source:hover {
    background-color: #475569;
}

.sort-card pre {
    max-height: 450px;
    overflow: auto;
    line-height: 1.6;
    font-size: 0.85rem;
    border: 1px solid #334155;
}

.sort-card details {
    margin-top: 15px;
}

.sort-grid {
    align-items: start;
}

/* CDN health monitor */

.health-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 25px 0;
}

.health-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.health-stat {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px;
}

.health-stat h3 {
    color: #94a3b8;
    font-size: 1rem;
    margin: 0 0 15px;
}

.health-stat span {
    font-size: 2.5rem;
    font-weight: bold;
}

#total-servers {
    color: #38bdf8;
}

#healthy-servers {
    color: #4ade80;
}

#unhealthy-servers {
    color: #f87171;
}

.health-panel {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
}

.table-container {
    overflow-x: auto;
}

.health-table {
    width: 100%;
    border-collapse: collapse;
}

.health-table th,
.health-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #334155;
}

.health-table th {
    color: #94a3b8;
}

.health-table tbody tr:hover {
    background-color: #0f172a;
}

.status-healthy {
    color: #4ade80;
}

.status-unhealthy,
.status-unreachable {
    color: #f87171;
}

.status-timeout {
    color: #fbbf24;
}

.status-cancelled {
    color: #94a3b8;
}

.performance-row {
    margin: 25px 0;
}

.performance-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.performance-track {
    height: 24px;
    background-color: #0f172a;
    border-radius: 6px;
    overflow: hidden;
}

.performance-bar {
    height: 100%;
    width: 0;
    transition: width 0.5s ease;
    border-radius: 6px;
}

.performance-bar.sequential {
    background-color: #f59e0b;
}

.performance-bar.concurrent {
    background-color: #38bdf8;
}

.performance-summary {
    text-align: center;
    padding: 20px;
}

#speedup {
    color: #4ade80;
    font-size: 2.5rem;
}

/* Individual server latency bars */

.latency-track {
    height: 8px;
    min-width: 100px;
    margin-top: 8px;
    background-color: #0f172a;
    border-radius: 4px;
    overflow: hidden;
}

.latency-bar {
    height: 100%;
    width: 0;
    background-color: #38bdf8;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.latency-bar.failed {
    background-color: #f87171;
}

.health-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#time-reduction {
    color: #4ade80;
    font-weight: bold;
}

/* Health monitor source code panels */

.health-source {
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.health-source summary {
    cursor: pointer;
    color: #38bdf8;
    font-weight: bold;
}

.health-source summary:hover {
    color: #7dd3fc;
}

.health-source pre {
    background-color: #020617;
    border-radius: 8px;
    padding: 20px;
    margin-top: 15px;
    max-height: 450px;
    overflow: auto;
}

.health-source code {
    font-family: Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.health-source .copy-source {
    margin-top: 10px;
}

.health-source .copy-source:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* CDN Cache Simulator */

.cache-panel {
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
}

.cache-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
}

.cache-controls label {
    color: #cbd5e1;
    font-weight: bold;
}

.cache-controls select {
    background-color: #0f172a;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 1rem;
}

.cache-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#cache-status,
#workload-status {
    color: #94a3b8;
    margin: 20px 0;
}

.cache-stats {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(150px, 1fr)
    );
    gap: 15px;
    margin: 25px 0;
}

.cache-stat {
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 20px;
}

.cache-stat h3 {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0 0 12px;
}

.cache-stat strong {
    color: #38bdf8;
    font-size: 2rem;
}

#cache-hits,
#workload-hit-rate {
    color: #4ade80;
}

#cache-misses,
#workload-origin-requests {
    color: #fbbf24;
}

#cache-evictions,
#workload-evictions {
    color: #f87171;
}

.cache-latest {
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 20px;
    margin: 25px 0;
}

.cache-latest h3 {
    margin-top: 0;
}

.cache-table-container {
    overflow-x: auto;
    margin-top: 15px;
}

.cache-table {
    width: 100%;
    border-collapse: collapse;
}

.cache-table th,
.cache-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #334155;
}

.cache-table th {
    color: #94a3b8;
}

.cache-table tbody tr:hover {
    background-color: #0f172a;
}

.cache-source-hit {
    color: #4ade80;
}

.cache-source-miss {
    color: #fbbf24;
}

.cache-source-shared {
    color: #38bdf8;
}

.cache-hit-track {
    width: 100%;
    height: 24px;
    background-color: #0f172a;
    border-radius: 6px;
    overflow: hidden;
    margin: 20px 0;
}

#workload-hit-bar {
    width: 0%;
    height: 100%;
    background-color: #4ade80;
    border-radius: 6px;
    transition: width 0.6s ease;
}

@media (max-width: 600px) {
    .cache-panel {
        padding: 15px;
    }

    .cache-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* LRU cache visualization */

.cache-order-section {
    margin: 30px 0;
    padding: 20px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
}

.cache-order-section h3 {
    margin-top: 0;
}

.cache-order-labels {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 20px 0 10px;
}

.cache-order {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(135px, 1fr)
    );
    gap: 12px;
    min-height: 100px;
}

.cache-order-card {
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 10px;
    padding: 18px 10px;
    text-align: center;
}

.cache-order-card strong {
    display: block;
    color: #e2e8f0;
    font-size: 1rem;
    margin-bottom: 8px;
}

.cache-order-card small {
    color: #94a3b8;
}

.cache-order-card.lru-oldest {
    border-color: #f59e0b;
}

.cache-order-card.lru-newest {
    border-color: #22c55e;
}

.cache-order-empty {
    color: #94a3b8;
    align-self: center;
}

/* CDN cache source code viewer */

.cache-source {
    margin-top: 15px;
    padding: 16px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
}

.cache-source summary {
    color: #38bdf8;
    cursor: pointer;
    font-weight: 600;
}

.cache-source summary:hover {
    color: #7dd3fc;
}

.cache-source pre {
    max-height: 450px;
    overflow: auto;
    margin-top: 15px;
    padding: 20px;
    background: #020617;
    border-radius: 8px;
}

.cache-source code {
    font-family: Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #e2e8f0;
}

.cache-source .copy-source {
    margin-top: 12px;
}

.cache-source .copy-source:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Go syntax highlighting */

.cache-source .go-keyword {
    color: #c084fc;
}

.cache-source .go-type {
    color: #38bdf8;
}

.cache-source .go-string {
    color: #a3e635;
}

.cache-source .go-comment {
    color: #94a3b8;
}

.cache-source .go-value {
    color: #fbbf24;
}