/* Base element on canvas */
.wf-element {
  position: absolute;
  box-sizing: border-box;
  cursor: default;
}
.wf-element:hover .element-hover-ring {
  opacity: 1;
}
.element-hover-ring {
  position: absolute;
  inset: -2px;
  border: 1.5px solid var(--accent);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}

/* Selected state */
.wf-element.selected .element-hover-ring { display: none; }
.wf-element.selected { outline: none; }
.wf-element.selected > .selection-handles { display: block; }
.wf-element.locked { opacity: 0.5; }

/* Selection handles */
.selection-handles {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
.selection-outline {
  position: absolute;
  inset: -1px;
  border: 1.5px solid var(--accent);
  border-radius: inherit;
  pointer-events: none;
}
.handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  pointer-events: all;
  cursor: nwse-resize;
  z-index: 30;
}
.handle.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.handle.n  { top: -4px; left: calc(50% - 4px); cursor: ns-resize; }
.handle.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.handle.e  { top: calc(50% - 4px); right: -4px; cursor: ew-resize; }
.handle.se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.handle.s  { bottom: -4px; left: calc(50% - 4px); cursor: ns-resize; }
.handle.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.handle.w  { top: calc(50% - 4px); left: -4px; cursor: ew-resize; }
.handle.rotate {
  top: -28px;
  left: calc(50% - 4px);
  cursor: crosshair;
  background: var(--accent);
  border-color: white;
}

/* ── WIREFRAME COMPONENT STYLES ── */

/* Frame */
.wf-frame {
  background: white;
  border: 2px solid var(--border2);
  border-radius: 4px;
  overflow: visible;
}
.wf-frame-label {
  position: absolute;
  top: -22px;
  left: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  pointer-events: none;
}

/* Rectangle */
.wf-rect {
  background: var(--wire-fill);
  border: 1.5px solid var(--wire-stroke);
  border-radius: 4px;
}

/* Ellipse */
.wf-ellipse {
  background: var(--wire-fill);
  border: 1.5px solid var(--wire-stroke);
  border-radius: 50%;
}

/* Text */
.wf-text {
  color: var(--wire-text);
  font-size: 14px;
  line-height: 1.5;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  min-width: 40px;
  min-height: 20px;
}
.wf-text.editing {
  outline: 2px solid var(--accent);
  background: rgba(255,255,255,0.9);
  border-radius: 3px;
  padding: 2px 4px;
  cursor: text;
}

/* Image placeholder */
.wf-image {
  background: var(--surface2);
  border: 1.5px solid var(--wire-stroke);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text3);
  font-size: 12px;
  overflow: hidden;
}
.wf-image img { width: 100%; height: 100%; object-fit: cover; }
.wf-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text3);
  font-size: 11px;
  width: 100%;
  height: 100%;
}

/* ── UI COMPONENTS ── */
.wf-comp {
  font-family: var(--font);
  pointer-events: none;
  overflow: hidden;
}
.wf-comp * { pointer-events: none; }

/* Button */
.wf-button-comp {
  background: var(--wire-accent-fill);
  border: 1.5px solid var(--wire-accent-stroke);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: #444;
}
.wf-button-comp.secondary { background: var(--wire-fill); border-color: var(--wire-stroke); }
.wf-button-comp.ghost { background: transparent; border-color: var(--wire-stroke); }

/* Input */
.wf-input-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
}
.wf-input-comp.focused { border-color: var(--wire-accent-stroke); }

