/* ==========================================================
   09 - Panneau Historique (tiroir lateral)
   ========================================================== */

#historyModal {
  justify-content: flex-end;
  align-items: stretch;
}
.modal-panel-history {
  width: 500px;
  max-width: 90vw;
  max-height: 100vh;
  height: 100vh;
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  transform: translateX(100%);
  opacity: 1;
  transition: transform 0.32s var(--ease);
}
#historyModal.open .modal-panel-history {
  transform: translateX(0);
}

.history-search-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  color: var(--t4);
  flex-shrink: 0;
}
.history-search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--t1);
  outline: none;
}
.history-search-bar input::placeholder { color: var(--t4); }

.history-loading {
  padding: 32px;
  text-align: center;
  font-size: 13.5px;
  color: var(--t3);
}
.history-list {
  list-style: none;
  padding: 8px 0;
}
.history-item {
  display: flex;
  flex-direction: column;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  font-size: 13px;
  transition: border-left-color 0.18s, background 0.18s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--surface-2); }
.history-item.unseen { border-left-color: var(--blue); background: color-mix(in srgb, var(--blue) 3%, transparent); }
.history-item.unseen:hover { border-left-color: transparent; }
.history-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-changes {
  margin-top: 7px;
  padding: 9px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.history-change-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.history-change-row:last-child { border-bottom: none; }
.history-change-field {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.history-change-values { display: block; }
.history-change-inline {
  font-size: 12px;
  line-height: 1.65;
  word-break: break-word;
  color: var(--t1);
}
.diff-add {
  color: var(--green);
  background: var(--green-soft);
  border-radius: 4px;
  padding: 1px 4px;
  font-weight: 600;
}
.diff-del {
  color: var(--red);
  background: var(--red-soft);
  text-decoration: line-through;
  border-radius: 4px;
  padding: 1px 4px;
}

.history-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
  min-width: 90px;
  justify-content: center;
}
.history-action-create  { background: var(--green-soft); color: var(--green); }
.history-action-update  { background: var(--blue-soft);  color: var(--blue); }
.history-action-delete  { background: var(--red-soft);   color: var(--red); }
.history-action-restore { background: var(--orange-soft); color: var(--orange); }

.history-op-name {
  flex: 1;
  font-weight: 600;
  letter-spacing: -0.014em;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.history-op-name:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.history-op-name-maxxess,
.history-op-name-moto-axxe,
.history-op-name-both {
  flex: 0 1 auto;
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-weight: 700;
}
.history-op-name-maxxess {
  background: #ffed00;
  color: #191713;
}
.history-op-name-moto-axxe {
  background: var(--brand-axxe);
  color: #fff;
}
.history-op-name-both {
  background: linear-gradient(90deg, var(--brand-axxe) 50%, var(--brand-maxxess) 50%);
  color: #fff;
}
.history-op-name-maxxess:hover { color: #191713; text-decoration: underline; }
.history-op-name-moto-axxe:hover,
.history-op-name-both:hover { color: #fff; text-decoration: underline; }

.history-user {
  font-size: 11px;
  color: var(--t4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.history-date {
  font-size: 11.5px;
  color: var(--t3);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-restore-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
  border-radius: var(--r-full);
  background: var(--red-soft);
  color: var(--red);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.history-restore-btn:hover {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
}
.history-restore-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

.history-group-count {
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t4);
  flex-shrink: 0;
}
.history-item .history-changes + .history-changes,
.history-item .history-restore-btn + .history-changes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-2);
}
.history-change-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.history-change-inline-row:last-child { border-bottom: none; }
.history-change-inline-row .history-change-inline { flex: 1; }
.history-restore-btn-compact {
  margin-top: 0;
  padding: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-restore-btn-compact svg { width: 12px; height: 12px; }
