/* ==========================================================================
   IAMSentry - Dark Cyberpunk & Executive Security Design System
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d121d;
  --bg-card: #121927;
  --bg-surface: #182235;
  --bg-code: #090d15;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(6, 182, 212, 0.4);
  --border-focus: #00f0ff;

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-purple: #8b5cf6;

  --color-critical: #ef4444;
  --color-critical-glow: rgba(239, 68, 68, 0.2);
  --color-high: #f59e0b;
  --color-high-glow: rgba(245, 158, 11, 0.2);
  --color-medium: #3b82f6;
  --color-safe: #10b981;
  --color-safe-glow: rgba(16, 185, 129, 0.2);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Background grid mesh */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* ==========================================================================
   Header & Nav
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 18, 29, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  display: block;
  margin-top: -2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.status-beacon {
  width: 8px;
  height: 8px;
  background-color: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-header-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-header-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--accent-cyan);
}

.btn-header-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #07090e;
  border: none;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 15px var(--accent-cyan-glow);
  transition: all 0.2s ease;
}

.btn-header-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   Presets Bar
   ========================================================================== */

.presets-container {
  padding: 0.85rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow-x: auto;
  position: relative;
  z-index: 10;
}

.presets-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.05em;
}

.preset-buttons-scroll {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.preset-buttons-scroll::-webkit-scrollbar {
  display: none;
}

.preset-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.preset-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: var(--bg-surface);
}

.preset-btn.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  color: #ffffff;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* Badges */
.preset-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.badge-critical {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-high {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-medium {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-safe {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ==========================================================================
   Main Workbench Layout
   ========================================================================== */

.workbench-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  flex: 1;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

@media (max-width: 1100px) {
  .workbench-container {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Left Panel: Policy Editor
   ========================================================================== */

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panel-header {
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.panel-title-icon {
  color: var(--accent-cyan);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-tool {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-tool:hover {
  color: #ffffff;
  border-color: var(--accent-cyan);
}

.syntax-error {
  display: none;
  background: rgba(239, 68, 68, 0.15);
  border-left: 4px solid var(--color-critical);
  padding: 0.75rem 1.25rem;
  color: #fca5a5;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 480px;
}

.code-textarea {
  width: 100%;
  flex: 1;
  background: var(--bg-code);
  border: none;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 1.25rem;
  resize: none;
  outline: none;
  line-height: 1.6;
  tab-size: 2;
}

.code-textarea::placeholder {
  color: var(--text-muted);
}

.editor-footer {
  padding: 0.5rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Right Panel: Intelligence & Analysis
   ========================================================================== */

/* Threat Gauge Header */
.threat-overview-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.score-dial-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.score-dial-card .label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.score-value {
  font-size: 2.8rem;
  font-weight: 900;
  font-family: var(--font-mono);
  line-height: 1.1;
  margin: 0.25rem 0;
}

.score-safe { color: var(--color-safe); }
.score-medium { color: var(--color-high); }
.score-high { color: #f97316; }
.score-critical { color: var(--color-critical); }

.score-max {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.threat-meta-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.blast-badge-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blast-badge {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  letter-spacing: 0.03em;
  display: inline-block;
}

.threat-counters-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.counter-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.6rem;
  text-align: center;
}

.counter-num {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

.counter-num.crit { color: var(--color-critical); }
.counter-num.high { color: var(--color-high); }
.counter-num.med { color: var(--color-medium); }

.counter-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Visual Attack Path Canvas
   ========================================================================== */

.attack-path-section {
  padding: 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.attack-path-canvas {
  width: 100%;
  height: 180px;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.pulsing-line {
  animation: dash 20s linear infinite;
}

@keyframes dash {
  to { stroke-dashoffset: -1000; }
}

/* ==========================================================================
   Findings List
   ========================================================================== */

.findings-section {
  padding: 1.25rem;
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}

.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.finding-card.severity-critical {
  border-left: 4px solid var(--color-critical);
}

.finding-card.severity-high {
  border-left: 4px solid var(--color-high);
}

.finding-card.severity-medium {
  border-left: 4px solid var(--color-medium);
}

.finding-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.finding-id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.finding-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  flex: 1;
}

.finding-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.finding-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.finding-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.finding-meta a {
  color: var(--accent-cyan);
  text-decoration: none;
}

.finding-meta a:hover {
  text-decoration: underline;
}

.finding-remediation {
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
}

.remediation-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-safe);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.finding-remediation p {
  font-size: 0.82rem;
  color: #a7f3d0;
  line-height: 1.4;
}

.clean-state {
  text-align: center;
  padding: 3rem 1.5rem;
}

.clean-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.clean-state h3 {
  font-size: 1.2rem;
  color: var(--color-safe);
  margin-bottom: 0.5rem;
}

.clean-state p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  max-width: 450px;
  margin: 0 auto;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 3rem 1.5rem;
}

/* ==========================================================================
   Remediation Studio (Bottom Section)
   ========================================================================== */

.remediation-studio {
  max-width: 1700px;
  margin: 0 auto 2rem;
  padding: 0 2rem;
  width: 100%;
}

.remediation-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.remediation-header {
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remediation-tabs {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--accent-cyan);
}

.code-diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-subtle);
  min-height: 280px;
}

@media (max-width: 900px) {
  .code-diff-container {
    grid-template-columns: 1fr;
  }
}

.code-output-block {
  background: var(--bg-code);
  padding: 1.25rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.active {
  display: flex;
}

.modal-window {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  width: 90%;
  max-width: 650px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  color: #ffffff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: #ffffff;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-code-box {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #38bdf8;
  white-space: pre-wrap;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}


/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.85rem 1.4rem;
  font-size: 0.85rem;
  color: #ffffff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 1000;
  animation: toastIn 0.25s ease-out;
}

.toast.show {
  display: block;
}

.toast-success {
  border-left: 4px solid var(--color-safe);
}

.toast-error {
  border-left: 4px solid var(--color-critical);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Print Styles for Executive PDF Export
   ========================================================================== */

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  body::before, .app-header, .presets-container, .panel-actions, .remediation-studio, .modal-backdrop {
    display: none !important;
  }

  .workbench-container {
    display: block !important;
    padding: 0 !important;
  }

  .panel {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .finding-card {
    border: 1px solid #cccccc !important;
    background: #f8fafc !important;
    color: #000000 !important;
    page-break-inside: avoid;
  }

  .finding-title {
    color: #000000 !important;
  }

  .finding-desc, .finding-meta {
    color: #333333 !important;
  }
}