/* Navbar */
.wf-navbar-comp {
  background: white;
  border-bottom: 1.5px solid var(--wire-stroke);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
}
.wf-navbar-logo { font-weight: 700; font-size: 13px; color: var(--text); margin-right: auto; }
.wf-navbar-link { font-size: 12px; color: var(--text2); }
.wf-navbar-link.active { color: var(--accent); font-weight: 500; }
.wf-navbar-btn {
  padding: 4px 12px;
  background: var(--wire-accent-fill);
  border: 1px solid var(--wire-accent-stroke);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Card */
.wf-card-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.wf-card-image {
  background: var(--surface2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 11px;
}
.wf-card-body { padding: 12px; flex: 1; }
.wf-card-title { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.wf-card-desc { font-size: 11px; color: var(--text2); line-height: 1.5; }
.wf-card-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* Table */
.wf-table-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.wf-table-head {
  background: var(--surface2);
  display: flex;
  border-bottom: 1.5px solid var(--wire-stroke);
}
.wf-table-row { display: flex; border-bottom: 1px solid var(--border); }
.wf-table-row:last-child { border-bottom: none; }
.wf-table-cell {
  flex: 1;
  padding: 6px 10px;
  font-size: 11px;
  border-right: 1px solid var(--border);
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wf-table-cell:last-child { border-right: none; }
.wf-table-head .wf-table-cell { font-weight: 600; color: var(--text); font-size: 11px; }

/* Checkbox */
.wf-checkbox-comp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.wf-checkbox-box {
  width: 16px; height: 16px;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: white;
}
.wf-checkbox-box.checked { background: var(--wire-accent-fill); border-color: var(--wire-accent-stroke); }
.wf-checkbox-box.checked::after { content: '✓'; font-size: 10px; color: var(--accent); font-weight: 700; }

/* Radio */
.wf-radio-comp {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wf-radio-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text); }
.wf-radio-circle {
  width: 16px; height: 16px;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: white;
}
.wf-radio-circle.selected::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Toggle */
.wf-toggle-comp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.wf-toggle-track {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--border2);
  position: relative;
  transition: background 0.2s;
}
.wf-toggle-track.on { background: var(--wire-accent-stroke); }
.wf-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform 0.2s;
}
.wf-toggle-track.on .wf-toggle-thumb { transform: translateX(16px); }

/* Dropdown */
.wf-dropdown-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 5px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text2);
}
.wf-dropdown-comp::after { content: '▾'; color: var(--text3); }

/* Slider */
.wf-slider-comp {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.wf-slider-track {
  flex: 1;
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  position: relative;
}
.wf-slider-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--wire-accent-stroke);
  border-radius: 2px;
}
.wf-slider-thumb {
  position: absolute;
  top: -6px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--wire-accent-stroke);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.wf-slider-label { font-size: 11px; color: var(--text3); font-family: var(--font-mono); }

/* Badge */
.wf-badge-comp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--wire-accent-fill);
  border: 1px solid var(--wire-accent-stroke);
  color: #444;
  width: 100%;
  height: 100%;
}

/* Avatar */
.wf-avatar-comp {
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--wire-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text2);
  font-size: 13px;
  overflow: hidden;
}

/* Divider */
.wf-divider-comp {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
}
.wf-divider-line {
  flex: 1;
  height: 1.5px;
  background: var(--wire-stroke);
}
.wf-divider-text { font-size: 11px; color: var(--text3); white-space: nowrap; }

/* Progress */
.wf-progress-comp {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 0 2px;
}
.wf-progress-label-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text2); }
.wf-progress-track {
  width: 100%;
  height: 8px;
  background: var(--border2);
  border-radius: 4px;
  overflow: hidden;
}
.wf-progress-fill {
  height: 100%;
  background: var(--wire-accent-stroke);
  border-radius: 4px;
}

/* Tabs */
.wf-tabs-comp {
  display: flex;
  flex-direction: column;
}
.wf-tabs-bar {
  display: flex;
  border-bottom: 1.5px solid var(--wire-stroke);
  background: var(--surface2);
}
.wf-tab {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
}
.wf-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: white; }
.wf-tabs-content {
  flex: 1;
  padding: 12px;
  font-size: 12px;
  color: var(--text3);
  background: white;
  border: 1px solid var(--wire-stroke);
  border-top: none;
}

