/* =============================================
   SOP Viewer — Custom Styles
   Tailwind handles utilities; this file handles
   animations, complex components, and tokens.
   ============================================= */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --color-navy-950: #020b1a;
  --color-navy-900: #041229;
  --color-slate-bg: #020617;

  --node-glow-pass: 0 0 20px rgba(16, 185, 129, 0.15);
  --node-glow-fail: 0 0 20px rgba(239, 68, 68, 0.15);
  --node-glow-active: 0 0 20px rgba(59, 130, 246, 0.2);
}

* {
  font-family: var(--font-sans);
  box-sizing: border-box;
}

code, .font-mono, [class*="font-mono"] {
  font-family: var(--font-mono);
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ============ TRANSITIONS ============ */
.fade-in {
  animation: fadeInUp 0.35s ease-out both;
}

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

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
  50%       { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15); }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

@keyframes connectorDraw {
  from { height: 0; opacity: 0; }
  to   { height: 100%; opacity: 1; }
}

@keyframes nodePop {
  0%   { transform: scale(0.96); opacity: 0; }
  60%  { transform: scale(1.01); }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ FLOWCHART LAYOUT ============ */
.flowchart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-bottom: 2rem;
}

.flowchart-node-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 680px;
}

/* ============ CONNECTOR ============ */
.connector-line-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  padding: 0 0 0 0;
}

