/* =========================================================================
   Bookmarks — layouts (grid/list/compact) + folder tree
   ========================================================================= */

/* Body splits into folder tree + content */
.bm-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Layout switcher */
.bm-layout-pick {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2px;
}
.bm-layout-btn {
  width: 28px; height: 26px;
  border: 0; background: transparent;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-lo); cursor: pointer;
}
.bm-layout-btn:hover { color: var(--text-hi); }
.bm-layout-btn.is-active {
  background: var(--color-primary); color: #fff;
}
.bm-layout-btn .material-symbols-outlined { font-size: 16px; }

/* Folder tree pane */
.bm-tree {
  overflow-y: auto;
  padding: 8px;
  border-right: 1px solid var(--color-border);
  background: rgba(0,0,0,0.08);
  display: flex; flex-direction: column;
  gap: 1px;
}
html.light .bm-tree { background: rgba(0,0,0,0.02); }
.bm-tree-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 8px 6px;
}
.bm-tree-add {
  background: transparent; border: 0; cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: all 120ms;
}
.bm-tree-add:hover {
  color: var(--color-primary);
  background: rgba(var(--primary-rgb, 127,13,242), 0.1);
}
.bm-tree-add .material-symbols-outlined { font-size: 16px; }
.bm-tree-row {
  display: flex; align-items: center; gap: 4px;
  width: 100%;
  padding: 6px 6px;
  background: transparent; border: 0; border-radius: 7px;
  cursor: pointer; font-family: inherit;
  font-size: 12.5px; color: var(--text-md);
  text-align: left;
}
.bm-tree-row:hover { background: rgba(var(--primary-rgb, 127,13,242), 0.06); color: var(--text-hi); }
.bm-tree-row.is-active {
  background: rgba(var(--primary-rgb, 127,13,242), 0.12);
  color: var(--color-primary);
}
.bm-tree-row > .material-symbols-outlined {
  font-size: 15px; flex-shrink: 0;
}
.bm-tree-row.is-active > .material-symbols-outlined { color: var(--color-primary); }
.bm-tree-indent { flex-shrink: 0; }
.bm-tree-toggle {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  transition: transform 120ms;
  flex-shrink: 0;
}
.bm-tree-toggle:hover { background: rgba(0,0,0,0.1); color: var(--text-hi); }
.bm-tree-toggle.is-open { transform: rotate(90deg); }
.bm-tree-toggle-empty { width: 16px; }
.bm-tree-toggle .material-symbols-outlined { font-size: 14px; }
.bm-tree-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bm-tree-count {
  font-size: 10px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
  flex-shrink: 0;
}
.bm-tree-row.is-active .bm-tree-count { color: var(--color-primary); }

/* Hover actions on a folder row */
.bm-tree-actions {
  display: flex; gap: 2px;
  opacity: 0;
  margin-left: auto;
  transition: opacity 120ms;
}
.bm-tree-row:hover .bm-tree-actions { opacity: 1; }
.bm-tree-row:hover .bm-tree-count { display: none; }
.bm-tree-action {
  width: 22px; height: 22px;
  background: transparent; border: 0; cursor: pointer;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.bm-tree-action:hover {
  color: var(--text-hi);
  background: rgba(0,0,0,0.15);
}
.bm-tree-action.danger:hover { color: var(--color-error); background: rgba(248,113,113,0.1); }
.bm-tree-action .material-symbols-outlined { font-size: 14px; }
html.light .bm-tree-action:hover { background: rgba(0,0,0,0.06); }

/* Content area */
.bm-content {
  overflow-y: auto;
  padding: 18px 22px 28px;
  min-height: 0;
}

/* List layout */
.bm-list { display: flex; flex-direction: column; gap: 4px; }
.bm-list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color 120ms, background 120ms;
  position: relative;
}
.bm-list-row:hover {
  border-color: rgba(var(--primary-rgb, 127,13,242), 0.4);
  background: rgba(var(--primary-rgb, 127,13,242), 0.03);
}
.bm-list-favicon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.bm-list-favicon img { width: 20px; height: 20px; position: relative; z-index: 1; }
.bm-list-favicon .material-symbols-outlined { position: absolute; font-size: 14px; color: var(--text-muted); }
.bm-list-main { flex: 1; min-width: 0; }
.bm-list-title {
  font-size: 13.5px; font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bm-list-url {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.bm-list-tags {
  display: flex; gap: 6px; flex-wrap: nowrap;
  font-size: 10px;
  flex-shrink: 0;
}

/* Compact layout (dense single-line rows) */
.bm-compact {
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}
.bm-compact-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 7px 14px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--color-border);
  transition: background 120ms;
  position: relative;
}
.bm-compact-row:last-child { border-bottom: 0; }
.bm-compact-row:hover { background: rgba(var(--primary-rgb, 127,13,242), 0.06); }
.bm-compact-favicon { width: 16px; height: 16px; border-radius: 3px; }
.bm-compact-title {
  font-size: 13px; font-weight: 500;
  color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bm-compact-url {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: ui-monospace, Menlo, monospace;
}
.bm-compact-folder {
  font-size: 10px; color: var(--text-lo);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb, 127,13,242), 0.08);
  white-space: nowrap;
}

/* Pin + delete buttons for list / compact rows */
.bm-row-pin, .bm-row-del {
  opacity: 0;
  flex-shrink: 0;
}
.bm-list-row:hover .bm-row-pin,
.bm-list-row:hover .bm-row-del,
.bm-compact-row:hover .bm-row-pin,
.bm-compact-row:hover .bm-row-del { opacity: 1; }
.bm-list-row .pin-btn.is-pinned,
.bm-compact-row .pin-btn.is-pinned { opacity: 1; }

/* Hide the old folders bar (kept as no-op) */
.bm-folders-bar { display: none; }

/* Tag cloud in the tree pane */
.bm-tree-head-tags {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px;
  margin-top: 8px;
  border-top: 1px solid var(--color-border);
}
.bm-tag-clear {
  font-family: inherit;
  font-size: 10px; font-weight: 600;
  color: var(--color-primary);
  background: transparent; border: 0;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: none; letter-spacing: 0;
}
.bm-tag-clear:hover { background: rgba(var(--primary-rgb, 127,13,242), 0.08); }

.bm-tag-cloud {
  display: flex; flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px 8px;
}
.bm-tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  font-size: 11px;
  color: var(--text-md);
  transition: all 120ms;
}
.bm-tag-chip:hover {
  border-color: rgba(var(--primary-rgb, 127,13,242), 0.4);
  color: var(--text-hi);
}
.bm-tag-chip.is-active {
  background: rgba(var(--primary-rgb, 127,13,242), 0.12);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.bm-tag-count {
  font-size: 9px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.bm-tag-chip.is-active .bm-tag-count { color: var(--color-primary); }

/* Tighten grid (since it's now inside content area) */
.bm-tool .bm-grid {
  padding: 0;
}
