/* =========================================
 * collectable_new.css
 * - Modern 合集 / pin UI
 * - Theme-aware (uses sf.css variables)
 * - Hides legacy button UI
 * ======================================= */

/* Hide old inline buttons but keep their data attributes for JS */
.collectable,
.funcpin {
  display: none !important;
}

/* =========================================================
 * Topbar button active states
 * ======================================================= */

.topbar-btn.is-active {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-text);
}

.topbar-btn.is-active i {
  color: var(--color-accent);
}

/* Slight highlight even when not fully active (hover/ focus) */
.topbar-btn[data-action="favorite"]:hover i,
.topbar-btn[data-action="pin"]:hover i {
  filter: brightness(1.1);
}

/* =========================================================
 * Collect panel (overlay)
 * Similar in spirit to #cdn-panel / console, but simpler
 * ======================================================= */

#collect-panel.collect-panel {
  position: fixed;
  inset: 0;
  z-index: 80; /* above layout and comments, below console (1100) */
  display: none; /* toggled via .is-open */
  align-items: center;
  justify-content: center;
  pointer-events: none; /* shell has pointer-events: auto */
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-text);
}

#collect-panel.collect-panel.is-open {
  display: flex;
}

#collect-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

/* Shell */

#collect-panel-shell.collect-shell {
  position: relative;
  pointer-events: auto;
  width: min(720px, 100% - 16px);
  max-height: min(520px, 100% - 24px);
  background: var(--color-bg-elevated);
  border-radius: 12px;
  border: 1px solid var(--color-border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================
 * Header
 * ======================================================= */

.collect-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  background: radial-gradient(
    circle at top left,
    var(--color-bg-elevated),
    var(--color-bg)
  );
}

.collect-header-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.collect-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.collect-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collect-header-actions {
  display: flex;
  gap: 4px;
}

.collect-close-btn {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.collect-close-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
}

/* =========================================================
 * Body layout
 * ======================================================= */

.collect-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px 10px;
  background: var(--color-bg);
  min-height: 0;
}

.collect-column {
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: radial-gradient(
    circle at top left,
    var(--color-bg-elevated),
    var(--color-bg)
  );
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Column header */

.collect-column-header {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.collect-column-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
}

.collect-column-meta {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* Column body */

.collect-column-body {
  flex: 1;
  padding: 6px 8px 8px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* =========================================================
 * Left column: 可选合集列表
 * ======================================================= */

.collect-empty-hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.collect-collection-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.collect-collection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--color-bg-elevated);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
}

.collect-collection-item:hover {
  border-color: var(--color-accent);
}

.collect-collection-item input[type="checkbox"] {
  margin: 0;
  flex: 0 0 auto;
}

.collect-collection-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.collect-collection-name {
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collect-collection-extra {
  font-size: 11px;
  color: var(--color-text-muted);
}

.collect-collection-link {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--color-info);
  text-decoration: none;
  white-space: nowrap;
}

.collect-collection-link:hover {
  text-decoration: underline;
}

/* Create button inline in header */

.collect-new-btn {
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.collect-new-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

/* =========================================================
 * Right column: 收藏记录 (this work’s collections)
 * ======================================================= */

.collect-history-refresh-btn {
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.collect-history-refresh-btn:hover {
  border-color: var(--color-info);
  color: var(--color-text);
}

.collect-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.collect-history-card {
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}

.collect-history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.collect-history-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collect-history-link {
  font-size: 11px;
  color: var(--color-info);
  text-decoration: none;
  flex: 0 0 auto;
}

.collect-history-link:hover {
  text-decoration: underline;
}

.collect-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--color-text-muted);
}

.collect-tag-pill {
  border-radius: 999px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.24);
  font-size: 10px;
}

/* Loading + empty */

.collect-history-empty {
  font-size: 12px;
  color: var(--color-text-muted);
}

.collect-history-loading {
  font-size: 12px;
  color: var(--color-info);
}

/* =========================================================
 * Footer buttons
 * ======================================================= */

.collect-footer {
  padding: 6px 10px 8px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  background: linear-gradient(
    to bottom,
    var(--color-bg-elevated),
    var(--color-bg)
  );
}

.collect-footer-btn {
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}

.collect-footer-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.collect-footer-btn-primary {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  color: var(--color-text);
  font-weight: 600;
}

/* =========================================================
 * Mobile
 * ======================================================= */

@media (max-width: 720px) {
  #collect-panel-shell.collect-shell {
    width: calc(100% - 8px);
    max-height: calc(100% - 8px);
    border-radius: 10px;
  }

  .collect-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding-inline: 8px;
  }

  .collect-column {
    min-height: 0;
  }
}