.connector-line {
  width: 2px;
  min-height: 40px;
  background: linear-gradient(to bottom, #334155, #475569);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.connector-line.connector-pass {
  background: linear-gradient(to bottom, #059669, #10b981);
}

.connector-line.connector-fail {
  background: linear-gradient(to bottom, #dc2626, #ef4444);
}

.connector-arrow {
  position: absolute;
  bottom: -4px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #475569;
}

.connector-line.connector-pass .connector-arrow { border-top-color: #10b981; }
.connector-line.connector-fail .connector-arrow { border-top-color: #ef4444; }

.connector-label {
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #64748b;
  white-space: nowrap;
  background: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #1e293b;
}

/* ============ FLOW NODES ============ */
.flow-node {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #1e293b;
  background: linear-gradient(135deg, #0f172a 0%, #0a1628 100%);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: nodePop 0.4s ease-out both;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  overflow: hidden;
}

.flow-node::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,130,167,0.3), transparent);
}

.flow-node:hover {
  transform: translateY(-1px);
  border-color: #334155;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.flow-node:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Node type variants */
.flow-node.node-start {
  border-color: #1d4ed8;
  background: linear-gradient(135deg, #0f1e3d 0%, #0a1228 100%);
}

.flow-node.node-end {
  border-color: #1e293b;
  background: linear-gradient(135deg, #0f172a 0%, #0a0f1e 100%);
}

.flow-node.node-check {
  border-left: 3px solid #334155;
}

.flow-node.node-check.status-pass {
  border-left-color: #10b981;
  border-color: #064e3b;
  background: linear-gradient(135deg, #042f1f 0%, #0a1628 100%);
  box-shadow: var(--node-glow-pass);
}

.flow-node.node-check.status-fail {
  border-left-color: #ef4444;
  border-color: #7f1d1d;
  background: linear-gradient(135deg, #2d0a0a 0%, #0a1628 100%);
  box-shadow: var(--node-glow-fail);
}

.flow-node.node-escalate {
  border-color: #7f1d1d;
  background: linear-gradient(135deg, #1f0808 0%, #0a1628 100%);
  box-shadow: var(--node-glow-fail);
  animation: pulseGlow 3s ease-in-out infinite, nodePop 0.4s ease-out both;
}

.flow-node.node-action {
  border-color: #1e3a5f;
  background: linear-gradient(135deg, #0a1f38 0%, #0a1628 100%);
}

.flow-node.node-decision {
  border-color: #44337a;
  background: linear-gradient(135deg, #150e2a 0%, #0a1628 100%);
  border-radius: 14px;
}

/* ============ NODE ICON BADGE ============ */
.node-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.badge-start  { background: rgba(37, 99, 235, 0.2); color: #60a5fa; border: 1px solid rgba(37,99,235,0.3); }
.badge-check  { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.2); }
.badge-check-pass { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.badge-check-fail { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.badge-decision { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.badge-action { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-escalate { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.badge-end    { background: rgba(100, 116, 139, 0.1); color: #64748b; border: 1px solid rgba(100,116,139,0.2); }

/* ============ NODE CONTENT ============ */
.node-content { flex: 1; min-width: 0; }

.node-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.node-type-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #475569;
  font-family: var(--font-mono);
}

.node-id {
  font-size: 10px;
  color: #334155;
  font-family: var(--font-mono);
}

.node-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.node-description {
  font-size: 0.8125rem;
  color: #64748b;
  line-height: 1.5;
}

.node-status-dot {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #334155;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.dot-pass  { background: #10b981 !important; box-shadow: 0 0 8px rgba(16,185,129,0.6); }
.dot-fail  { background: #ef4444 !important; box-shadow: 0 0 8px rgba(239,68,68,0.6); }
.dot-pending { background: #334155 !important; }

/* ============ STATUS BUTTONS ============ */
.node-status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.875rem;
  flex-wrap: wrap;
}

.node-status-buttons { display: flex; gap: 0.5rem; }

.status-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 32px;
}

.status-btn-pass {
  border-color: #1e3a2a;
  background: transparent;
  color: #4b7a5f;
}
.status-btn-pass:hover {
  border-color: #10b981;
  background: rgba(16,185,129,0.1);
  color: #34d399;
}
.status-btn-pass-active {
  border-color: #10b981;
  background: rgba(16,185,129,0.15);
  color: #34d399;
  box-shadow: 0 0 12px rgba(16,185,129,0.2);
}

.status-btn-fail {
  border-color: #3a1e1e;
  background: transparent;
  color: #7a4b4b;
}
.status-btn-fail:hover {
  border-color: #ef4444;
  background: rgba(239,68,68,0.1);
  color: #f87171;
}
.status-btn-fail-active {
  border-color: #ef4444;
  background: rgba(239,68,68,0.15);
  color: #f87171;
  box-shadow: 0 0 12px rgba(239,68,68,0.2);
}

.node-status-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 4px;
}

.badge-pass { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.25); }
.badge-fail { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }

/* ============ ESCALATE BUTTON ============ */
.escalate-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.625rem 1.125rem;
  border-radius: 8px;
  border: 1px solid #dc2626;
  background: rgba(239,68,68,0.12);
  color: #f87171;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  animation: pulseGlow 2.5s ease-in-out infinite;
}

.escalate-btn:hover {
  background: rgba(239,68,68,0.22);
  box-shadow: 0 0 20px rgba(239,68,68,0.25);
}

.escalate-btn-triggered {
  border-color: #16a34a;
  background: rgba(22,163,74,0.12);
  color: #4ade80;
  animation: none;
}

.escalate-btn-sm {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid #dc2626;
  background: rgba(239,68,68,0.12);
  color: #f87171;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
  white-space: nowrap;
}

.escalate-btn-sm:hover {
  background: rgba(239,68,68,0.22);
}

.escalate-btn-sm-triggered {
  border-color: #16a34a;
  background: rgba(22,163,74,0.12);
  color: #4ade80;
}

/* ============ DECISION BRANCHES ============ */
.decision-branches {
  display: none;
}

/* ============ PROGRESS BAR ============ */
.progress-bar-fill {
  background: linear-gradient(90deg, #2563eb, #10b981);
}

/* ============ SUMMARY BAR ============ */
.summary-bar {
  border: 1px solid #1e293b;
  background: linear-gradient(135deg, #0f172a, #0a1628);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.summary-grid {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.summary-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
}

.summary-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.summary-divider {
  width: 1px;
  height: 40px;
  background: #1e293b;
}

.save-session-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.625rem 1.125rem;
  border-radius: 8px;
  border: 1px solid #1d4ed8;
  background: rgba(37, 99, 235, 0.12);
  color: #60a5fa;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.save-session-btn:hover {
  background: rgba(37, 99, 235, 0.22);
  box-shadow: 0 0 16px rgba(37,99,235,0.2);
}

/* ============ CHECKLIST ============ */
.checklist-item {
  display: flex;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  border-radius: 12px;
  border: 1px solid #1e293b;
  background: #0f172a;
  transition: all 0.25s ease;
  animation: fadeInUp 0.3s ease-out both;
}

.checklist-pass {
  border-color: #064e3b;
  background: linear-gradient(135deg, #031f13, #0f172a);
  box-shadow: var(--node-glow-pass);
}

.checklist-fail {
  border-color: #7f1d1d;
  background: linear-gradient(135deg, #1f0808, #0f172a);
  box-shadow: var(--node-glow-fail);
}

.checklist-pending {
  border-color: #1e293b;
}

.checklist-number {
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: var(--font-mono);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.num-pending { background: #1e293b; color: #475569; }
.num-pass    { background: rgba(16,185,129,0.15); color: #34d399; }
.num-fail    { background: rgba(239,68,68,0.15); color: #f87171; }

.checklist-body { flex: 1; min-width: 0; }

.checklist-substeps {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.escalation-banner {
  border: 1px solid #7f1d1d;
  background: linear-gradient(135deg, #1f0808, #0f172a);
  border-radius: 12px;
  padding: 1.25rem;
  animation: fadeInUp 0.3s ease-out both;
}

/* ============ TEMPLATES ============ */
.template-card {
  border: 1px solid #1e293b;
  background: linear-gradient(135deg, #0f172a, #0a1628);
  border-radius: 14px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: fadeInUp 0.35s ease-out both;
}

.template-card:hover {
  border-color: #334155;
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.template-card:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.template-card-active {
  border-color: #1d4ed8 !important;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.template-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.template-icon-blue   { background: rgba(37,99,235,0.15); color: #60a5fa; border: 1px solid rgba(37,99,235,0.25); }
.template-icon-emerald { background: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.25); }
.template-icon-violet { background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.25); }
.template-icon-amber  { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }

.saved-session-card {
  border: 1px solid #1e293b;
  background: #0f172a;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  animation: fadeInUp 0.3s ease-out both;
}

/* ============ TOAST ============ */
.toast-notification {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1.125rem;
  border-radius: 10px;
  border: 1px solid;
  min-width: 240px;
  max-width: 360px;
  pointer-events: all;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}

.toast-success { background: rgba(4, 47, 31, 0.95); border-color: #065f46; color: #34d399; }
.toast-error   { background: rgba(47, 4, 4, 0.95);  border-color: #7f1d1d; color: #f87171; }
.toast-info    { background: rgba(4, 18, 47, 0.95);  border-color: #1e3a8a; color: #60a5fa; }

.toast-enter { animation: slideIn 0.3s ease-out both; }
.toast-leave { animation: slideOut 0.3s ease-in both; }
