/* ============================================================
   completengine.net -- Simulation Control Room Dashboard
   Colors: #0a0e17 #141b2d #2a3350 #00e5ff #ffab00 #ff1744
           #00e676 #e8eaf6 #7986a0 #1a237e
   Fonts: Share Tech Mono, Chakra Petch, Inter, Orbitron
   ============================================================ */

:root {
    --void: #0a0e17;
    --panel: #141b2d;
    --wire: #2a3350;
    --cyan: #00e5ff;
    --amber: #ffab00;
    --red: #ff1744;
    --green: #00e676;
    --white: #e8eaf6;
    --fog: #7986a0;
    --plasma: #1a237e;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--void);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

/* ===== Scanline Overlay ===== */
.scanline-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        transparent, transparent 2px,
        rgba(0, 0, 0, 0.03) 2px, rgba(0, 0, 0, 0.03) 3px
    );
    pointer-events: none;
    z-index: 999;
}

/* ===== HUD Frame ===== */
.hud-frame {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 1px solid var(--cyan);
    pointer-events: none;
    z-index: 998;
    opacity: 0.3;
}

.corner-mark {
    position: absolute;
    width: 20px;
    height: 20px;
}

.corner-mark::before, .corner-mark::after {
    content: '';
    position: absolute;
    background: var(--fog);
}

.corner-mark.tl { top: 4px; left: 4px; }
.corner-mark.tl::before { width: 20px; height: 1px; top: 0; left: 0; }
.corner-mark.tl::after { width: 1px; height: 20px; top: 0; left: 0; }

.corner-mark.tr { top: 4px; right: 4px; }
.corner-mark.tr::before { width: 20px; height: 1px; top: 0; right: 0; }
.corner-mark.tr::after { width: 1px; height: 20px; top: 0; right: 0; }

.corner-mark.bl { bottom: 4px; left: 4px; }
.corner-mark.bl::before { width: 20px; height: 1px; bottom: 0; left: 0; }
.corner-mark.bl::after { width: 1px; height: 20px; bottom: 0; left: 0; }

.corner-mark.br { bottom: 4px; right: 4px; }
.corner-mark.br::before { width: 20px; height: 1px; bottom: 0; right: 0; }
.corner-mark.br::after { width: 1px; height: 20px; bottom: 0; right: 0; }

/* ===== HUD Title ===== */
.hud-title {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-align: center;
}

.hud-logo {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 12px;
    letter-spacing: 0.15em;
    color: var(--cyan);
    text-transform: uppercase;
}

.hud-ver {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--fog);
    margin-left: 8px;
}

/* ===== Dashboard Grid ===== */
#dashboard {
    display: grid;
    grid-template-columns: 30% 1fr 25%;
    grid-template-rows: 1fr 60px;
    height: 100vh;
    gap: 1px;
    padding: 32px 4px 4px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--wire);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--fog);
    padding: 10px 14px;
    border-bottom: 1px solid var(--wire);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.panel-header-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--fog);
    text-transform: uppercase;
}

/* ===== Thread Pool ===== */
#thread-pool {
    grid-row: 1;
    grid-column: 1;
}

.thread-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--wire) var(--void);
}

.thread-bar {
    height: 18px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: var(--void);
    cursor: pointer;
    transition: background 0.5s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.thread-bar.idle { background: #2a3350; color: var(--fog); }
.thread-bar.running { background: var(--cyan); box-shadow: inset 0 0 8px rgba(0,229,255,0.3); animation: threadPulse 2s ease-in-out infinite; }
.thread-bar.blocked { background: var(--amber); box-shadow: inset 0 0 8px rgba(255,171,0,0.3); }
.thread-bar.terminated { background: var(--red); opacity: 0.5; }

@keyframes threadPulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

/* ===== Event Stream ===== */
#event-stream {
    grid-row: 1;
    grid-column: 2;
}

.stream-tabs {
    display: flex;
    gap: 4px;
}

.stream-tab {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: var(--fog);
    background: transparent;
    border: 1px solid var(--wire);
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.04em;
}

.stream-tab.active {
    color: var(--cyan);
    border-color: var(--cyan);
    background: rgba(0, 229, 255, 0.08);
}

.event-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--wire) var(--void);
}

