/* ============================================================
   Trash view + Version history
   Scoped to .trash-root and .history-overlay / .history-modal.
   Reuses css/style.css custom properties (fallbacks provided).
   ============================================================ */

/* ------------------------------ Trash ------------------------------ */
.trash-root {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 56px 80px;
  color: var(--text, #37352f);
}
.trash-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.trash-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text, #37352f);
}
.trash-count {
  font-size: 14px;
  color: var(--text-faint, #9b9a97);
}
.trash-empty { margin-left: auto; }

.trash-searchbar { margin-bottom: 14px; }
.trash-search {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  font-family: var(--font, sans-serif);
  color: var(--text, #37352f);
  background: var(--bg-hover, rgba(0, 0, 0, 0.045));
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
.trash-search:focus {
  border-color: var(--accent, #5b5bd6);
  background: var(--bg-input, #fff);
}
.trash-search::placeholder { color: var(--text-placeholder, rgba(55, 53, 47, 0.35)); }

.trash-list { margin-top: 4px; }
.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border, #e9e9e7);
}
.trash-row:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); }
.trash-ic {
  width: 26px;
  flex: 0 0 26px;
  text-align: center;
  font-size: 18px;
  line-height: 1;
}
.trash-info { flex: 1; min-width: 0; cursor: pointer; }
.trash-name {
  font-size: 15px;
  color: var(--text, #37352f);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trash-info:hover .trash-name { text-decoration: underline; }
.trash-when {
  font-size: 12.5px;
  color: var(--text-faint, #9b9a97);
  margin-top: 1px;
}
.trash-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.trash-blank {
  padding: 48px 8px;
  text-align: center;
  color: var(--text-faint, #9b9a97);
  font-size: 14px;
}

/* shared small buttons (trash) */
.trash-btn {
  font-family: var(--font, sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong, #d3d3d1);
  background: var(--bg, #fff);
  color: var(--text-light, #787774);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.trash-btn:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); color: var(--text, #37352f); }
.trash-btn:disabled { opacity: 0.5; cursor: default; }
.trash-btn-restore:hover {
  border-color: var(--accent, #5b5bd6);
  color: var(--accent, #5b5bd6);
}
.trash-btn-danger { color: var(--danger, #eb5757); }
.trash-btn-danger:hover {
  background: rgba(235, 87, 87, 0.1);
  color: var(--danger, #eb5757);
  border-color: var(--danger, #eb5757);
}
.trash-btn.armed {
  background: var(--danger, #eb5757);
  border-color: var(--danger, #eb5757);
  color: #fff;
}

@media (max-width: 720px) {
  .trash-root { padding: 24px 18px 60px; }
}

/* --------------------------- Version history --------------------------- */
.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(15, 15, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.history-modal {
  display: flex;
  width: 900px;
  max-width: 100%;
  height: 80vh;
  max-height: 720px;
  background: var(--bg-modal, #fff);
  color: var(--text, #37352f);
  border-radius: 10px;
  box-shadow: var(--shadow-popover, rgba(15, 15, 15, 0.2) 0 9px 24px);
  overflow: hidden;
  animation: history-in 0.12s ease;
}
@keyframes history-in { from { opacity: 0; transform: scale(0.985); } }

.history-side {
  width: 268px;
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border, #e9e9e7);
  background: var(--bg-sidebar, #f7f7f5);
}
.history-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 10px 16px;
}
.history-title { font-size: 15px; font-weight: 600; color: var(--text, #37352f); }
.history-x {
  width: 26px; height: 26px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-light, #787774);
}
.history-x:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); color: var(--text, #37352f); }

.history-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; }
.history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text, #37352f);
}
.history-item:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); }
.history-item.active { background: var(--bg-active, rgba(0, 0, 0, 0.08)); }
.history-item-when { font-size: 13.5px; font-weight: 500; }
.history-item-name {
  font-size: 12px;
  color: var(--text-faint, #9b9a97);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* who produced this snapshot (owner or collaborator) */
.history-item-by { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.history-item-av {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 8.5px; font-weight: 700; text-transform: uppercase;
  font-family: var(--font-display, sans-serif);
}
.history-item-who {
  font-size: 11.5px; color: var(--text-light, #787774);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-readonly-note { font-size: 12.5px; color: var(--text-faint, #9b9a97); font-style: italic; }
.history-empty {
  padding: 30px 12px;
  text-align: center;
  color: var(--text-faint, #9b9a97);
  font-size: 13.5px;
}

.history-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-main-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border, #e9e9e7);
  min-height: 54px;
}
.history-when { font-size: 13.5px; color: var(--text-light, #787774); }
.history-main-actions { margin-left: auto; display: flex; gap: 8px; }

.history-btn {
  font-family: var(--font, sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong, #d3d3d1);
  background: var(--bg, #fff);
  color: var(--text-light, #787774);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.history-btn:hover { background: var(--bg-hover, rgba(0, 0, 0, 0.045)); color: var(--text, #37352f); }
.history-btn:disabled { opacity: 0.5; cursor: default; }
.history-btn-primary {
  background: var(--accent, #5b5bd6);
  border-color: var(--accent, #5b5bd6);
  color: #fff;
}
.history-btn-primary:hover { background: var(--accent-hover, #0077d4); color: #fff; }
.history-btn-danger { color: var(--danger, #eb5757); }
.history-btn-danger:hover { background: rgba(235, 87, 87, 0.1); color: var(--danger, #eb5757); border-color: var(--danger, #eb5757); }
.history-btn-danger.armed { background: var(--danger, #eb5757); border-color: var(--danger, #eb5757); color: #fff; }

/* ---- read-only block preview (hv- = history view) ---- */
.history-preview {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px 60px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text, #37352f);
}
.hv-blank, .hv-muted {
  color: var(--text-faint, #9b9a97);
  font-size: 14px;
  font-style: italic;
}
.hv-blank { padding: 40px 4px; text-align: center; }
.hv-p { padding: 3px 0; word-break: break-word; }
.hv-empty { color: var(--text-placeholder, rgba(55, 53, 47, 0.35)); }
.hv-h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 22px 0 4px; letter-spacing: -0.4px; }
.hv-h2 { font-size: 22px; font-weight: 600; line-height: 1.3; margin: 16px 0 3px; }
.hv-h3 { font-size: 18px; font-weight: 600; line-height: 1.3; margin: 12px 0 2px; }
.hv-h1:first-child, .hv-h2:first-child, .hv-h3:first-child { margin-top: 0; }
.hv-row { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
.hv-row > div { flex: 1; min-width: 0; word-break: break-word; }
.hv-bul { width: 18px; text-align: center; flex: 0 0 18px; }
.hv-num { min-width: 20px; flex: 0 0 auto; color: var(--text, #37352f); }
.hv-tri { color: var(--text-faint, #9b9a97); font-size: 11px; line-height: 1.7; flex: 0 0 14px; }
.hv-check { flex: 0 0 18px; }
.hv-todo.done > div { color: var(--text-faint, #9b9a97); text-decoration: line-through; }
.hv-quote {
  border-left: 3px solid var(--text, #37352f);
  padding: 2px 0 2px 14px;
  margin: 6px 0;
  word-break: break-word;
}
.hv-callout {
  display: flex;
  gap: 10px;
  background: var(--bg-callout, #f1f1ef);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 6px 0;
}
.hv-callout-ic { flex: 0 0 auto; }
.hv-code {
  background: var(--bg-code, #f7f6f3);
  border: 1px solid var(--border, #e9e9e7);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 6px 0;
  overflow-x: auto;
}
.hv-code code {
  font-family: var(--font-mono, monospace);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre;
  color: var(--text, #37352f);
}
.hv-hr { border: none; height: 1px; background: var(--border-strong, #d3d3d1); margin: 14px 0; }
.hv-tablewrap { overflow-x: auto; margin: 6px 0; }
.hv-table { border-collapse: collapse; }
.hv-th, .hv-td {
  border: 1px solid var(--border, #e9e9e7);
  padding: 6px 9px;
  font-size: 14px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.hv-th { font-weight: 600; background: var(--bg-code, #f7f6f3); }
.hv-cols { display: flex; gap: 16px; margin: 6px 0; }
.hv-col { flex: 1 1 0; min-width: 0; word-break: break-word; }
.history-preview code {
  font-family: var(--font-mono, monospace);
  font-size: 85%;
  background: var(--bg-code, #f7f6f3);
  padding: 1px 4px;
  border-radius: 3px;
}
.history-preview a { color: var(--text-light, #787774); text-decoration: underline; }

@media (max-width: 720px) {
  .history-modal { flex-direction: column; height: 88vh; }
  .history-side { width: 100%; flex-basis: auto; height: 190px; border-right: none; border-bottom: 1px solid var(--border, #e9e9e7); }
}
