/* ---- History sidebar (docked, collapsible — mirrors agent-panel.css) --- */
/* Lives in the flex row alongside `.docx-editor-main-column`
   (base/layout.css), so opening it shrinks the editor's available width
   instead of overlaying/dimming it — no backdrop, unlike the old drawer. */

.docx-editor-history-sidebar {
  position: relative;
  flex: 0 0 var(--de-history-width, 320px);
  width: var(--de-history-width, 320px);
  min-width: 260px;
  max-width: 480px;
  background: var(--de-surface);
  border-left: 1px solid var(--de-border-raw);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: flex-basis 220ms ease, width 220ms ease, opacity 220ms ease;
  flex-shrink: 0;
}
.docx-editor-history-sidebar[data-closed="true"] {
  flex-basis: 0 !important;
  width: 0 !important;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
  border-left-color: transparent;
}

.docx-editor-history-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--de-border-raw);
  flex-shrink: 0;
}
.docx-editor-history-sidebar__title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--de-text);
  margin: 0;
}
.docx-editor-history-sidebar__close {
  border: none;
  background: transparent;
  color: var(--de-text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: flex;
  transition: background 120ms ease, color 120ms ease;
}
.docx-editor-history-sidebar__close:hover {
  background: var(--de-surface-hover);
  color: var(--de-text);
}

.docx-editor-history-sidebar__body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.docx-editor-history-sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
}

.docx-editor-history-sidebar__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 20px;
  text-align: center;
  color: var(--de-text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.docx-editor-history-sidebar__empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--de-surface-hover);
  color: var(--de-text-muted);
}

/* ---- Diff view mode banner ------------------------------------------ */
/* Shown while an entry's diff is pinned (HistoryEntryRow's eye toggle) so
   it stays visible while the user scrolls, instead of only on hover. */

.docx-editor-history-sidebar__diff-mode-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 10px 0;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 10px;
  flex-shrink: 0;
}
.docx-editor-history-sidebar__diff-mode-banner-icon {
  flex-shrink: 0;
  display: flex;
  color: #2563eb;
}
.docx-editor-history-sidebar__diff-mode-banner span {
  flex: 1;
  font-weight: 500;
}
.docx-editor-history-sidebar__diff-mode-banner button {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 9px;
  border-radius: 7px;
  flex-shrink: 0;
  transition: background 120ms ease;
}
.docx-editor-history-sidebar__diff-mode-banner button:hover {
  background: rgba(37, 99, 235, 0.22);
}

/* ---- Entry card ------------------------------------------------------ */

.docx-editor-history-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: transparent;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.docx-editor-history-entry:hover {
  background: var(--de-surface);
  border-color: var(--de-border-raw);
  box-shadow: var(--de-card-shadow, 0 1px 3px rgba(0, 0, 0, 0.08));
}
.docx-editor-history-entry--pinned {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.35);
}
.docx-editor-history-entry--pinned:hover {
  background: rgba(37, 99, 235, 0.08);
}

.docx-editor-history-entry__badge {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.docx-editor-history-entry__badge--user { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
.docx-editor-history-entry__badge--agent { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.docx-editor-history-entry__badge--restore { background: rgba(5, 150, 105, 0.12); color: #059669; }

.docx-editor-history-entry__body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}
.docx-editor-history-entry__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--de-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.docx-editor-history-entry__timestamp {
  font-size: 11px;
  color: var(--de-text-muted);
  margin-top: 2px;
}

.docx-editor-history-entry__diff-toggle {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--de-text-muted);
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}
.docx-editor-history-entry:hover .docx-editor-history-entry__diff-toggle,
.docx-editor-history-entry__diff-toggle--active {
  opacity: 1;
}
.docx-editor-history-entry__diff-toggle:hover {
  background: var(--de-surface-hover);
  color: var(--de-text);
}
.docx-editor-history-entry__diff-toggle--active {
  background: #2563eb;
  color: #fff;
}
.docx-editor-history-entry__diff-toggle--active:hover {
  background: #1d4ed8;
}

.docx-editor-history-entry:hover .docx-editor-history-entry__delete-toggle {
  opacity: 1;
}
.docx-editor-history-entry__delete-toggle:hover {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.docx-editor-history-entry__confirm {
  position: absolute;
  inset: 0;
  background: var(--de-surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  z-index: 1;
}
.docx-editor-history-entry__confirm-text {
  flex: 1;
  font-size: 12px;
  color: var(--de-text);
}
.docx-editor-history-entry__confirm-btn {
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--de-border-raw);
  background: var(--de-surface);
  color: var(--de-text);
  transition: background 120ms ease, border-color 120ms ease;
}
.docx-editor-history-entry__confirm-btn:hover {
  background: var(--de-surface-hover);
}
.docx-editor-history-entry__confirm-btn--primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.docx-editor-history-entry__confirm-btn--primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}
.docx-editor-history-entry__confirm-btn--danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.docx-editor-history-entry__confirm-btn--danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