.event-card {
    background: var(--panel);
    border: 1px solid var(--wire);
    border-left: 3px solid var(--cyan);
    padding: 14px 16px;
    border-radius: 2px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 1s ease;
    animation: cardSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cardSlideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.event-card:hover {
    transform: translateY(-2px);
    border-left-width: 6px;
}

.event-card.priority-elevated { border-left-color: var(--amber); }
.event-card.priority-critical { border-left-color: var(--red); }
.event-card.faded { opacity: 0.3; }

.event-timestamp {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    color: var(--fog);
    letter-spacing: 0.04em;
    font-feature-settings: 'tnum' 1;
}

.event-badge {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 2px;
    margin-left: 8px;
}

.badge-p0 { background: var(--red); color: var(--void); }
.badge-p1 { background: var(--amber); color: var(--void); }
.badge-p2 { background: var(--cyan); color: var(--void); }

.event-title {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--white);
    margin: 8px 0 6px;
}

.event-body {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: var(--white);
    line-height: 1.6;
    letter-spacing: 0.01em;
}

/* ===== Resource Monitor ===== */
#resource-monitor {
    grid-row: 1;
    grid-column: 3;
}

.metrics {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--fog);
}

.metric-bar {
    height: 80px;
    background: var(--void);
    border: 1px solid var(--wire);
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.metric-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 229, 255, 0.4);
    border-top: 2px solid var(--cyan);
    transition: height 1s ease;
}

.metric-fill-amber {
    background: rgba(255, 171, 0, 0.3);
    border-top-color: var(--amber);
}

.metric-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 16px;
    color: var(--cyan);
    font-feature-settings: 'tnum' 1;
}

.metric-counter {
    font-family: 'Share Tech Mono', monospace;
    font-size: 20px;
    color: var(--cyan);
    font-feature-settings: 'tnum' 1;
}

.metric-counter-green { color: var(--green); }

.metric-counter small {
    font-size: 11px;
    color: var(--fog);
}

/* ===== Timeline Bar ===== */
#timeline-bar {
    grid-row: 2;
    grid-column: 1 / -1;
}

.timeline-track {
    position: relative;
    height: 100%;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    overflow-x: auto;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--cyan);
    box-shadow: 0 0 20px var(--cyan);
    z-index: 5;
    left: 0%;
    transition: left 0.5s linear;
}

.timeline-ticks {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: max-content;
}

.timeline-tick {
    width: 1px;
    height: 16px;
    background: var(--fog);
    opacity: 0.5;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
}

.timeline-tick.major {
    height: 24px;
    opacity: 0.8;
}

.timeline-tick .tick-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel);
    border: 1px solid var(--wire);
    padding: 4px 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--fog);
    white-space: nowrap;
    margin-bottom: 4px;
}

.timeline-tick:hover .tick-tooltip {
    display: block;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    html, body { overflow: auto; }

    #dashboard {
        grid-template-columns: 1fr;
        grid-template-rows: 80px 1fr auto 60px;
        height: auto;
        min-height: 100vh;
    }

    #thread-pool {
        grid-column: 1;
        grid-row: 1;
    }

    .thread-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 4px;
    }

    .thread-bar {
        min-width: 80px;
        height: 100%;
    }

    #event-stream { grid-column: 1; grid-row: 2; }
    #resource-monitor { grid-column: 1; grid-row: 3; }
    #timeline-bar { grid-column: 1; grid-row: 4; }

    .hud-frame { display: none; }
    .hud-title { display: none; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .thread-bar { animation: none; }
    .event-card { animation: none; opacity: 1; transform: none; }
    .playhead { transition: none; }
    .metric-fill { transition: none; }
}
