/* =====================================================
   AI FACTORY BUILDER — sidebar.css
   ===================================================== */

#sidebar {
  display: flex;
  flex-direction: row;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-dim);
  z-index: var(--z-sidebar);
  flex-shrink: 0;
  position: relative;
}

/* ── Vertical icon tabs ────────────────────────── */
#sidebar-tabs {
  width: var(--sidebar-tab-w);
  height: 100%;
  background: var(--bg-base);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-tab {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--anim-base), background var(--anim-base);
  position: relative;
  font-size: 22px;
}

.sidebar-tab:hover {
  color: var(--text-bright);
  background: var(--bg-elevated);
}

.sidebar-tab.active {
  color: var(--accent-cyan);
  background: var(--bg-elevated);
}

.sidebar-tab.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 20px;
  background: var(--accent-cyan);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.sidebar-tab-divider {
  width: 24px;
  height: 1px;
  background: var(--border-dim);
  margin: 4px 0;
}

/* ── Library panel ─────────────────────────────── */
#sidebar-library {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.library-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-dim);
}

.library-title {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.library-search {
  margin-top: 8px;
  position: relative;
}

.library-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 5px 8px 5px 26px;
  outline: none;
  transition: border-color var(--anim-base);
}

.library-search input:focus {
  border-color: var(--border-accent);
}

.library-search input::placeholder {
  color: var(--text-dim);
}

.library-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

/* Category groups */
.library-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.library-category {
  margin-bottom: 4px;
}

.library-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  transition: color var(--anim-fast);
}

.library-category-header:hover { color: var(--text-base); }

.library-category-header .chevron {
  transition: transform var(--anim-base);
  font-size: 14px;
}

.library-category.collapsed .chevron { transform: rotate(-90deg); }
.library-category.collapsed .library-blocks { display: none; }

.library-blocks {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ── Draggable block items in library ─────────── */
.library-block-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-dim);
  background: var(--bg-elevated);
  cursor: grab;
  transition: border-color var(--anim-fast), background var(--anim-fast), transform var(--anim-fast);
  position: relative;
  overflow: hidden;
}

.library-block-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--block-color, var(--accent-blue));
  opacity: 0.8;
}

.library-block-item:hover {
  border-color: var(--border-bright);
  background: var(--bg-active);
  transform: translateX(2px);
}

.library-block-item:active {
  cursor: grabbing;
}

.library-block-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.library-block-info {
  flex: 1;
  min-width: 0;
}

.library-block-name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-block-desc {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ghost drag preview */
.library-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: var(--z-dragging);
  opacity: 0.85;
  transform: rotate(2deg) scale(1.05);
  transition: none;
}
