/* =========================================================
   deeBoard — Task Tagging / Labels
   Mirrors link-section / link-picker / notes.css chip patterns.
========================================================= */

/* ---------- Card chips (board view — lives inside .note-card-content
   as its first child: a full-width "cap" fused to the card's own top
   edge, like a lego stud, breaking out of the card's own padding via
   negative margins so it spans edge-to-edge instead of sitting inset.
   Must stay inside .note-card-content — not a flex sibling of it inside
   .note-card, and not a sibling in the column list — or it either gets
   squeezed into the card's icon/content flex row, or breaks SortableJS's
   drag reordering and the filter's card-only hide. ---------- */
.note-card { position: relative; } /* anchor for the tag strip below — no longer clips card content */
.note-card-tags {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 13px;
  overflow: hidden;
  background: var(--surface-hover);
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius-md) var(--radius-md) 0 0; /* round only the strip's own top corners, since the card itself no longer clips */
  /* .note-card's box: 13px right padding, but only 10px "true" padding
     on the left (13px padding - 3px eaten by border-left status color
     stripe). Cancel each side by its actual inset so the strip lines up
     flush with the card's real edges instead of overshooting past the
     colored left stripe. */
  margin: -11px -13px 8px -10px;
  width: calc(100% + 23px);
}
.note-card-tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 1.5px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.6;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  /* --tag-color / --tag-color-soft set inline per chip in JS */
  background: var(--tag-color-soft);
  color: var(--tag-color);
  border: 1px solid var(--tag-color-soft);
}

/* ---------- Modal tags section ---------- */
.task-tags-section {
  margin-bottom: 18px;
}
.task-tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 4px;
}
.task-tag-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: default;
  background: var(--tag-color-soft);
  color: var(--tag-color);
  border: 1px solid var(--tag-color-soft);
}
.task-tag-chip-remove {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: currentColor;
  opacity: 0.7;
  cursor: pointer;
  font-size: 10px;
}
.task-tag-chip-remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

/* ---------- Tag picker list rows ---------- */
.tag-picker-panel { width: 340px; }
.tag-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
}
.tag-picker-row:hover { background: var(--surface-hover); }
.tag-picker-row.selected { background: var(--accent-soft); border-color: var(--accent); }
.tag-picker-row.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tag-picker-row.disabled:hover { background: transparent; }
.tag-picker-limit-hint {
  padding: 8px 10px 2px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-tertiary);
}
.tag-picker-row-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--dot-color);
}
.tag-picker-row-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--text);
}
.tag-picker-row-check {
  flex-shrink: 0;
  color: var(--accent-strong);
  opacity: 0;
  font-size: 15px;
}
.tag-picker-row.selected .tag-picker-row-check { opacity: 1; }

.tag-picker-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
}
.tag-picker-footer .btn-text {
  width: 100%;
  justify-content: center;
}

/* ---------- Custom tag manager modal ---------- */
.custom-tag-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.custom-tag-name-input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}
.custom-tag-name-input:focus { border-color: var(--accent); }
.custom-tag-color-input {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.custom-tag-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.custom-tag-color-input::-webkit-color-swatch { border: none; border-radius: 5px; }

.custom-tag-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 42vh;
  overflow-y: auto;
}
.custom-tag-list-empty {
  padding: 20px 4px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.custom-tag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
}
.custom-tag-item-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.custom-tag-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--text);
}
.custom-tag-item-preset-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-hover);
  flex-shrink: 0;
}
.custom-tag-item-del {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}
.custom-tag-item-del:hover {
  color: var(--accent-rose);
  background: var(--accent-rose-soft);
}

/* ---------- Filter button (header) ---------- */
.tag-filter-btn {
  position: relative;
}
.tag-filter-count {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.tag-filter-count.hidden { display: none; }

.tag-filter-btn.has-active {
  color: var(--accent-strong);
}

/* ---------- Filter dropdown ---------- */
.tag-filter-dropdown {
  position: fixed;
  z-index: 950;
  width: 260px;
  max-width: 90vw;
  max-height: 60vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px var(--shadow-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: noteWindowIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.tag-filter-dropdown.hidden { display: none; }
.tag-filter-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}
.btn-text-small {
  border: none;
  background: transparent;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.btn-text-small:hover { text-decoration: underline; }
.tag-filter-dropdown-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tag-filter-empty {
  padding: 18px 8px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12.5px;
}

/* ---------- Filter application on board cards ---------- */
.note-card.tag-filter-hidden { display: none !important; }

@media (max-width: 640px) {
  .tag-picker-panel { width: 90vw; }
}
