/* ==========================================================================
   AutoGuard AI — SecOps Git-Diff, Fluid Card Animations & Cascades
   Architecture: High-Density Autonomous Agent Operations Console
   Colors: Red-Team Crimson (#FF3366), Defense Mint (#00E5A3), Mutation Amber (#FFB800)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&family=Space+Grotesk:wght@300..700&display=swap');

:root {
  --red-team: #ff3366;
  --red-team-subtle: rgba(255, 51, 102, 0.12);
  --red-team-border: rgba(255, 51, 102, 0.35);
  
  --defense-mint: #00e5a3;
  --defense-mint-subtle: rgba(0, 229, 163, 0.12);
  --defense-mint-border: rgba(0, 229, 163, 0.35);

  --agent-amber: #ffb800;
  --agent-amber-subtle: rgba(255, 184, 0, 0.12);
  --agent-amber-border: rgba(255, 184, 0, 0.35);

  --signal-cyan: #00f0ff;
  --signal-cyan-subtle: rgba(0, 240, 255, 0.1);

  --bg-canvas: #080b11;
  --bg-substrate: #0e131d;
  --bg-panel: #131a28;
  --bg-input: #0a0e17;

  --border-dim: #1e293b;
  --border-highlight: #334155;

  --text-pure: #f8fafc;
  --text-high: #cbd5e1;
  --text-mid: #94a3b8;
  --text-low: #475569;

  --glow-crimson: 0 0 25px rgba(255, 51, 102, 0.25);
  --glow-mint: 0 0 25px rgba(0, 229, 163, 0.25);
  --glow-cyan: 0 0 25px rgba(0, 240, 255, 0.25);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-pure);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 12%, rgba(66, 133, 244, 0.08) 0%, transparent 45%),  /* Google Blue */
    radial-gradient(circle at 90% 12%, rgba(234, 67, 53, 0.08) 0%, transparent 45%),   /* Google Red */
    radial-gradient(circle at 80% 88%, rgba(251, 188, 5, 0.06) 0%, transparent 50%),   /* Google Yellow */
    radial-gradient(circle at 20% 88%, rgba(52, 168, 83, 0.07) 0%, transparent 50%);   /* Google Green */
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.font-display { font-family: 'Space Grotesk', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ================= CONSOLE PANELS ================= */
.console-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-dim);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.console-panel:hover {
  border-color: var(--border-highlight);
}

