/* AASE - Adversarial Attack Simulation Exercises
   Dark theme — RedKit-aligned palette */

:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2128;
  --border: #30363d;
  --border-strong: #3d444d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-mute: #6e7681;
  --accent: #ff4444;
  --accent-hover: #ff6666;
  --accent-dim: rgba(255,68,68,.12);
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --info: #58a6ff;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: .15s ease;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --glass: rgba(22,27,34,.88);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- LOGIN (RedKit-style gate) ---- */
#login-screen {
  position: fixed; inset: 0;
  z-index: 2147483000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  font-family: var(--font-sans);
  transition: opacity .35s ease;
}
#login-screen.hidden { opacity: 0; pointer-events: none; }

.login-box {
  width: min(92vw, 360px);
  padding: 32px 28px;
  background: var(--bg-elev);
  border: 1px solid #23272e;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  text-align: center;
}
.login-box .logo {
  font: 600 22px/1 var(--font-mono);
  color: var(--text);
  margin-bottom: 6px;
}
.login-box .logo .accent { color: var(--accent); }
.login-box .logo .muted { color: var(--text-mute); }
.login-box .subtitle {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 13px;
}
.login-input-row { position: relative; display: flex; }
.login-box input {
  flex: 1; width: 100%;
  padding: 12px 42px 12px 14px;
  font-size: 15px; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.login-box input:focus { border-color: var(--accent); }
.login-box input::placeholder { color: #484f58; }
.login-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: none;
  color: var(--text-mute); cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.login-box button.login-go {
  margin-top: 14px; width: 100%; padding: 12px;
  font-size: 14px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 9px;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.login-box button.login-go:hover { background: var(--accent-hover); }
.login-box button.login-go:disabled { opacity: .6; cursor: default; }
.login-error {
  min-height: 16px; margin-top: 12px;
  color: #ff6b6b; font-size: 12.5px; visibility: hidden;
}
.login-error.visible { visibility: visible; }
#login-screen.err .login-box { animation: gateShake .3s; }
@keyframes gateShake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-7px); }
  75%     { transform: translateX(7px); }
}

/* ---- APP SHELL ---- */
#app { display: none; height: 100vh; flex-direction: column; }
#app.active { display: flex; }

/* Top Bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 48px; min-height: 48px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.topbar .brand {
  font: 600 15px/1 var(--font-mono);
  color: var(--text);
  flex-shrink: 0;
  letter-spacing: -0.3px;
}
.topbar .brand .a { color: var(--accent); }
.topbar .separator { width: 1px; height: 20px; background: var(--border); }
.topbar .project-name {
  font-size: 13px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .spacer { flex: 1; }

.topbar-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 7px;
  font: 12px var(--font-sans); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.topbar-btn:hover {
  background: var(--bg-elev2); color: var(--text);
  border-color: var(--border-strong);
}
.topbar-btn.active {
  background: var(--accent-dim); color: var(--accent);
  border-color: var(--accent);
}
.topbar-btn svg { width: 14px; height: 14px; }

select.topbar-select {
  padding: 5px 26px 5px 10px;
  background: var(--bg); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 7px;
  font: 12px var(--font-sans); cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236e7681'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
select.topbar-select:hover { border-color: var(--border-strong); }

/* Main Area */
.main-area { flex: 1; display: flex; position: relative; overflow: hidden; }

/* Graph Canvas */
#cy {
  flex: 1;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.025) 1px, transparent 0);
  background-size: 28px 28px;
}

/* Glass panels (shared) */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}

/* Legend */
.legend {
  position: absolute; bottom: 20px; left: 16px;
  padding: 14px 16px;
  z-index: 50;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.legend::-webkit-scrollbar { width: 3px; }
.legend::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.legend h4 {
  font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-mute);
  margin-bottom: 8px;
}
.legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0; font-size: 12px; color: var(--text-dim);
  cursor: pointer; transition: color var(--transition);
}
.legend-item:hover { color: var(--text); }
.legend-item.dimmed { opacity: .25; }
.legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.legend-line {
  width: 18px; height: 2px; flex-shrink: 0; border-radius: 1px;
}
.legend-section { margin-top: 10px; }

/* Stats Bar */
.stats-bar {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 0;
  overflow: hidden; z-index: 50;
}
.stat-item {
  padding: 10px 22px; text-align: center;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-value {
  font-size: 20px; font-weight: 700;
  font-family: var(--font-mono);
}
.stat-value.danger { color: var(--danger); }
.stat-value.warning { color: var(--warning); }
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-label {
  font-size: 9px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text-mute);
  margin-top: 2px;
}

/* Phase Timeline */
.phase-bar {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 0;
  overflow: hidden; z-index: 50;
}
.phase-item {
  padding: 9px 16px; font-size: 11px;
  color: var(--text-mute); cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all var(--transition); white-space: nowrap;
}
.phase-item:last-child { border-right: none; }
.phase-item:hover { background: rgba(255,255,255,.04); color: var(--text-dim); }
.phase-item.active {
  background: var(--accent-dim); color: var(--accent); font-weight: 600;
}
.phase-num {
  font-weight: 700; font-family: var(--font-mono);
  margin-right: 5px; opacity: .5;
}

/* Detail Panel */
.detail-panel {
  position: absolute; top: 0; right: -420px;
  width: 420px; height: 100%;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  z-index: 80;
  transition: right .3s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.detail-panel.open { right: 0; }

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.detail-header h3 {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.detail-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-mute); cursor: pointer; font-size: 16px;
  transition: all var(--transition);
}
.detail-close:hover { background: var(--bg-elev2); color: var(--text); }

.detail-body {
  flex: 1; overflow-y: auto; padding: 18px;
}
.detail-body::-webkit-scrollbar { width: 4px; }
.detail-body::-webkit-scrollbar-track { background: transparent; }
.detail-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.detail-section { margin-bottom: 18px; }
.detail-section-title {
  font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-mute);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.detail-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-mute); flex-shrink: 0; margin-right: 12px; }
.detail-val {
  color: var(--text); font-family: var(--font-mono);
  font-size: 12px; text-align: right; word-break: break-word;
}

.detail-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .5px;
}
.detail-badge.critical { background: rgba(248,81,73,.12); color: var(--danger); }
.detail-badge.high { background: rgba(210,153,34,.12); color: var(--warning); }
.detail-badge.medium { background: rgba(88,166,255,.12); color: var(--info); }
.detail-badge.low { background: rgba(63,185,80,.12); color: var(--success); }

.detail-description {
  font-size: 13px; line-height: 1.65; color: var(--text-dim);
}

.detail-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.detail-tag {
  padding: 3px 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; font-size: 11px;
  font-family: var(--font-mono); color: var(--text-dim);
}

.node-type-indicator {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 10px 18px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text);
  font-size: 13px; z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(8px);
  transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Watermark */
.watermark {
  position: absolute; bottom: 20px; right: 20px;
  font-size: 10px; letter-spacing: 2px;
  color: rgba(255,255,255,.06);
  z-index: 10; pointer-events: none; user-select: none;
}

/* Responsive */
@media (max-width: 768px) {
  .detail-panel { width: 100%; right: -100%; }
  .stats-bar { flex-wrap: wrap; width: 92%; }
  .stat-item { padding: 8px 12px; }
  .stat-value { font-size: 16px; }
  .legend { bottom: auto; top: 60px; left: 10px; max-width: 150px; }
  .phase-bar { display: none; }
}
