/* ---------------------------------------------------------------
   app.css — layout & components for Flow-Chart Generator.
   --------------------------------------------------------------- */

* { box-sizing: border-box; }

/* an author rule that sets display: flex/grid on an element beats the UA
   stylesheet's [hidden] rule in the cascade — restate it explicitly so
   `hidden` always wins, whatever display the component itself declares. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, select, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---------- header ---------- */

.fc-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.fc-header-left { display: flex; align-items: center; gap: var(--space-2); }
.fc-logo { font-size: 1.2rem; color: var(--accent); }
.fc-title { font-size: 0.95rem; }

.fc-header-flow { display: flex; align-items: center; gap: var(--space-1); }
.fc-header-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.fc-sep { width: 1px; height: 22px; background: var(--border); margin: 0 var(--space-1); }

.fc-select, .fc-input, .fc-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
}

.fc-icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.fc-icon-btn:hover { background: var(--surface-hover); border-color: var(--border); }
.fc-icon-btn:disabled { opacity: 0.35; cursor: default; }
.fc-icon-btn:disabled:hover { background: transparent; border-color: transparent; }

.fc-btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
.fc-btn:hover { background: var(--surface-hover); }
.fc-btn.fc-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fc-btn.fc-primary:hover { background: var(--accent-hover); }
.fc-btn.fc-danger { color: var(--danger); }

/* ---------- main layout ---------- */

.fc-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.fc-canvas-wrap {
  flex: 1 1 auto;
  position: relative;
  background:
    radial-gradient(circle, var(--border) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--bg);
  overflow: hidden;
}

.fc-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.fc-svg:active { cursor: grabbing; }

.fc-zoom-controls {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  box-shadow: var(--shadow-1);
}

/* ---------- SVG node styling ---------- */

.fc-shape { stroke-width: 1.5; }
.fc-start { fill: var(--accent-soft); stroke: var(--accent-line); }
.fc-question { fill: var(--surface); stroke: var(--border-strong); }
.fc-action { fill: var(--surface); stroke: var(--border-strong); }
.fc-exit { fill: var(--surface-2); stroke: var(--border-strong); }

.fc-node { cursor: pointer; }
.fc-node:hover .fc-shape { stroke: var(--accent); }
.fc-node.fc-selected .fc-shape { stroke: var(--accent); stroke-width: 2.5; }

.fc-label { fill: var(--text); font-size: 13px; font-family: var(--font); }
.fc-edge { fill: none; stroke: var(--text-faint); stroke-width: 1.6; }
.fc-edge-label { fill: var(--text-dim); font-size: 11px; }
.fc-arrow-head { fill: var(--text-faint); }

.fc-badge { fill: var(--surface); stroke: var(--border-strong); }
.fc-badge-deprecated { fill: var(--warn); opacity: 0.25; }
.fc-badge-text { fill: var(--text); font-size: 10px; font-family: var(--font-mono); }

.fc-qmark-bg { fill: var(--accent); }
.fc-qmark { fill: var(--on-accent); font-size: 10px; font-weight: 700; }

.fc-slot-circle { fill: var(--surface); stroke: var(--border-strong); stroke-dasharray: 3 3; }
.fc-slot:hover .fc-slot-circle { stroke: var(--accent); fill: var(--accent-soft); }
.fc-slot-plus { fill: var(--text-dim); font-size: 16px; }
.fc-slot { cursor: pointer; }

/* ---------- inspector ---------- */

.fc-inspector {
  width: 320px;
  flex: 0 0 auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.fc-inspector-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.fc-inspector-body { padding: var(--space-4); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-3); }

.fc-field { display: flex; flex-direction: column; gap: 4px; }
.fc-field label { font-size: 0.78rem; color: var(--text-dim); }
.fc-field input, .fc-field textarea, .fc-field select { width: 100%; }
.fc-field textarea { min-height: 70px; resize: vertical; }

.fc-branch-row { display: flex; align-items: center; gap: var(--space-2); }
.fc-branch-row input { flex: 1; }

/* ---------- issues panel ---------- */

.fc-issues {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  max-width: 380px;
  max-height: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.fc-issues-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.fc-issues-list { list-style: none; margin: 0; padding: var(--space-2) var(--space-3); overflow-y: auto; font-size: 0.82rem; }
.fc-issues-list li { padding: 3px 0; cursor: pointer; }
.fc-issues-list li.fc-issue-error { color: var(--danger); }
.fc-issues-list li.fc-issue-warning { color: var(--warn); }
.fc-issues.fc-collapsed .fc-issues-list { display: none; }

/* ---------- modal ---------- */

.fc-modal-host { position: fixed; inset: 0; z-index: 100; }
.fc-modal-backdrop { position: absolute; inset: 0; background: rgba(15, 18, 24, 0.45); }
.fc-modal-panel {
  position: relative;
  max-width: 560px;
  width: min(92vw, 560px);
  max-height: 86vh;
  overflow-y: auto;
  margin: 6vh auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-5);
}

.fc-modal-title { margin: 0 0 var(--space-4); font-size: 1.05rem; }
.fc-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

.fc-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.fc-type-card {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}
.fc-type-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.fc-type-card .fc-type-icon { font-size: 1.6rem; }

/* ---------- register table ---------- */

.fc-register-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.fc-register-table th, .fc-register-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fc-register-table th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.fc-code-pill { font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 6px; }
.fc-status-deprecated { color: var(--warn); }
.fc-status-active { color: var(--ok); }
.fc-row-actions { display: flex; gap: 6px; }
.fc-row-actions button { font-size: 0.75rem; padding: 3px 8px; }

/* ---------- settings ---------- */

.fc-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.fc-settings-section { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.fc-settings-section h4 { margin: 0 0 var(--space-2); font-size: 0.85rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.fc-hint { color: var(--text-faint); font-size: 0.78rem; }

/* ---------- misc ---------- */

.fc-toast {
  position: fixed; bottom: var(--space-4); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 8px 16px; border-radius: var(--radius-pill);
  font-size: 0.85rem; box-shadow: var(--shadow-2);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.fc-toast.fc-show { opacity: 1; }

@media (max-width: 760px) {
  .fc-inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow-2); }
  .fc-header-flow .fc-select { max-width: 110px; }
}
