/* ═══════════════════════════════════════════════════════════════════
   FLOW DIAGRAMS — Swimlane / Sequence Diagram Styles
   Used by: /developers/flows/*
   ═══════════════════════════════════════════════════════════════════ */

/* --- Diagram Wrapper (horizontal scroll on mobile) --- */
.flow-diagram {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  position: relative;
}

.flow-diagram-inner {
  display: flex;
  flex-direction: column;
  min-width: 900px;
  gap: 0;
  padding-left: 12px;
  padding-top: 4px;
}

/* 7-column variant for API Checkout & AI Agent */
.flow-diagram-inner.flow-cols-7 {
  min-width: 1050px;
}

/* --- Actor Column Headers --- */
.flow-actors {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 2px solid #dee2e6;
  padding: 0.75rem 0;
  margin-bottom: 0.5rem;
}

.flow-actors-6 { grid-template-columns: repeat(6, 1fr); }
.flow-actors-7 { grid-template-columns: repeat(7, 1fr); }

.flow-actor {
  text-align: center;
  padding: 0.5rem 0.25rem;
}

.flow-actor-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.4rem;
  font-size: 1.15rem;
  color: #fff;
}

.flow-actor-name {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #495057;
  line-height: 1.2;
}

/* --- Step Rows --- */
.flow-row {
  display: grid;
  align-items: start;
  min-height: 50px;
  padding: 0.25rem 0;
  position: relative;
}

.flow-row-6 { grid-template-columns: repeat(6, 1fr); }
.flow-row-7 { grid-template-columns: repeat(7, 1fr); }

/* --- Step Boxes --- */
.flow-step {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.3;
  text-align: center;
  border: 2px solid;
  background: #fff;
  position: relative;
  z-index: 2;
  margin: 0 auto;
  max-width: 160px;
  word-wrap: break-word;
}

/* Color variants */
.flow-step-action   { border-color: #0d6efd; background: #e7f1ff; color: #052c65; }
.flow-step-success  { border-color: #198754; background: #d1e7dd; color: #0a3622; }
.flow-step-error    { border-color: #dc3545; background: #f8d7da; color: #58151c; }
.flow-step-data     { border-color: #0dcaf0; background: #cff4fc; color: #055160; }
.flow-step-security { border-color: #6f42c1; background: #e8ddf5; color: #3b1f6e; }
.flow-step-wait     { border-color: #6c757d; background: #e9ecef; color: #343a40; }

/* Step number badge */
.flow-step-num {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #d4a017;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  line-height: 1;
}

/* --- Decision Diamond --- */
.flow-diamond-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0;
  position: relative;
  z-index: 2;
}

.flow-diamond {
  width: 90px;
  height: 90px;
  transform: rotate(45deg);
  border: 2px solid #ffc107;
  background: #fff3cd;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-diamond-text {
  transform: rotate(-45deg);
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  color: #664d03;
  line-height: 1.15;
  max-width: 72px;
}

/* --- SVG Defs Container (must be visible for marker refs) --- */
.flow-svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --- Arrow Containers --- */
.flow-arrow-row {
  position: relative;
  height: 36px;
  min-width: 100%;
}

.flow-arrow-row svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Vertical spacer between steps */
.flow-spacer {
  height: 8px;
}

.flow-spacer-lg {
  height: 20px;
}

/* --- Phase Dividers --- */
.flow-phase {
  padding: 0.4rem 1rem;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 4px;
  margin: 0.75rem 0;
}

/* --- Timing Annotations --- */
.flow-timing {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  display: inline-block;
  margin-top: 0.25rem;
}

.flow-timing-instant {
  background: #d1e7dd;
  color: #0a3622;
}

.flow-timing-delayed {
  background: #fff3cd;
  color: #664d03;
}

/* --- Legend --- */
.flow-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.7rem;
  align-items: center;
}

.flow-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.flow-legend-swatch {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
}

.flow-legend-diamond {
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border: 2px solid #ffc107;
  background: #fff3cd;
  flex-shrink: 0;
}

/* --- Security Callout --- */
.flow-security-note {
  font-size: 0.6rem;
  color: #6f42c1;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

/* --- Arrow Label Styling --- */
.flow-arrow-label {
  font-size: 10px;
  fill: #495057;
  text-anchor: middle;
  font-weight: 700;
}

.flow-arrow-label-success {
  fill: #198754;
}

.flow-arrow-label-error {
  fill: #dc3545;
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
  .flow-diagram-inner {
    min-width: 850px;
  }
  .flow-diagram-inner.flow-cols-7 {
    min-width: 1000px;
  }
}

@media (max-width: 767.98px) {
  .flow-diagram {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
