/* change-history.css
 *
 * Timeline styling for change history display.
 * Follows GitHub/Google Docs patterns for change history.
 */

/* ========================================
   History Tab Styling
   ======================================== */

.nav-link-history,
.nav-link-history.active {
  color: var(--text-light) !important;
}

/* ========================================
   Container
   ======================================== */

.history-container {
  padding: 1rem 0;
}

.history-empty {
  padding: 3rem 2rem;
  text-align: center;
  background: var(--hover-bg);
  border-radius: 0.5rem;
}

/* ========================================
   Timeline Structure
   ======================================== */

.history-timeline {
  /* Shared vertical line properties - used by entry and day-header segments */
  --line-left: -1.5rem;
  --line-width: 2px;
  --line-color: var(--border);
  position: relative;
  padding-left: 2rem;
}

/* Vertical line segments - shared base styles */
.history-entry::before,
.history-entry::after,
.history-day:not(:first-child) .history-day-header::before {
  content: '';
  position: absolute;
  left: var(--line-left);
  transform: translateX(-50%);
  width: var(--line-width);
  background: var(--line-color);
}

/* Entry: line above marker */
.history-entry::before {
  top: -1rem;
  height: 2rem;
}

/* Entry: line below marker */
.history-entry::after {
  top: 1.5rem;
  bottom: -1rem;
}

/* First entry of first day: no line above */
.history-day:first-child .history-entry:first-child::before {
  display: none;
}

/* Last entry (creation): no line below */
.history-entry-creation::after {
  display: none;
}

/* ========================================
   Day Groups
   ======================================== */

.history-day {
  margin-bottom: 1.5rem;
}

.history-day-header {
  position: relative;
  margin-bottom: 1rem;
  margin-left: -2rem;
  padding-left: 2rem;
  border: 1px solid transparent; /* Match entry border for line alignment */
}

/* Day header: line connecting through to bridge gap between days */
.history-day:not(:first-child) .history-day-header::before {
  /* Compensate for day-header's margin-left:-2rem */
  left: calc(var(--line-left) + 2rem);
  top: -0.75rem;
  bottom: -1rem;
}

.history-day-label {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-light);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 1rem;
}

/* ========================================
   Entry Items
   ======================================== */

.history-entry {
  position: relative;
  display: flex;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: box-shadow 0.15s ease;
}

.history-entry:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Entry marker (timeline dot) */
.history-entry-marker {
  position: absolute;
  left: -2rem;
  top: 1rem;
  width: 1rem;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.history-entry-marker i {
  font-size: 0.75rem;
  color: var(--text-light);
  padding: 0.125rem;
}

/* Latest entry (current state) - filled dot with accent border */
.history-entry-latest {
  border: 2px solid var(--border);
}

.history-entry-latest .history-entry-marker i {
  color: var(--line-color);
}

/* Entry content */
.history-entry-content {
  flex: 1;
  min-width: 0;
}

.history-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.history-chevron-btn {
  border: none;
  background: transparent;
  padding: 0.25rem;
  color: var(--text-light);
}

.history-chevron-btn[aria-expanded='true'] {
  transform: rotate(90deg);
}

.history-entry-time {
  color: var(--text-light);
  font-weight: 500;
}

.history-entry-separator {
  color: var(--text-light);
}

.history-entry-user {
  font-weight: 500;
  color: var(--text-heading);
}

/* Source badge */
.history-source-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
}

/* Summary text */
.history-entry-summary {
  font-size: 0.9375rem;
  color: var(--text);
  word-break: break-word;
}

/* Change reason (comment) */
.history-entry-reason {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-light);
}

.history-entry-reason em {
  font-style: italic;
}

/* ========================================
   Details Table
   ======================================== */

/* Changes table */
.history-changes-table {
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

.history-changes-table th {
  font-weight: 600;
  color: var(--text-light);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.history-changes-table td {
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}

.history-field-name {
  font-weight: 500;
  white-space: nowrap;
  width: 1%;
}

.history-before-value,
.history-after-value {
  word-break: break-word;
}

/* Column backgrounds for diff highlighting */
.history-changes-table .history-before-value {
  background-color: color-mix(in srgb, var(--danger) 10%, transparent);
}

.history-changes-table .history-after-value {
  background-color: color-mix(in srgb, var(--success) 10%, transparent);
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 576px) {
  .history-timeline {
    --line-left: -1.125rem;
    padding-left: 1.5rem;
  }

  .history-entry-marker {
    left: -1.5rem;
  }

  .history-day-header {
    margin-left: -1.5rem;
    padding-left: 1.5rem;
  }

  /* Adjust day-header line for mobile margin */
  .history-day:not(:first-child) .history-day-header::before {
    left: calc(var(--line-left) + 1.5rem);
  }

  .history-entry-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .history-entry-separator {
    display: none;
  }
}
