/* ---------- Concept Lab ---------- */

.concept-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-3);
}

.concept-tab {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.concept-tab:hover {
  color: var(--text);
  border-color: var(--muted);
}

.concept-tab.is-active {
  color: var(--green);
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.1);
}

.concept-tab--add {
  font-weight: 600;
  width: 32px;
  text-align: center;
  padding: var(--space-2) 0;
}

.concept-tab--add-group {
  font-weight: 600;
}

.concept-tab-wrap {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
}

.concept-tab__menu-btn,
.concept-group__menu-btn {
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}

.concept-tab__menu-btn:hover,
.concept-group__menu-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.concept-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: 2px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Drag-and-drop (concept-lab-dragdrop.js): a solid accent border/tint on
   the group chip being hovered, and a crisp side border on whichever half
   of a tab is the insertion point — no blur/glow, consistent with the
   grid's own "quiet" editing indicators. */
.concept-group--drop-target {
  border-style: solid;
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.1);
}

.concept-tab--drop-before {
  border-left: 2px solid var(--green);
}

.concept-tab--drop-after {
  border-right: 2px solid var(--green);
}

.concept-tab.is-dragging {
  opacity: 0.4;
}

.concept-group__header {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.concept-group__header:hover {
  color: var(--text);
}

.concept-group__chevron {
  font-size: 0.65rem;
}

.concept-group__count {
  font-size: 0.7rem;
  color: var(--muted);
}

.concept-group__active-label {
  font-size: 0.75rem;
  color: var(--green);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.concept-sheet-meta {
  margin-bottom: var(--space-4);
}

.concept-sheet-meta__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.concept-sheet-meta__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.concept-meta-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  padding: 2px 6px;
  width: 100%;
  max-width: 320px;
}

.concept-meta-name:hover,
.concept-meta-name:focus {
  border-color: var(--border);
  outline: none;
}

.concept-sheet-meta__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.concept-sheet-meta__row label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--muted);
}

.concept-sheet-meta__row input {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 0.8rem;
  color: var(--text);
}

.concept-sheet-meta__conditions {
  margin-top: var(--space-3);
  cursor: text;
}

.concept-conditions {
  list-style: decimal;
  margin: 0;
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 0.85rem;
  color: var(--muted);
}

.concept-conditions-empty {
  font-size: 0.85rem;
}

.concept-sheet-meta__conditions textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  font-size: 0.85rem;
  color: var(--text);
  resize: vertical;
}

.concept-lab-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.concept-lab-table-toolbar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.concept-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

/* border-collapse: collapse (above) already merges each pair of adjacent
   cells' borders into a single line rather than stacking two — this one
   low-contrast border value is genuinely the only line drawn at any seam. */
.concept-table th,
.concept-table td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
  white-space: nowrap;
}

.concept-table thead th {
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 2px solid rgba(255, 255, 255, 0.28);
}

.concept-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.concept-table__header {
  white-space: nowrap;
}

.concept-table__header-name {
  cursor: text;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.concept-table__header-name:hover {
  color: var(--text);
  background: var(--bg);
}

.concept-table__sort-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0 2px;
}

.concept-table__sort-btn:hover {
  color: var(--text);
}

.concept-table__header-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  margin-left: 2px;
}

.concept-table__header-remove:hover {
  color: var(--red);
}

.concept-table__header-placeholder {
  color: var(--muted);
  font-style: italic;
}

/* The wrapping <th>/<td> that holds an active input gets its own padding
   zeroed, and the input's padding is reduced by its 1px border on each
   side — together they land on exactly the same total inset as the normal
   cell padding, so entering edit mode doesn't nudge row height or column
   width. */
.concept-table th.concept-table__cell--input,
.concept-table td.concept-table__cell--input {
  padding: 0;
}

.header-input {
  display: block;
  width: 100%;
  min-width: 80px;
  background: var(--bg);
  border: 1px solid var(--green);
  padding: calc(var(--space-2) - 1px) calc(var(--space-3) - 1px);
  font-size: 0.75rem;
  color: var(--text);
  outline: none;
}

.concept-table__filter-row input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 0.8rem;
  color: var(--text);
}

.concept-table__cell {
  cursor: text;
  position: relative; /* anchors the hover dot below */
}

.concept-table__cell:hover {
  background: var(--bg);
}

/* Crosshair highlight on the row + column of the cell being edited. Both
   this and .is-selected below are deliberately faint — the focused input's
   own 1px border (see .cell-input) is what actually marks the active
   cell; these are just ambient row/column context. */
.concept-table tbody tr.is-editing-row {
  background: rgba(255, 255, 255, 0.07);
}

.concept-table td.is-editing-col,
.concept-table th.is-editing-col {
  background: rgba(255, 255, 255, 0.11);
}

.concept-table tbody tr.is-selected {
  background: rgba(255, 255, 255, 0.04);
}

