/**
 * Version History Styles
 * Git-style timeline and diff viewer
 */

/* Version History Container */
.version-history-container {
  display: flex;
  gap: 20px;
  min-height: 600px;
  max-height: 70vh;
}

/* Timeline Section */
.timeline-section {
  flex: 1;
  max-width: 400px;
  overflow-y: auto;
  padding-right: 10px;
}

.timeline-section .section-header {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg);
  padding: 10px 0;
  margin-bottom: 15px;
  border-bottom: 2px solid var(--bs-border-color);
  z-index: 10;
}

.version-stats {
  margin-top: 8px;
}

/* Version Timeline */
.version-timeline {
  position: relative;
  padding-left: 30px;
}

.version-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--bs-border-color);
}

/* Timeline Item */
.timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding: 15px;
  background: var(--bs-body-bg);
  border: 2px solid var(--bs-border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.timeline-item:hover {
  border-color: var(--bs-primary);
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.timeline-item.selected-version {
  border-color: var(--bs-warning);
  background: rgba(var(--bs-warning-rgb), 0.1);
}

.timeline-item.selected-version::after {
  content: attr(data-marker);
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--bs-warning);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
}

/* Timeline Marker */
.timeline-marker {
  position: absolute;
  left: -25px;
  top: 15px;
  width: 24px;
  height: 24px;
  background: var(--bs-secondary);
  border: 2px solid var(--bs-border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  color: white;
  font-size: 10px;
}

.timeline-marker.current {
  background: var(--bs-success);
  border-color: var(--bs-success);
  box-shadow: 0 0 0 3px rgba(var(--bs-success-rgb), 0.2);
  animation: pulse 2s infinite;
}

/* Version Header */
.version-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.version-id {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--bs-primary);
  background: rgba(var(--bs-primary-rgb), 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Version Meta */
.version-meta {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: var(--bs-secondary);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.version-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.version-meta i {
  opacity: 0.7;
}

/* Version Message */
.version-message {
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.5;
  color: var(--bs-body-color);
}

/* Version Actions */
.version-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Diff Viewer Section */
.diff-viewer-section {
  flex: 2;
  border-left: 2px solid var(--bs-border-color);
  padding-left: 20px;
  overflow-y: auto;
}

.diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  background: var(--bs-body-bg);
  z-index: 10;
}

.diff-header h6 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Diff Section */
.diff-section {
  margin-bottom: 25px;
}

.diff-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 15px;
  background: var(--bs-secondary-bg);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.diff-section-title .badge {
  font-size: 11px;
  padding: 3px 8px;
}

.diff-editor {
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  overflow: hidden;
}

/* Simple Diff Fallback */
.simple-diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  background: var(--bs-body-bg);
}

.simple-diff > div {
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

.diff-before {
  background: rgba(var(--bs-danger-rgb), 0.1);
  border-left: 3px solid var(--bs-danger);
}

.diff-after {
  background: rgba(var(--bs-success-rgb), 0.1);
  border-left: 3px solid var(--bs-success);
}

.simple-diff pre {
  margin: 8px 0 0 0;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.simple-diff strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

/* Responsive Design */
@media (max-width: 992px) {
  .version-history-container {
    flex-direction: column;
  }

  .timeline-section {
    max-width: 100%;
    max-height: 300px;
  }

  .diff-viewer-section {
    border-left: none;
    border-top: 2px solid var(--bs-border-color);
    padding-left: 0;
    padding-top: 20px;
  }

  .simple-diff {
    grid-template-columns: 1fr;
  }
}

/* Dark Theme Support */
body[data-theme="dark"] .timeline-item {
  background: var(--bg-secondary);
}

body[data-theme="dark"] .timeline-item:hover {
  background: var(--hover-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body[data-theme="dark"] .version-timeline::before {
  background: var(--border);
}

/* Loading State */
.version-history-container .loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--bs-secondary);
}

.version-history-container .loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid var(--bs-border-color);
  border-top-color: var(--bs-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Empty State */
.version-history-container .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--bs-secondary);
  text-align: center;
  padding: 40px 20px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}
