/* ===== STATELOT — Black & Red Hacker Theme ===== */

:root {
  --bg: #050505;
  --bg-panel: #0a0a0a;
  --bg-panel-2: #0d0d0d;
  --red: #ff0033;
  --red-dim: #cc0029;
  --red-glow: rgba(255, 0, 51, 0.6);
  --red-soft: rgba(255, 0, 51, 0.15);
  --amber: #ffaa00;
  --green: #00ff66;
  --green-dim: #00cc52;
  --text: #c8c8c8;
  --text-dim: #666;
  --text-bright: #e8e8e8;
  --border: #1a1a1a;
  --border-red: rgba(255, 0, 51, 0.3);
  --font-mono: 'Share Tech Mono', 'Courier New', monospace;
  --font-term: 'VT323', 'Courier New', monospace;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  position: relative;
}

/* ===== Matrix canvas ===== */
#matrix {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.35;
}

/* ===== Overlay effects ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.15) 3px,
    rgba(0, 0, 0, 0.15) 4px
  );
}

.vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.7) 100%);
}

.flicker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--red-soft);
  opacity: 0;
  animation: flicker 8s infinite;
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 0; }
  96% { opacity: 0.04; }
  97% { opacity: 0; }
  98% { opacity: 0.06; }
  99% { opacity: 0; }
}

/* ===== Boot screen ===== */
.boot {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: var(--bg);
  padding: 40px;
  font-family: var(--font-term);
  font-size: 20px;
  color: var(--red);
  overflow: hidden;
}

.boot-text {
  white-space: pre-wrap;
  line-height: 1.4;
}

.boot-cursor {
  display: inline-block;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Main terminal ===== */
.terminal {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.terminal.hidden {
  display: none;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 44px;
  background: linear-gradient(180deg, #0d0d0d, #080808);
  border-bottom: 1px solid var(--border-red);
  box-shadow: 0 0 20px rgba(255, 0, 51, 0.1);
}

.topbar-left .logo {
  font-family: var(--font-term);
  font-size: 24px;
  color: var(--red);
  text-shadow: 0 0 10px var(--red-glow);
  letter-spacing: 2px;
}

.cursor-blink {
  animation: blink 1s steps(1) infinite;
}

.topbar-nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 6px 14px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 1px;
  border: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--red);
  border-color: var(--border-red);
  background: var(--red-soft);
}

.nav-link.active {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-soft);
  text-shadow: 0 0 8px var(--red-glow);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

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

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  50% { opacity: 0.5; }
}

.status-text {
  color: var(--green);
  font-family: var(--font-mono);
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 8px;
  padding: 8px;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: var(--bg);
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--red-dim);
}

/* ===== Panels ===== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--red-dim);
  display: flex;
  flex-direction: column;
}

.panel.wide {
  flex: 1;
  min-height: 0;
}

.panel-header {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--red);
  letter-spacing: 1px;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-tag {
  font-size: 9px;
  color: var(--green-dim);
  border: 1px solid var(--green-dim);
  padding: 1px 5px;
  text-transform: uppercase;
}

.panel-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ===== Stat rows ===== */
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}

.stat-row span:first-child {
  color: var(--text-dim);
}

.stat-row .val {
  color: var(--text-bright);
}

/* ===== Threat bar ===== */
.threat-bar {
  height: 10px;
  background: #111;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 4px;
}

.threat-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  transition: width 0.5s;
  box-shadow: 0 0 8px currentColor;
}

.threat-label {
  text-align: center;
  font-size: 12px;
  color: var(--green);
  letter-spacing: 1px;
}

/* ===== Content area ===== */
.content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.view {
  display: none;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* ===== Cards grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-top: 2px solid var(--red-dim);
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  animation: scan 3s linear infinite;
}

@keyframes scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.card-header {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.yellow { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }

.card-value {
  font-family: var(--font-term);
  font-size: 36px;
  color: var(--red);
  text-shadow: 0 0 12px var(--red-glow);
  line-height: 1;
}

.card-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.sparkline {
  height: 24px;
  margin-top: 8px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.spark-bar {
  flex: 1;
  background: var(--red-dim);
  min-height: 2px;
  transition: height 0.3s;
  opacity: 0.6;
}

.spark-bar:last-child {
  opacity: 1;
  background: var(--red);
  box-shadow: 0 0 4px var(--red);
}

/* ===== Log ===== */
.log {
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.6;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.log.tall {
  min-height: 400px;
}

.log::-webkit-scrollbar {
  width: 4px;
}
.log::-webkit-scrollbar-track {
  background: var(--bg);
}
.log::-webkit-scrollbar-thumb {
  background: var(--red-dim);
}

.log-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.log-time {
  color: var(--text-dim);
  margin-right: 6px;
}

.log-tag {
  display: inline-block;
  padding: 0 4px;
  margin-right: 6px;
  font-size: 10px;
  border: 1px solid currentColor;
}

.log-info { color: var(--green-dim); }
.log-warn { color: var(--amber); }
.log-err { color: var(--red); }
.log-ok { color: var(--green); }

/* ===== Network grid ===== */
.net-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.net-node {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
  font-size: 10px;
  position: relative;
  transition: all 0.2s;
}

.net-node.online {
  border-color: var(--green-dim);
  color: var(--green);
}

.net-node.online::before {
  content: '●';
  margin-right: 4px;
  text-shadow: 0 0 4px var(--green);
}

.net-node.offline {
  border-color: var(--border);
  color: var(--text-dim);
  opacity: 0.5;
}

.net-node.alert {
  border-color: var(--red);
  color: var(--red);
  animation: alertPulse 1s infinite;
}

@keyframes alertPulse {
  50% { background: var(--red-soft); }
}

.net-node-ip {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ===== Vault ===== */
.vault-list {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vault-item {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--red-dim);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  transition: all 0.15s;
  cursor: pointer;
}

.vault-item:hover {
  border-left-color: var(--red);
  background: var(--red-soft);
}

.vault-name {
  color: var(--text-bright);
}

.vault-hash {
  color: var(--text-dim);
  font-size: 11px;
}

.vault-size {
  color: var(--amber);
  font-size: 11px;
}

/* ===== Console ===== */
.console-wrap {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 240px;
}

.console-out {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
}

.console-out::-webkit-scrollbar {
  width: 4px;
}
.console-out::-webkit-scrollbar-thumb {
  background: var(--red-dim);
}

.console-line {
  color: var(--text);
}

.console-line.cmd {
  color: var(--red);
}

.console-line.out {
  color: var(--green-dim);
}

.console-line.err {
  color: var(--red);
}

.console-in {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel-2);
}

.prompt {
  color: var(--red);
  margin-right: 6px;
  font-size: 12px;
  white-space: nowrap;
}

#consoleInput {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  flex: 1;
  caret-color: var(--red);
}

/* ===== Activity ===== */
.activity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}

.activity-item {
  padding: 2px 0;
  color: var(--text-dim);
  border-bottom: 1px dashed var(--border);
}

.activity-item .time {
  color: var(--red-dim);
  margin-right: 4px;
}

/* ===== Bottom bar ===== */
.bottombar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 28px;
  background: var(--bg-panel-2);
  border-top: 1px solid var(--border-red);
  font-size: 11px;
  color: var(--text-dim);
}

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

.blink {
  color: var(--red);
  animation: blink 1.5s steps(1) infinite;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    max-height: 200px;
  }
  .sidebar .panel {
    min-width: 200px;
  }
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .topbar-nav {
    display: none;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .boot {
    font-size: 14px;
    padding: 20px;
  }
}
