@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Syne:wght@400;600;700&display=swap');

:root {
    --bg-base:        #080c14;
    --bg-panel:       #0d1320;
    --bg-card:        #111827;
    --bg-card-hover:  #151f30;
    --border-dim:     rgba(255,255,255,0.06);
    --border-bright:  rgba(255,255,255,0.12);
    --text-primary:   #e8edf5;
    --text-secondary: #7a8ba0;
    --text-mono:      #a8b8cc;
    --accent-blue:    #3b82f6;
    --accent-cyan:    #06b6d4;

    --status-uplink:        #111827;
    --status-uplink-border: rgba(59,130,246,0.25);
    --status-uplink-glow:   rgba(59,130,246,0.08);

    --status-join:          #111827;
    --status-join-border:   rgba(6,182,212,0.25);
    --status-join-glow:     rgba(6,182,212,0.08);

    --status-timeout:       #1a1200;
    --status-timeout-border:#d97706;
    --status-timeout-glow:  rgba(217,119,6,0.12);
    --status-timeout-text:  #fbbf24;

    --status-inactive:      #1a0808;
    --status-inactive-border:#dc2626;
    --status-inactive-glow: rgba(220,38,38,0.12);
    --status-inactive-text: #f87171;
}

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

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Syne', sans-serif;
    min-height: 100vh;
    padding: 24px 20px;
    /* Subtle grid texture */
    background-image:
        linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* ── Header ── */
.title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 8px;
    position: relative;
}

.title::after {
    content: '';
    display: block;
    width: 48px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    margin: 8px auto 24px;
    border-radius: 2px;
}

/* ── Layout ── */
.columns {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* ── Scroll panels ── */
.column-panel {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border-dim);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    max-height: 88vh;
}

.column-panel h3 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-dim);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.scroll-box {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.scroll-box::-webkit-scrollbar { width: 4px; }
.scroll-box::-webkit-scrollbar-track { background: transparent; }
.scroll-box::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 4px;
}

/* Column indicator dot */
#uplink-devices h3::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 6px var(--accent-blue);
}

#join-devices h3::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 6px var(--accent-cyan);
}

/* ── Device card ── */
.device-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-dim);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    position: relative;
    overflow: hidden;
}

/* Left accent bar */
.device-row::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    border-radius: 8px 0 0 8px;
    background: var(--border-bright);
    transition: background 0.15s ease;
}

.device-row:hover {
    transform: translateX(2px);
    background: var(--bg-card-hover);
}

/* ── Status variants ── */
.uplink {
    background: var(--status-uplink);
    border-color: var(--status-uplink-border);
    box-shadow: inset 0 0 20px var(--status-uplink-glow);
}
.uplink::before { background: var(--accent-blue); }

.join {
    background: var(--status-join);
    border-color: var(--status-join-border);
    box-shadow: inset 0 0 20px var(--status-join-glow);
}
.join::before { background: var(--accent-cyan); }

.join-timeout {
    background: var(--status-timeout);
    border-color: var(--status-timeout-border);
    box-shadow: inset 0 0 24px var(--status-timeout-glow),
                0 0 0 1px rgba(217,119,6,0.15);
    animation: pulse-warn 2.5s ease-in-out infinite;
}
.join-timeout::before { background: #d97706; }

.inactive {
    background: var(--status-inactive);
    border-color: var(--status-inactive-border);
    box-shadow: inset 0 0 24px var(--status-inactive-glow),
                0 0 0 1px rgba(220,38,38,0.15);
    animation: pulse-crit 2.5s ease-in-out infinite;
}
.inactive::before { background: #dc2626; }

@keyframes pulse-warn {
    0%, 100% { box-shadow: inset 0 0 24px var(--status-timeout-glow), 0 0 0 1px rgba(217,119,6,0.15); }
    50%       { box-shadow: inset 0 0 32px rgba(217,119,6,0.2),        0 0 0 1px rgba(217,119,6,0.35); }
}

@keyframes pulse-crit {
    0%, 100% { box-shadow: inset 0 0 24px var(--status-inactive-glow), 0 0 0 1px rgba(220,38,38,0.15); }
    50%       { box-shadow: inset 0 0 32px rgba(220,38,38,0.22),        0 0 0 1px rgba(220,38,38,0.4); }
}

/* ── Card content ── */
.device-left  { flex: 8; padding-right: 10px; }
.device-right {
    flex: 2;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    padding-top: 2px;
    white-space: nowrap;
}

.device-left strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.join-timeout .device-left strong { color: var(--status-timeout-text); }
.inactive     .device-left strong { color: var(--status-inactive-text); }

.meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.8;
}

.meta br { display: block; content: ''; }

/* ── Payload box ── */
.payload-box {
    display: none;
    margin-top: 10px;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-bright);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-mono);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
}

/* ── Footer Initial ── */
#htho-footer {
    position: fixed;
    bottom: 16px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
    overflow: hidden;
    padding: 8px 12px;
    border-radius: 8px;
}

#htho-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#htho-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: rgba(180,195,215,0.3);
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 2;
    cursor: default;
    user-select: none;
    transition: color 0.3s ease;
}

#htho-footer:hover #htho-label { color: rgba(180,195,215,0.7); }

.htho-h   { color: #3b82f6; opacity: 0.4; transition: opacity 0.3s, text-shadow 0.3s; }
.htho-tho { color: #06b6d4; opacity: 0.4; transition: opacity 0.3s, text-shadow 0.3s; }

#htho-footer:hover .htho-h   { opacity: 1; text-shadow: 0 0 12px rgba(59,130,246,0.6); }
#htho-footer:hover .htho-tho { opacity: 1; text-shadow: 0 0 12px rgba(6,182,212,0.6); }
