@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

/* AG Grid — base structural styles + Quartz theme */
@import "../node_modules/ag-grid-community/styles/ag-grid.css";
@import "../node_modules/ag-grid-community/styles/ag-theme-quartz.css";

/* Leaflet map */
@import "../node_modules/leaflet/dist/leaflet.css";

/* Case Key Journal — Drill-enabled columns (Jube parity: Case Workflow XPath) */
.ckj-drillable {
  cursor: pointer;
}
.ckj-drillable:hover {
  outline: 1px dashed #6366f1;
  outline-offset: -1px;
}

[x-cloak] { display: none !important; }

/* LiveView navigation — dim the outgoing page during a live redirect (e.g.
   clicking between the Model Config sub-page tabs, each its own LiveView)
   instead of the abrupt cut to blank/unstyled content while the new view
   mounts. LiveView adds .phx-loading directly to the main LiveView's root
   container (marked [data-phx-main]) for the duration; topbar (app.js)
   already shows the thin progress bar on the same page-loading event. */
[data-phx-main].phx-loading {
  opacity: 0.4;
  transition: opacity 200ms ease-in 100ms;
  pointer-events: none;
  cursor: wait;
}

.nav-item-active {
  background-color: rgba(99, 102, 241, 0.2);
  color: #fff;
}
.nav-item {
  transition: background-color 0.15s ease;
}
.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   FLOW BUILDER — canvas, nodes, palette, toolbar, panel
   ============================================================ */

/* ----- Toolbar ----- */
.flow-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.flow-toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s;
}
.flow-toolbar__btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.flow-toolbar__btn--primary {
  background: #4f46e5;
  border-color: #4338ca;
  color: #fff;
}
.flow-toolbar__btn--primary:hover {
  background: #4338ca;
  border-color: #3730a3;
}

/* ----- Canvas ----- */
.flow-canvas {
  position: relative;
  min-width: 2400px;
  min-height: 1600px;
  background-color: #f8fafc;
  background-image:
    linear-gradient(rgba(99,102,241,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: visible;
}

/* ----- Nodes (base) ----- */
.flow-node {
  position: absolute;
  min-width: 140px;
  max-width: 200px;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.15s, border-color 0.15s;
  z-index: 10;
}
.flow-node:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
}
.flow-node__header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px 5px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.flow-node__icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.flow-node__title {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-node__body {
  padding: 5px 10px 7px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* ----- Node type colours ----- */
.flow-node--request  { border-color: #3b82f6; background: #eff6ff; }
.flow-node--request  .flow-node__header { background: #3b82f6; }
.flow-node--request  .flow-node__icon,
.flow-node--request  .flow-node__title  { color: #fff; }

.flow-node--slot     { border-color: #8b5cf6; background: #f5f3ff; }
.flow-node--slot     .flow-node__header { background: #8b5cf6; }
.flow-node--slot     .flow-node__icon,
.flow-node--slot     .flow-node__title  { color: #fff; }

.flow-node--adapter  { border-color: #10b981; background: #ecfdf5; }
.flow-node--adapter  .flow-node__header { background: #10b981; }
.flow-node--adapter  .flow-node__icon,
.flow-node--adapter  .flow-node__title  { color: #fff; }

.flow-node--transform { border-color: #f97316; background: #fff7ed; }
.flow-node--transform .flow-node__header { background: #f97316; }
.flow-node--transform .flow-node__icon,
.flow-node--transform .flow-node__title  { color: #fff; }

.flow-node--merge    { border-color: #06b6d4; background: #ecfeff; }
.flow-node--merge    .flow-node__header { background: #06b6d4; }
.flow-node--merge    .flow-node__icon,
.flow-node--merge    .flow-node__title  { color: #fff; }

.flow-node--response { border-color: #6366f1; background: #eef2ff; }
.flow-node--response .flow-node__header { background: #6366f1; }
.flow-node--response .flow-node__icon,
.flow-node--response .flow-node__title  { color: #fff; }

.flow-node--decision { border-color: #f59e0b; background: #fffbeb; }
.flow-node--decision .flow-node__header { background: #f59e0b; }
.flow-node--decision .flow-node__icon,
.flow-node--decision .flow-node__title  { color: #fff; }

/* ----- Node state modifiers ----- */
.flow-node--selected {
  box-shadow: 0 0 0 3px rgba(99,102,241,0.45), 0 4px 16px rgba(0,0,0,0.14);
  border-color: #6366f1 !important;
}
.flow-node--error {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.45);
  border-color: #ef4444 !important;
}
.flow-node--active  { box-shadow: 0 0 0 3px rgba(251,191,36,0.6); }
.flow-node--ok      { box-shadow: 0 0 0 3px rgba(34,197,94,0.5); }
.flow-node--fallback { box-shadow: 0 0 0 3px rgba(249,115,22,0.5); }
.flow-node--failed  { box-shadow: 0 0 0 3px rgba(239,68,68,0.5); opacity: 0.75; }
.flow-node--skipped { opacity: 0.45; }

.flow-node__overlay-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

/* ----- Node Palette ----- */
.flow-palette {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flow-palette__item {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: grab;
  transition: background-color 0.12s, border-color 0.12s;
}
.flow-palette__item:hover {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #3730a3;
}
.flow-palette__item--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.flow-palette__item--disabled:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #475569;
}

/* ----- Property panel ----- */
.flow-property-panel {
  font-size: 13px;
}
.flow-property-panel__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 4px;
}

/* ----- Connection labels ----- */
.flow-conn-label {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
}
.flow-conn-label--fallback   { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.flow-conn-label--dependency { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.flow-conn-label--yes_branch { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flow-conn-label--no_branch  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* jsPlumb endpoint hover ring */
.jtk-endpoint:hover circle,
.jtk-endpoint:hover ellipse {
  stroke: #6366f1;
  stroke-width: 2;
}

/* =========================================================================
   Flow Audit Canvas — read-only replay overlay
   ========================================================================= */

.audit-canvas-inner {
  position: relative;
}

.audit-canvas-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  color: #94a3b8;
  font-style: italic;
}

/* Node card */
.audit-node {
  position: absolute;
  width: 140px;
  background: #fff;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  overflow: visible;
  user-select: none;
  transition: box-shadow 0.15s;
}

.audit-node--ok     { border-color: #86efac; box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }
.audit-node--error  { border-color: #fca5a5; box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }
.audit-node--skipped{ border-color: #e2e8f0; opacity: 0.55; }
.audit-node--unknown{ border-color: #e2e8f0; }

/* Header stripe */
.audit-node__header {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #fff;
  padding: 3px 8px;
  border-radius: 8px 8px 0 0;
}

/* Body */
.audit-node__body {
  padding: 6px 8px 4px;
}

.audit-node__name {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-node__id {
  font-size: 10px;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
  margin-top: 1px;
}

/* Status badge — top-right corner */
.audit-node__badge {
  position: absolute;
  top: -10px;
  right: -10px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 2px 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  white-space: nowrap;
  z-index: 10;
}

.audit-node--ok    .audit-node__badge { border-color: #86efac; }
.audit-node--error .audit-node__badge { border-color: #fca5a5; }

.audit-node__badge-icon {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.audit-node__badge-dur {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  font-family: ui-monospace, monospace;
}

/* Error reason strip */
.audit-node__reason {
  font-size: 10px;
  color: #dc2626;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
  padding: 3px 8px;
  border-radius: 0 0 8px 8px;
  word-break: break-word;
  max-height: 36px;
  overflow: hidden;
}