/* Modal */
.wf-modal-comp {
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.wf-modal-box {
  background: white;
  border-radius: 8px;
  border: 1.5px solid var(--wire-stroke);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 200px;
}
.wf-modal-header { padding: 12px 16px 10px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.wf-modal-title { font-weight: 600; font-size: 13px; }
.wf-modal-close { color: var(--text3); font-size: 13px; }
.wf-modal-body { padding: 12px 16px; font-size: 12px; color: var(--text2); flex: 1; }
.wf-modal-footer { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.wf-modal-btn { padding: 5px 12px; border-radius: 4px; font-size: 11px; font-weight: 500; background: var(--wire-accent-fill); border: 1px solid var(--wire-accent-stroke); }
.wf-modal-btn.sec { background: var(--wire-fill); border-color: var(--wire-stroke); }

/* Sidebar */
.wf-sidebar-comp {
  display: flex;
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 6px;
  overflow: hidden;
}
.wf-sidebar-nav {
  width: 40%;
  background: var(--surface2);
  border-right: 1px solid var(--wire-stroke);
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wf-sidebar-item {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.wf-sidebar-item.active { background: var(--wire-accent-fill); color: #444; }
.wf-sidebar-icon { width: 12px; height: 12px; border-radius: 2px; background: currentColor; opacity: 0.4; flex-shrink: 0; }
.wf-sidebar-main { flex: 1; padding: 8px; font-size: 11px; color: var(--text3); }

/* Breadcrumb */
.wf-breadcrumb-comp {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.wf-bc-item { color: var(--text2); }
.wf-bc-item.current { color: var(--text); font-weight: 500; }
.wf-bc-sep { color: var(--text3); }

/* Pagination */
.wf-pagination-comp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.wf-page-btn {
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 1px solid var(--wire-stroke);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: var(--text2);
  background: white;
}
.wf-page-btn.active { background: var(--wire-accent-fill); border-color: var(--wire-accent-stroke); color: #444; font-weight: 600; }
.wf-page-btn.nav { color: var(--text3); }

/* List */
.wf-list-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 6px;
  overflow: hidden;
}
.wf-list-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.wf-list-item:last-child { border-bottom: none; }
.wf-list-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--wire-stroke); flex-shrink: 0; }
.wf-list-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--wire-stroke); flex-shrink: 0; }

/* Chart */
.wf-chart-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wf-chart-title { font-size: 12px; font-weight: 600; color: var(--text); }
.wf-chart-area {
  flex: 1;
  background: var(--surface2);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 8px 0;
  overflow: hidden;
}
.wf-chart-bar {
  flex: 1;
  background: var(--wire-accent-stroke);
  opacity: 0.7;
  border-radius: 3px 3px 0 0;
  min-width: 8px;
}

/* Form */
.wf-form-comp {
  background: white;
  border: 1.5px solid var(--wire-stroke);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wf-form-title { font-size: 14px; font-weight: 600; color: var(--text); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.wf-form-field { display: flex; flex-direction: column; gap: 4px; }
.wf-form-label { font-size: 11px; font-weight: 500; color: var(--text2); }
.wf-form-input { height: 30px; border: 1.5px solid var(--wire-stroke); border-radius: 4px; background: var(--bg); }
.wf-form-submit { height: 32px; border-radius: 5px; background: var(--wire-accent-fill); border: 1.5px solid var(--wire-accent-stroke); font-size: 12px; font-weight: 500; align-self: flex-start; padding: 0 16px; }

/* Hero */
.wf-hero-comp {
  background: var(--surface2);
  border: 1.5px solid var(--wire-stroke);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 20px;
}
.wf-hero-tag { padding: 3px 10px; border-radius: 20px; background: var(--wire-accent-fill); border: 1px solid var(--wire-accent-stroke); font-size: 11px; color: #555; }
.wf-hero-title { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.wf-hero-sub { font-size: 12px; color: var(--text2); max-width: 280px; line-height: 1.5; }
.wf-hero-btns { display: flex; gap: 8px; }
.wf-hero-btn { padding: 7px 16px; border-radius: 5px; font-size: 12px; font-weight: 500; }
.wf-hero-btn.primary { background: var(--wire-accent-fill); border: 1.5px solid var(--wire-accent-stroke); }
.wf-hero-btn.secondary { background: white; border: 1.5px solid var(--wire-stroke); color: var(--text2); }

/* Footer */
.wf-footer-comp {
  background: var(--surface2);
  border: 1.5px solid var(--wire-stroke);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.wf-footer-top { display: flex; gap: 20px; }
.wf-footer-col { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.wf-footer-col-title { font-size: 11px; font-weight: 700; color: var(--text); }
.wf-footer-link { font-size: 11px; color: var(--text3); }
.wf-footer-bottom { border-top: 1px solid var(--border); padding-top: 8px; font-size: 11px; color: var(--text3); display: flex; justify-content: space-between; }

/* Icon placeholder */
.wf-icon-comp {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wire-stroke);
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--wire-stroke);
}

/* Line / Arrow */
.wf-line-container {
  position: absolute;
  pointer-events: all;
  overflow: visible;
}
.wf-line-svg { overflow: visible; }
.wf-line-hit {
  position: absolute;
  inset: -8px;
  cursor: pointer;
}

/* Group */
.wf-group {
  position: absolute;
}
.wf-group > .selection-handles .selection-outline { border-style: dashed; }