/* Manual/rule-driven cell colour — a per-cell concept only, never a row.
   Placed last so it wins over the zebra stripe and the editing-row/column
   tint above; this is deliberate data (win/loss colour-coding), not a
   transient UI state. Text takes the solid colour, background a light
   ~15% tint so typed text stays readable. */
.concept-table td.concept-color-bg--green {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}
.concept-table td.concept-color-bg--red {
  background: rgba(244, 80, 106, 0.15);
  color: var(--red);
}
.concept-table td.concept-color-bg--yellow {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}
.concept-table td.concept-color-bg--blue {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}
.concept-table td.concept-color-bg--purple {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}
.concept-table td.concept-color-bg--grey {
  background: rgba(113, 113, 122, 0.15);
  color: #71717a;
}

/* Small colour-picker trigger inside each cell — invisible until the cell
   is hovered, in addition to right-click working anywhere in the cell. */
.concept-cell-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.concept-table__cell:hover .concept-cell-dot {
  opacity: 1;
}
.concept-cell-dot--green {
  background: var(--green);
  border-color: var(--green);
}
.concept-cell-dot--red {
  background: var(--red);
  border-color: var(--red);
}
.concept-cell-dot--yellow {
  background: #eab308;
  border-color: #eab308;
}
.concept-cell-dot--blue {
  background: #3b82f6;
  border-color: #3b82f6;
}
.concept-cell-dot--purple {
  background: #a855f7;
  border-color: #a855f7;
}
.concept-cell-dot--grey {
  background: #71717a;
  border-color: #71717a;
}
/* A cell that already has a colour keeps its dot faintly visible even
   without hovering, as a quiet reminder it's tagged. */
.concept-color-bg--green .concept-cell-dot--green,
.concept-color-bg--red .concept-cell-dot--red,
.concept-color-bg--yellow .concept-cell-dot--yellow,
.concept-color-bg--blue .concept-cell-dot--blue,
.concept-color-bg--purple .concept-cell-dot--purple,
.concept-color-bg--grey .concept-cell-dot--grey {
  opacity: 0.6;
}

.concept-lab-hint {
  font-size: 0.8rem;
}

.concept-rules-panel {
  margin-bottom: var(--space-4);
}

.concept-rules-panel__hint {
  font-size: 0.8rem;
  margin-bottom: var(--space-3);
}

.concept-rule-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.concept-rule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.concept-rule-row select,
.concept-rule-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.concept-rule-row__contains,
.concept-rule-row__arrow {
  font-size: 0.8rem;
  color: var(--muted);
}

.concept-rule-row [data-remove-rule] {
  margin-left: auto;
}

.concept-table td .cell-input {
  display: block;
  width: 100%;
  min-width: 60px;
  background: var(--bg);
  border: 1px solid var(--green);
  padding: calc(var(--space-2) - 1px) calc(var(--space-3) - 1px);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  outline: none;
}

.concept-table__thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  display: block;
}

.concept-shot-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 220px;
}

.concept-shot-thumb {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.concept-shot-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.6rem;
  line-height: 1;
  padding: 0;
}

.concept-shot-remove:hover {
  color: var(--red);
  border-color: var(--red);
}

.concept-shot-add {
  width: 32px;
  height: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.concept-shot-add:hover {
  color: var(--text);
  border-color: var(--muted);
}

.concept-shot-cap {
  font-size: 0.7rem;
  white-space: nowrap;
}

/* Small text-menu popover shared by the tab menu (rename/move/delete
   sheet) and the group menu (rename/delete group) in
   concept-lab-groups.js. */
.concept-text-menu {
  position: fixed;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.concept-text-menu__item {
  text-align: left;
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.concept-text-menu__item:hover {
  background: var(--bg);
}

.concept-text-menu__item--destructive {
  color: var(--red);
}

.concept-text-menu__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

.concept-cell-menu {
  position: fixed;
  display: flex;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.concept-cell-menu__swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}

.concept-cell-menu__swatch:hover {
  border-color: var(--text);
}

.concept-cell-menu__swatch--green {
  background: var(--green);
}

.concept-cell-menu__swatch--red {
  background: var(--red);
}

.concept-cell-menu__swatch--yellow {
  background: #eab308;
}

.concept-cell-menu__swatch--blue {
  background: #3b82f6;
}

.concept-cell-menu__swatch--purple {
  background: #a855f7;
}

.concept-cell-menu__swatch--grey {
  background: #71717a;
}

.concept-cell-menu__swatch--clear {
  background: none;
  position: relative;
}

.concept-cell-menu__swatch--clear::before,
.concept-cell-menu__swatch--clear::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1px;
  background: var(--muted);
}

.concept-cell-menu__swatch--clear::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.concept-cell-menu__swatch--clear::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.concept-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  cursor: pointer;
  z-index: 1000;
}

.concept-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  cursor: default;
}

@media (max-width: 599px) {
  .concept-sheet-meta__header {
    flex-direction: column;
  }
}
