/**
 * Flowchart Builder — paste notes module + import modal.
 */

/* ── Home / paste view ─────────────────────────────────────── */

.fcbuilder {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.fcbuilder__hero {
  position: relative;
  padding: 2rem 0 2.25rem;
  text-align: center;
}

.fcbuilder__hero--compact {
  padding: 1rem 0;
  text-align: left;
}

.fcbuilder__back {
  position: absolute;
  left: 0;
  top: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: none;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
}

.fcbuilder__hero--compact .fcbuilder__back {
  position: static;
}

.fcbuilder__back:hover {
  background: var(--surface-3, rgba(0, 0, 0, 0.08));
  color: var(--text-primary);
}

.fcbuilder__hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.fcbuilder__badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(2, 132, 199, 0.12));
  color: #0284c7;
  margin-bottom: 0.75rem;
}

.fcbuilder__title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.15;
  color: var(--text-primary);
}

.fcbuilder__subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.fcbuilder__panel {
  background: var(--card-bg, var(--surface-1));
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  margin-bottom: 2rem;
}

.fcbuilder__form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.fcbuilder__row--split {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1rem;
}

.fcbuilder__field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fcbuilder__field span {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.fcbuilder__field span small {
  font-weight: 400;
  color: var(--text-secondary);
}

.fcbuilder__field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.fcbuilder__input,
.fcbuilder__select,
.fcbuilder__textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  background: var(--input-bg, #fff);
  color: var(--text-primary);
}

.fcbuilder__textarea {
  resize: vertical;
  min-height: 280px;
  line-height: 1.55;
  font-family: 'DM Sans', system-ui, sans-serif;
}

.fcbuilder__input:focus,
.fcbuilder__select:focus,
.fcbuilder__textarea:focus {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  border-color: #0ea5e9;
}

.fcbuilder__paste-btn {
  border: none;
  background: rgba(14, 165, 233, 0.1);
  color: #0284c7;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.fcbuilder__paste-btn:hover {
  background: rgba(14, 165, 233, 0.18);
}

.fcbuilder__hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.fcbuilder__error {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
  font-size: 0.9rem;
}

.fcbuilder__actions {
  display: flex;
  justify-content: flex-end;
}

.fcbuilder__submit {
  min-width: 200px;
}

.fcbuilder__tips {
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
  border: 1px dashed var(--border-subtle, rgba(0, 0, 0, 0.1));
}

.fcbuilder__tips-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.fcbuilder__tips-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.65;
}

.fcbuilder__tips-list code {
  font-size: 0.85em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}

/* ── Result view (embedded flow canvas) ────────────────────── */

.fcbuilder--result {
  max-width: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4rem);
}

.fcbuilder-result__toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
  background: var(--card-bg, #fff);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.fcbuilder-result__toolbar .fcbuilder__back {
  position: static;
}

.fcbuilder-result__meta {
  flex: 1;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fcbuilder-result__stat {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
}

.fcbuilder-result__actions {
  display: flex;
  gap: 0.5rem;
}

.fcbuilder-result__btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.fcbuilder-result__btn--ghost {
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border-color: var(--border-subtle, rgba(0, 0, 0, 0.1));
  color: var(--text-primary);
}

.fcbuilder-result__btn--ghost:hover {
  background: var(--surface-3, rgba(0, 0, 0, 0.08));
}

.fcbuilder-result__btn--primary {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
}

.fcbuilder-result__btn--primary:hover {
  filter: brightness(1.06);
}

.fcbuilder-result__canvas {
  flex: 1;
  background: #0b1220;
  min-height: 0;
}

.fcbuilder-result__canvas--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.fcbuilder-result__canvas .fcflow-layout {
  min-height: calc(100vh - 8rem);
}

.fcbuilder-result__canvas .fcflow-canvas {
  padding: 2rem 2.5rem 3rem;
}

/* ── Import modal ────────────────────────────────────────────── */

.fcbuilder-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.fcbuilder-import-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.fcbuilder-import-modal {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg, #fff);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.fcbuilder-import-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
}

.fcbuilder-import-modal__head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.fcbuilder-import-modal__close {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
}

.fcbuilder-import-modal__body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fcbuilder-import__modes {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fcbuilder-import__modes legend {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.fcbuilder-import__mode {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.1));
  border-radius: 10px;
  cursor: pointer;
}

.fcbuilder-import__mode:has(input:checked) {
  border-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.06);
}

.fcbuilder-import__mode span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.fcbuilder-import__mode strong {
  font-size: 0.9rem;
}

.fcbuilder-import__mode small {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.fcbuilder-import__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fcbuilder-import__field span {
  font-size: 0.85rem;
  font-weight: 600;
}

.fcbuilder-import__input,
.fcbuilder-import__select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  font: inherit;
}

.fcbuilder-import__check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.fcbuilder-import__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.fcbuilder-import-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

@media print {
  .fcbuilder-result__toolbar {
    display: none !important;
  }

  .fcbuilder-result__canvas {
    background: #fff;
  }
}

@media (max-width: 768px) {
  .fcbuilder__row--split {
    grid-template-columns: 1fr;
  }

  .fcbuilder-result__toolbar {
    flex-wrap: wrap;
  }

  .fcbuilder-result__actions {
    width: 100%;
    justify-content: stretch;
  }

  .fcbuilder-result__btn {
    flex: 1;
  }
}
