/* SpeyTech Training Dashboard - Terminal Aesthetic */

:root {
    --bg-primary: #0a0a0a;
    --bg-panel: #1a1a1a;
    --bg-header: #2a2a2a;
    --border-color: #333;
    --text-primary: #00ff88;
    --text-cyan: #00ffff;
    --text-orange: #ff6600;
    --text-red: #ff4444;
    --text-yellow: #ffcc00;
    --text-green: #44ff44;
    --text-dim: #666;
    --text-label: #888;
    --accent: #00ff88;
}

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

body {
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #0f1a0f 0%, #1a1a1a 100%);
    border: 2px solid var(--accent);
    border-radius: 4px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-title h1 {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: 20px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 25px;
}

.step-counter, .epoch-counter {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-label);
}

.live-dot {
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--text-primary); }
    50% { opacity: 0.5; box-shadow: 0 0 5px var(--text-primary); }
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto auto auto;
    gap: 15px;
    flex: 1;
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.panel-header {
    background: var(--bg-header);
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-label);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-content {
    padding: 12px;
}

/* Panel Positioning */
.progress-panel { grid-column: 1; grid-row: 1; }
.loss-panel { grid-column: 2 / 4; grid-row: 1; }
.merkle-panel { grid-column: 4; grid-row: 1 / 3; }
.determinism-panel { grid-column: 5; grid-row: 1 / 3; }
.gradient-panel { grid-column: 1; grid-row: 2; }
.optimizer-panel { grid-column: 2; grid-row: 2; }
.permutation-panel { grid-column: 3; grid-row: 2; }
.timing-panel { grid-column: 1 / 3; grid-row: 3; }
.fault-panel { grid-column: 3 / 5; grid-row: 3; }
.status-panel { grid-column: 5; grid-row: 3; }

/* Labels and Values */
.label {
    color: var(--text-label);
}

.label-small {
    font-size: 10px;
    color: var(--text-dim);
}

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

.value.small {
    font-size: 10px;
}

.value.mono {
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.cyan { color: var(--text-cyan) !important; }
.orange { color: var(--text-orange) !important; }
.green { color: var(--text-green) !important; }
.red { color: var(--text-red) !important; }
.dim { color: var(--text-dim) !important; }

/* Stat Rows */
.stat-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 8px;
    font-size: 12px;
}

.stat-row .label {
    flex: 1;
}

.stat-row .value {
    margin-right: 10px;
}

.stat-row.highlight .value {
    font-size: 14px;
}

.stat-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

/* Status Badge */
.status-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
}

.status-badge.good {
    background: rgba(0, 255, 136, 0.2);
    color: var(--text-primary);
    border: 1px solid var(--text-primary);
}

.status-badge.warn {
    background: rgba(255, 170, 0, 0.2);
    color: #ffaa00;
    border: 1px solid #ffaa00;
}

.status-badge.error {
    background: rgba(255, 68, 68, 0.2);
    color: var(--text-red);
    border: 1px solid var(--text-red);
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: #222;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
    flex: 1;
}

.progress-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 3px;
    transition: width 0.1s linear;
}

.epoch-progress {
    margin-top: 10px;
    font-size: 11px;
}

.epoch-progress .progress-bar {
    margin: 5px 0;
}

/* Sparkline */
.sparkline-container {
    position: relative;
    height: 120px;
}

.sparkline-container canvas {
    width: 100%;
    height: 100%;
}

.y-axis {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-dim);
    padding: 5px 0;
    text-align: right;
    padding-right: 5px;
}

/* Hash Display */
.hash-display {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: var(--text-dim);
    background: #111;
    padding: 6px 8px;
    border-radius: 3px;
    margin: 5px 0 10px 0;
    word-break: break-all;
    letter-spacing: 1px;
}

.hash-display.highlight {
    color: var(--text-cyan);
    border: 1px solid var(--text-cyan);
}

.hash-scroll {
    max-height: 100px;
    overflow-y: auto;
    background: #111;
    border-radius: 3px;
    padding: 5px;
    margin-bottom: 10px;
}

.hash-entry {
    font-size: 9px;
    color: var(--text-dim);
    padding: 3px 5px;
    border-bottom: 1px solid #222;
    font-family: 'Courier New', monospace;
}

.hash-entry:last-child {
    border-bottom: none;
}

.hash-entry .step-num {
    color: var(--text-label);
    margin-right: 10px;
}

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

/* Verify Button */
.verify-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--text-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.verify-btn:hover {
    background: rgba(0, 255, 136, 0.1);
}

.verify-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 14px;
}

.verify-result {
    margin-top: 8px;
    font-size: 10px;
    min-height: 20px;
    text-align: center;
}