.console-header-strip {
  background: var(--bg-substrate);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ================= MASTER LAUNCH BUTTON ================= */
.btn-taskmaster-execute {
  background: linear-gradient(135deg, #4285f4 0%, #34a853 50%, #00e5a3 100%);
  color: #ffffff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  border-radius: 10px;
  padding: 0.6rem 1.35rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 4px 18px rgba(66, 133, 244, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-taskmaster-execute:hover:not(:disabled) {
  transform: translateY(-1.5px);
  box-shadow: 0 6px 25px rgba(66, 133, 244, 0.55);
}

.btn-taskmaster-execute:active:not(:disabled) {
  transform: translateY(0);
}

.btn-taskmaster-execute:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

/* ================= DAG 6-STAGE PIPELINE WITH GOOGLE 4-COLOR ACCENTS ================= */
.dag-pipeline-container {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  position: relative;
}

@media (max-width: 1024px) {
  .dag-pipeline-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .dag-pipeline-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

.dag-stage-node {
  background: var(--bg-substrate);
  border: 1.5px solid var(--border-dim);
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.dag-stage-node:hover {
  border-color: #4285f4;
  transform: translateY(-2px);
  background: #111724;
}

/* Stage Node Specific Google Color Accents */
#node_dag_01_plan { border-top: 2px solid rgba(66, 133, 244, 0.4); }
#node_dag_02_red_team { border-top: 2px solid rgba(234, 67, 53, 0.4); }
#node_dag_03_baseline_eval { border-top: 2px solid rgba(251, 188, 5, 0.4); }
#node_dag_04_critic { border-top: 2px solid rgba(66, 133, 244, 0.4); }
#node_dag_05_self_heal { border-top: 2px solid rgba(52, 168, 83, 0.4); }
#node_dag_06_cloud_deploy { border-top: 2px solid rgba(0, 229, 163, 0.4); }

.dag-stage-node.PENDING {
  opacity: 0.7;
}

.dag-stage-node.RUNNING {
  border-color: #4285f4;
  background: rgba(66, 133, 244, 0.08);
  box-shadow: 0 0 20px rgba(66, 133, 244, 0.25);
}

/* Active Moving Google 4-Color Laser Sweep Bar inside the card */
.dag-stage-node.RUNNING::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: linear-gradient(90deg, #4285f4, #ea4335, #fbbc05, #34a853);
  animation: laserSweep 1.2s infinite linear;
}

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

.dag-stage-node.COMPLETED {
  border-color: #34a853;
  background: rgba(52, 168, 83, 0.08);
}

.dag-stage-node.COMPLETED::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: linear-gradient(90deg, #4285f4, #34a853);
}

.dag-stage-node.FAILED {
  border-color: #ea4335;
  background: rgba(234, 67, 53, 0.08);
}

/* ================= REAL GIT-STYLE PROMPT DIFF VIEWER ================= */
.git-diff-container {
  background: #06090e;
  border: 1px solid #1e293b;
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  line-height: 1.65;
}

.diff-header-bar {
  background: #0e131d;
  border-bottom: 1px solid #1e293b;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}

.diff-line {
  display: flex;
  align-items: flex-start;
  padding: 0.15rem 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-line-num {
  width: 32px;
  color: #475569;
  user-select: none;
  text-align: right;
  padding-right: 12px;
  flex-shrink: 0;
  font-size: 0.72rem;
}

.diff-line-content {
  flex: 1;
}

.diff-line.deletion {
  background: rgba(255, 51, 102, 0.15);
  color: #fecdd3;
  text-decoration: line-through;
  text-decoration-color: rgba(255, 51, 102, 0.6);
}

.diff-line.deletion .diff-line-num {
  color: #ff3366;
}

.diff-line.addition {
  background: rgba(0, 229, 163, 0.14);
  color: #a7f3d0;
  font-weight: 500;
}

.diff-line.addition .diff-line-num {
  color: #00e5a3;
}

.diff-line.unchanged {
  color: #94a3b8;
}

.diff-line.section-header {
  background: #0e131d;
  color: #00f0ff;
  font-weight: 700;
  border-top: 1px solid #1e293b;
  border-bottom: 1px solid #1e293b;
  padding: 0.35rem 0.75rem;
}

/* ================= LIVE DUEL ARENA WITH CONFIDENCE METERS ================= */
.duel-arena-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .duel-arena-grid {
    grid-template-columns: 1fr;
  }
}

.duel-box-attacker {
  background: linear-gradient(180deg, rgba(255, 51, 102, 0.08) 0%, rgba(255, 51, 102, 0.02) 100%);
  border: 1.5px solid var(--red-team-border);
  border-radius: 14px;
  padding: 1.15rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #fecdd3;
  line-height: 1.6;
}

.duel-box-defender {
  background: linear-gradient(180deg, rgba(0, 229, 163, 0.08) 0%, rgba(0, 229, 163, 0.02) 100%);
  border: 1.5px solid var(--defense-mint-border);
  border-radius: 14px;
  padding: 1.15rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #a7f3d0;
  line-height: 1.6;
}

.confidence-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.confidence-bar-fill-red {
  height: 100%;
  background: var(--red-team);
  border-radius: 9999px;
  transition: width 0.6s ease;
}

.confidence-bar-fill-mint {
  height: 100%;
  background: var(--defense-mint);
  border-radius: 9999px;
  transition: width 0.6s ease;
}

/* Attack Injection Chips */
.attack-chip-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: #131a28;
  border: 1px solid var(--border-dim);
  color: var(--text-mid);
  cursor: pointer;
  transition: all 0.2s ease;
}

.attack-chip-btn:hover {
  background: #1e293b;
  color: var(--text-pure);
  border-color: var(--border-highlight);
}

.attack-chip-btn.active {
  background: rgba(255, 51, 102, 0.15);
  color: #ff3366;
  border-color: #ff3366;
  box-shadow: 0 0 12px rgba(255, 51, 102, 0.3);
}

/* ================= STAT SCORECARD ================= */
.stat-kpi-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .stat-kpi-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-kpi-card {
  background: var(--bg-substrate);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ================= SYNTAX TELEMETRY TERMINAL ================= */
.secops-terminal {
  background: #05070c;
  border: 1px solid #161f30;
  border-radius: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  height: 100%;
  min-height: 280px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  line-height: 1.65;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.8);
  flex: 1;
}

.secops-terminal::-webkit-scrollbar {
  width: 6px;
}
.secops-terminal::-webkit-scrollbar-track {
  background: #090d16;
  border-radius: 4px;
}
.secops-terminal::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
.secops-terminal::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

.terminal-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--signal-cyan);
  vertical-align: middle;
  margin-left: 4px;
  animation: blink 1s infinite;
}

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

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}
.log-time { color: var(--text-low); font-size: 0.72rem; flex-shrink: 0; }
.log-entry.info { color: #38bdf8; }
.log-entry.success { color: #00e5a3; }
.log-entry.warning { color: #ffb800; }
.log-entry.error { color: #ff3366; }

/* ================= BADGES & PILLS ================= */
.secops-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
}

.badge-crimson {
  background: var(--red-team-subtle);
  color: var(--red-team);
  border: 1px solid var(--red-team-border);
}

.badge-mint {
  background: var(--defense-mint-subtle);
  color: var(--defense-mint);
  border: 1px solid var(--defense-mint-border);
}

.badge-amber {
  background: var(--agent-amber-subtle);
  color: var(--agent-amber);
  border: 1px solid var(--agent-amber-border);
}

.badge-cyan {
  background: var(--signal-cyan-subtle);
  color: var(--signal-cyan);
  border: 1px solid rgba(0, 240, 255, 0.35);
}

/* Tab Bar */
.secops-tab-bar {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-substrate);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border-dim);
  overflow-x: auto;
}

.secops-tab-btn {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid transparent;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.secops-tab-btn:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.04);
}

.secops-tab-btn.active {
  background: #1e293b;
  color: var(--signal-cyan);
  border-color: rgba(0, 240, 255, 0.3);
  font-weight: 700;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 8, 0.82);
  backdrop-filter: blur(10px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  background: var(--bg-substrate);
  border: 1px solid var(--border-dim);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 240, 255, 0.15);
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Toast */
#toastContainer {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  background: var(--bg-substrate);
  color: var(--text-pure);
  border: 1px solid var(--border-dim);
  padding: 0.75rem 1.15rem;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
  transform: translateX(120%);
  animation: slideIn 0.3s forwards cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

@keyframes slideIn { to { transform: translateX(0); } }
