/* ============================================
   FlowBoard — Storyboard Library Styles
   All classes prefixed with fb-
   ============================================ */

/* --- Container & Layout --- */
.fb-container {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  display: flex;
  flex-direction: column;
  color: #333;
  font-size: 14px;
  line-height: 1.4;
  box-sizing: border-box;
}

.fb-container *, .fb-container *::before, .fb-container *::after {
  box-sizing: border-box;
}

/* --- Header / Toolbar --- */
.fb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  z-index: 100;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 48px;
}

.fb-project-title {
  font-weight: 700;
  font-size: 16px;
  color: #1a1a1a;
  white-space: nowrap;
}

.fb-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fb-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  color: #555;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}

.fb-toolbar-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

.fb-toolbar-btn:active {
  background: #e0e0e0;
}

.fb-zoom-label {
  font-size: 13px;
  color: #666;
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.fb-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.fb-action-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

.fb-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.fb-toggle-label input[type="checkbox"] {
  accent-color: #2A9D8F;
}

.fb-header-separator {
  width: 1px;
  height: 24px;
  background: #ddd;
  margin: 0 4px;
  flex-shrink: 0;
}

/* --- Legend --- */
.fb-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fb-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}

.fb-legend-item:hover {
  opacity: 0.8;
}

.fb-legend-item.fb-dimmed {
  color: #bbb;
}

.fb-legend-item.fb-dimmed .fb-legend-dot {
  opacity: 0.35;
}

.fb-legend-checkbox {
  width: 13px;
  height: 13px;
  cursor: pointer;
  margin: 0;
}

.fb-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Canvas --- */
.fb-canvas-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: default;
  background: #e4e6e9;
}

.fb-canvas-wrapper.fb-dragging-screen {
  cursor: default;
}

.fb-canvas-wrapper.fb-dragging-handle {
  cursor: grabbing;
}

.fb-canvas-sizer {
  transform-origin: 0 0;
  position: absolute;
  top: 0;
  left: 0;
}

.fb-canvas {
  position: relative;
  width: 10000px;
  height: 8000px;
  background: #f0f2f5;
  border: 2px dashed #ccc;
}

/* --- Arrows SVG Layer --- */
.fb-arrows-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.fb-arrow-path {
  fill: none;
  stroke: #888;
  stroke-width: 2;
}

.fb-arrow-path.fb-dashed {
  stroke-dasharray: 6 4;
}

.fb-arrow-head {
  fill: #888;
}

.fb-arrow-label {
  font-size: 11px;
  fill: #555;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.fb-arrow-label-bg {
  fill: #f0f2f5;
  rx: 3;
  ry: 3;
}

.fb-arrow-group {
  pointer-events: none;
}

.fb-arrow-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
}

.fb-arrow-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #888;
  opacity: 0;
  cursor: pointer;
  z-index: 25;
  transition: opacity 0.15s;
}

.fb-arrow-handle:hover {
  opacity: 1;
  background: #555;
}

.fb-arrow-handle:active {
  cursor: grabbing;
}

/* --- Arrow Contextual Popup --- */
.fb-arrow-popup {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 50;
}

.fb-arrow-popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: #555;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
}

.fb-arrow-popup-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.fb-arrow-popup-delete:hover {
  background: #fee2e2;
  color: #e74c3c;
}

.fb-arrow-popup-input {
  width: 90px;
  height: 26px;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  color: #333;
}

.fb-arrow-popup-input:focus {
  border-color: #2A9D8F;
}

.fb-arrow-popup-sep {
  width: 1px;
  height: 20px;
  background: #e0e0e0;
  margin: 0 2px;
}

/* --- Screen Contextual Popup --- */
.fb-screen-popup {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  min-width: 150px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 50;
}

.fb-screen-popup-label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
}

.fb-screen-popup-sizes {
  display: flex;
  gap: 4px;
}

.fb-screen-popup-size {
  flex: 1;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.fb-screen-popup-size:hover {
  background: #f0f0f0;
}

.fb-screen-popup-size.active {
  background: #2A9D8F;
  color: #fff;
  border-color: #2A9D8F;
}

.fb-screen-popup-size.active:hover {
  background: #238a7e;
}

.fb-screen-popup-sep {
  height: 1px;
  background: #e0e0e0;
}

.fb-screen-popup-input {
  width: 100%;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  color: #333;
  box-sizing: border-box;
}

.fb-screen-popup-input:focus {
  border-color: #2A9D8F;
}

.fb-screen-popup-btn {
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: #555;
  transition: background 0.15s;
}

.fb-screen-popup-btn:hover {
  background: #f0f0f0;
}

/* --- Anchor Dots --- */
.fb-anchor-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(42, 157, 143, 0.15);
  border: 2px solid rgba(42, 157, 143, 0.4);
  cursor: pointer;
  z-index: 20;
  transition: transform 0.1s, background 0.1s, border-color 0.1s;
  pointer-events: auto;
}

.fb-anchor-dot:hover,
.fb-anchor-dot.fb-anchor-dot-hover {
  transform: scale(1.5);
  background: rgba(42, 157, 143, 0.6);
  border-color: #2A9D8F;
}

.fb-anchor-dot.fb-anchor-dot-source {
  background: #2A9D8F;
  transform: scale(1.6);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.3);
}

/* Arrow creation mode */
.fb-canvas-wrapper.fb-creating-arrow {
  cursor: crosshair;
}

.fb-arrow-temp {
  pointer-events: none;
}

/* --- Screen Cards --- */
.fb-screen {
  position: absolute;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  cursor: move;
  z-index: 2;
  transition: box-shadow 0.2s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fb-screen:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 3;
}