/* Dual Run Display */
.dual-run {
    display: flex;
    align-items: center;
    gap: 10px;
}

.run-column {
    flex: 1;
    text-align: center;
}

.run-header {
    font-size: 10px;
    color: var(--text-label);
    margin-bottom: 8px;
}

.run-hash {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: var(--text-primary);
    background: #111;
    padding: 5px;
    border-radius: 3px;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.run-loss {
    font-size: 11px;
    color: var(--text-label);
}

.run-loss span {
    color: var(--text-cyan);
}

.run-compare {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 10px;
}

.compare-icon {
    font-size: 20px;
    color: var(--text-primary);
}

.compare-label {
    font-size: 9px;
    color: var(--text-primary);
    margin-top: 5px;
}

/* Gradient Bars */
.layer-gradients {
    margin-bottom: 10px;
}

.layer-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 11px;
}

.layer-name {
    width: 90px;
    color: var(--text-label);
}

.gradient-bar-container {
    flex: 1;
    height: 12px;
    background: #222;
    border-radius: 2px;
    margin: 0 10px;
    overflow: hidden;
}

.gradient-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--text-cyan), var(--text-primary));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.gradient-value {
    width: 50px;
    text-align: right;
    color: var(--text-dim);
    font-size: 10px;
}

/* Optimizer Selector */
.optimizer-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.opt-btn {
    flex: 1;
    padding: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-label);
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.opt-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.opt-btn.active {
    background: rgba(0, 255, 136, 0.2);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* Batch Indices */
.batch-indices {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.batch-idx {
    flex: 1;
    text-align: center;
    padding: 8px;
    background: #111;
    border-radius: 3px;
    font-size: 14px;
    color: var(--text-cyan);
    border: 1px solid #333;
}

/* Permutation Visual */
.permutation-visual {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    margin: 10px 0;
}

.perm-cell {
    aspect-ratio: 1;
    background: #222;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: var(--text-dim);
}

.perm-cell.active {
    background: var(--text-primary);
    color: #000;
}

.perm-cell.used {
    background: #333;
    color: var(--text-label);
}

/* Timing Bars */
.timing-breakdown {
    margin-bottom: 10px;
}

.timing-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 11px;
}

.timing-label {
    width: 100px;
    color: var(--text-label);
}

.timing-bar-container {
    flex: 1;
    height: 16px;
    background: #222;
    border-radius: 2px;
    margin: 0 10px;
    overflow: hidden;
}

.timing-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.timing-bar.forward { background: var(--text-cyan); }
.timing-bar.backward { background: var(--text-orange); }
.timing-bar.optimizer { background: var(--text-primary); }
.timing-bar.merkle { background: var(--text-yellow); }

.timing-value {
    width: 60px;
    text-align: right;
    color: var(--text-dim);
    font-size: 10px;
}

/* Fault Grid */
.fault-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.fault-item {
    text-align: center;
    padding: 10px;
    background: #111;
    border-radius: 3px;
}

.fault-label {
    display: block;
    font-size: 10px;
    color: var(--text-label);
    margin-bottom: 5px;
}

.fault-count {
    display: block;
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

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

.fault-dot.good {
    background: var(--text-primary);
    box-shadow: 0 0 6px var(--text-primary);
}

.fault-dot.bad {
    background: var(--text-red);
    box-shadow: 0 0 6px var(--text-red);
}

/* Status Rows */
.status-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
}

.status-row .label {
    flex: 1;
}

.status-row .value {
    margin-right: 10px;
}

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

.status-dot.good {
    background: var(--text-primary);
    box-shadow: 0 0 6px var(--text-primary);
}

/* Footer */
.footer {
    background: var(--bg-header);
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 11px;
    color: var(--text-label);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.separator {
    color: var(--border-color);
}

.footer-right {
    margin-left: auto;
}

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

.footer a:hover {
    text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Responsive */
@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .progress-panel { grid-column: 1; grid-row: 1; }
    .loss-panel { grid-column: 2 / 4; grid-row: 1; }
    .merkle-panel { grid-column: 1; grid-row: 2; }
    .determinism-panel { grid-column: 2; grid-row: 2; }
    .gradient-panel { grid-column: 3; grid-row: 2; }
    .optimizer-panel { grid-column: 1; grid-row: 3; }
    .permutation-panel { grid-column: 2; grid-row: 3; }
    .timing-panel { grid-column: 3; grid-row: 3; }
    .fault-panel { grid-column: 1 / 3; grid-row: 4; }
    .status-panel { grid-column: 3; grid-row: 4; }
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .header-status {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .fault-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Scanline effect (subtle) */
.container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.03) 0px,
        rgba(0, 0, 0, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}
