@import "@turbostarter/ui/globals.css";
@import "@turbostarter/ui-web/globals.css";

@source "../../../../../packages/ui";

@layer base {
  @import "@xyflow/react/dist/style.css";

  :root {
    /* Canvas */
    --canvas-bg: oklch(0.985 0.002 247);
    --canvas-grid: oklch(0.92 0.004 286 / 30%);
    /* Nodes */
    --node-bg: oklch(1 0 0);
    --node-border: oklch(0.85 0.01 260);
    --node-selected: oklch(0.623 0.214 260);
    --node-hover: oklch(0.623 0.214 260 / 12%);
    /* Edges */
    --edge-default: oklch(0.65 0.01 286);
    --edge-selected: oklch(0.623 0.214 260);
    /* AI (placeholders for future epics) */
    --ai-accent: oklch(0.623 0.214 260);
    /* Diagram type accents */
    --diagram-bpmn: oklch(0.623 0.214 260);
    --diagram-er: oklch(0.606 0.25 293);
    --diagram-orgchart: oklch(0.723 0.219 150);
    --diagram-architecture: oklch(0.552 0.016 286);
    --diagram-sequence: oklch(0.795 0.184 86);
    --diagram-flowchart: oklch(0.645 0.246 16);
    /* BPMN element-specific colors */
    --bpmn-start-event: #2ecc71;
    --bpmn-end-event: #e74c3c;
    --bpmn-timer-event: #3498db;
    --bpmn-message-event: #f39c12;
    --bpmn-gateway: #3498db;
    --bpmn-data-object: #f39c12;
  }

  .dark {
    --canvas-bg: oklch(0.16 0.005 285);
    --canvas-grid: oklch(0.92 0.004 286 / 15%);
    --node-bg: oklch(0.24 0.006 286);
    --node-border: oklch(0.35 0.01 260);
    --node-selected: oklch(0.623 0.214 260);
    --node-hover: oklch(0.623 0.214 260 / 12%);
    --edge-default: oklch(0.55 0.01 286);
    --edge-selected: oklch(0.623 0.214 260);
    --bpmn-start-event: #27ae60;
    --bpmn-end-event: #c0392b;
    --bpmn-timer-event: #5dade2;
    --bpmn-message-event: #f5b041;
    --bpmn-gateway: #5dade2;
    --bpmn-data-object: #f5b041;
  }

  /* ELK layout animation — only active during auto-layout transitions */
  .react-flow__node.layouting {
    transition: transform 200ms ease-out;
  }

  /* ── BPMN Node Styles ─────────────────────────────────────────────────── */

  .bpmn-activity {
    background: var(--node-bg);
    border: 1.5px solid var(--diagram-bpmn);
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 200px;
    max-width: 280px;
    font-size: 12px;
    cursor: pointer;
  }

  .bpmn-activity-tag {
    font-weight: 600;
    font-size: 11px;
    color: var(--diagram-bpmn);
    margin-bottom: 4px;
  }

  .bpmn-activity-label {
    color: var(--foreground);
    line-height: 1.4;
  }

  .bpmn-subprocess {
    background: var(--node-bg);
    border: 1.5px solid var(--diagram-bpmn);
    border-radius: 8px;
    padding: 8px 12px 20px;
    min-width: 200px;
    max-width: 280px;
    font-size: 12px;
    position: relative;
    cursor: pointer;
  }

  .bpmn-subprocess-marker {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--diagram-bpmn);
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--diagram-bpmn);
    line-height: 1;
  }

  .bpmn-event-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
  }

  .bpmn-event-label {
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted-foreground);
    text-align: center;
    max-width: 140px;
    word-wrap: break-word;
    line-height: 1.3;
  }

  .bpmn-gateway-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
  }

  .bpmn-data-object-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
  }

  .bpmn-annotation {
    border-left: 2px solid var(--muted-foreground);
    padding: 6px 10px;
    font-size: 11px;
    color: var(--muted-foreground);
    max-width: 220px;
    cursor: pointer;
  }

  .bpmn-annotation-text {
    line-height: 1.4;
  }

  /* ── BPMN Pool & Lane Styles ──────────────────────────────────────────── */

  .bpmn-pool {
    border: 2px solid var(--node-border);
    border-radius: 4px;
    background: transparent;
    pointer-events: none;
    position: relative;
  }

  .bpmn-pool-label {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 32px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-weight: 600;
    font-size: 12px;
    color: var(--foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--node-border);
    pointer-events: auto;
  }

  .bpmn-lane {
    border-top: 1px solid var(--node-border);
    background: transparent;
    pointer-events: none;
    position: relative;
  }

  .bpmn-lane-label {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 11px;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px dashed var(--node-border);
    pointer-events: auto;
  }

  /* ── BPMN Group Styles ───────────────────────────────────────────────── */

  .bpmn-group {
    border: 2px dashed var(--node-border);
    border-radius: 8px;
    background: transparent;
    pointer-events: none;
    position: relative;
  }

  .bpmn-group-label {
    position: absolute;
    top: -10px;
    left: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-foreground);
    background: var(--canvas-bg);
    padding: 0 6px;
    pointer-events: auto;
  }

  /* ── Path Highlighting ────────────────────────────────────────────────── */

  .react-flow__node.dimmed,
  .react-flow__edge.dimmed {
    opacity: 0.2;
    transition: opacity 200ms ease-out;
  }

  .react-flow__node.highlighted {
    filter: drop-shadow(0 0 6px var(--diagram-bpmn));
    transition: filter 200ms ease-out;
  }
}