.fb-screen.fb-dragging {
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 10;
  opacity: 0.92;
}

/* Size variants */
.fb-screen.fb-size-sm { width: 240px; }
.fb-screen.fb-size-md { width: 320px; }
.fb-screen.fb-size-lg { width: 400px; }
.fb-screen.fb-size-xl { width: 520px; }

/* Screen Header */
.fb-screen-header {
  position: relative;
  padding: 8px 30px 8px 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.fb-screen-header .fb-screen-id {
  opacity: 0.7;
  font-weight: 400;
  font-size: 11px;
}

/* Screen Body */
.fb-screen-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}

/* Screen Footer (notes) */
.fb-screen-footer {
  padding: 6px 12px 8px;
  border-top: 1px solid #eee;
  background: #fff;
  font-size: 10px;
  color: #aaa;
  font-style: italic;
  line-height: 1.3;
}

.fb-screen-footer.fb-hidden {
  display: none;
}

/* ============================================
   Wireframe Utility Classes (fb-*)
   Used inside screen body content
   ============================================ */

/* Navigation Bar */
.fb-bar {
  background: #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Button */
.fb-btn {
  background: #2A9D8F;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  text-align: center;
  cursor: default;
  font-weight: 500;
}

.fb-btn.outline {
  background: transparent;
  border: 1.5px solid #2A9D8F;
  color: #2A9D8F;
}

.fb-btn.danger {
  background: #e74c3c;
}

.fb-btn.secondary {
  background: #888;
}

.fb-btn.small {
  padding: 4px 10px;
  font-size: 11px;
}

/* Input */
.fb-input {
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: #999;
  background: #fafafa;
}

/* Card (nested) */
.fb-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Badge */
.fb-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #e0e0e0;
  color: #555;
}

.fb-badge.green  { background: #d1fae5; color: #065f46; }
.fb-badge.blue   { background: #dbeafe; color: #1e40af; }
.fb-badge.orange { background: #ffedd5; color: #9a3412; }
.fb-badge.red    { background: #fee2e2; color: #991b1b; }
.fb-badge.purple { background: #ede9fe; color: #5b21b6; }

/* Image Placeholder */
.fb-img {
  background: #e5e7eb;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 12px;
  min-height: 60px;
}

/* Separator */
.fb-sep {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* Row (horizontal layout) */
.fb-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.fb-row.spread {
  justify-content: space-between;
}

.fb-row.wrap {
  flex-wrap: wrap;
}

/* Icon Placeholder */
.fb-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: #d1d5db;
  flex-shrink: 0;
}

.fb-icon.round {
  border-radius: 50%;
}

.fb-icon.lg {
  width: 32px;
  height: 32px;
}

/* Text */
.fb-text {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}

.fb-text.title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
}

.fb-text.subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.fb-text.small {
  font-size: 10px;
  color: #999;
}

.fb-text.muted {
  color: #999;
}

/* Section Label */
.fb-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

/* Table */
.fb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.fb-table th {
  text-align: left;
  padding: 4px 6px;
  background: #f3f4f6;
  border-bottom: 1px solid #ddd;
  font-weight: 600;
  color: #555;
  font-size: 10px;
  text-transform: uppercase;
}

.fb-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #eee;
  color: #666;
}

/* Stat Card */
.fb-stat-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background: #fafafa;
  flex: 1;
}

.fb-stat-card .fb-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

.fb-stat-card .fb-stat-label {
  font-size: 10px;
  color: #999;
  margin-top: 2px;
}

/* Grid of images */
.fb-grid-images {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.fb-grid-images .fb-img {
  min-height: 50px;
}

/* Rich text block */
.fb-richtext {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  color: #888;
  line-height: 1.5;
  min-height: 40px;
}

/* Tabs */
.fb-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  gap: 0;
}

.fb-tab {
  padding: 6px 12px;
  font-size: 12px;
  color: #888;
  cursor: default;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.fb-tab.active {
  color: #2A9D8F;
  border-bottom-color: #2A9D8F;
  font-weight: 600;
}

/* List */
.fb-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fb-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  font-size: 12px;
  color: #555;
}

.fb-list-item:last-child {
  border-bottom: none;
}

/* Avatar */
.fb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}

.fb-avatar.sm {
  width: 20px;
  height: 20px;
}

/* Progress bar */
.fb-progress {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.fb-progress-fill {
  height: 100%;
  background: #2A9D8F;
  border-radius: 3px;
}

/* Chip/Tag */
.fb-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  background: #e5e7eb;
  color: #555;
}

/* --- Screen Toggle (hide/show) --- */
.fb-screen-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fb-screen-header:hover .fb-screen-toggle {
  opacity: 1;
}

.fb-screen-toggle:hover {
  color: #fff;
}

/* Screen dimmed (individually hidden) */
.fb-screen-dimmed {
  opacity: 0.25;
  pointer-events: auto;
  cursor: default;
}

.fb-screen-dimmed .fb-screen-body,
.fb-screen-dimmed .fb-screen-footer {
  pointer-events: none;
}

.fb-screen-dimmed .fb-screen-toggle {
  pointer-events: auto;
}

.fb-screen-dimmed .fb-screen-header:hover .fb-screen-toggle,
.fb-screen-dimmed:hover .fb-screen-toggle {
  opacity: 1;
}

/* Arrows connected to a dimmed screen */
.fb-arrow-dimmed {
  opacity: 0.15;
}

/* Flex helpers */
.fb-flex-1 { flex: 1; }
.fb-gap-4 { gap: 4px; }
.fb-gap-8 { gap: 8px; }
.fb-mt-4 { margin-top: 4px; }
.fb-mt-8 { margin-top: 8px; }
