:root {
  --bg: #0f1115;
  --panel: #131722;
  --text: #e6e9ef;
  --muted: #98a2b3;
  --accent: #7c9aff;
  --accent-2: #59d3a0;
  --danger: #ff6b6b;
  --border: #1f2430;
  --global-rollback-height: 120px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.app-header {
  padding: 16px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.app-header h1 { margin: 0 0 6px; font-size: 20px; }
.app-header p { margin: 0; color: var(--muted); }

.uploader {
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  border: none;
}

#zipInput { display: none; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 18px 24px;
  min-width: 240px;
  text-align: center;
  color: var(--muted);
  outline: none;
}
.dropzone.dragover { border-color: var(--accent-2); color: var(--accent-2); }

.summary {
  padding: 8px 20px;
  color: var(--muted);
}



/* Global Rollback Section Styling */
.global-rollback {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 200;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}
.global-rollback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.global-rollback-header h3 {
  margin: 0;
  font-size: 16px;
  color: var(--accent);
}
.selection-count {
  font-size: 12px;
  color: var(--muted);
  background: rgba(124, 154, 255, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.global-rollback-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.global-git-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.global-git-code {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  max-height: 120px;
  overflow-y: auto;
}
.global-git-command {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 12px;
  color: var(--accent);
  background: transparent;
  border: none;
  outline: none;
  word-break: break-all;
  line-height: 1.4;
}
.global-copy-button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}
.global-copy-button:hover:not(:disabled) {
  background: #6b8fff;
}
.global-copy-button:disabled {
  background: var(--muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.results {
  padding: 6px 12px calc(var(--global-rollback-height) + 60px);
  display: block;
}

.group {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
  margin-bottom: 16px;
  position: relative;
}

.group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--panel) 0%, #1a1f2e 100%);
  border-bottom: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
  position: sticky;
  top: 8px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
}

.group > summary:hover {
  background: linear-gradient(135deg, #1a1f2e 0%, #202534 100%);
}

.group > summary::-webkit-details-marker { display: none; }

.group > summary::before {
  content: '▶';
  font-size: 12px;
  color: var(--accent);
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.group[open] > summary::before {
  transform: rotate(90deg);
}

.group .reason {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  flex: 1;
}

.group .count {
  color: var(--muted);
  font-size: 12px;
  background: rgba(124, 154, 255, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 500;
}

/* Group Actions Container */
.group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* Group Button Base Styling */
.group-rollback-all-button,
.group-keep-all-button,
.group-deselect-all-button {
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Group Rollback All Button */
.group-rollback-all-button {
  background: var(--accent);
  color: var(--bg);
}
.group-rollback-all-button:hover {
  background: #6b8fff;
}

/* Group Keep All Button */
.group-keep-all-button {
  background: var(--accent-2);
  color: var(--bg);
}
.group-keep-all-button:hover {
  background: #4fc084;
}

/* Group Deselect All Button */
.group-deselect-all-button {
  background: var(--muted);
  color: var(--bg);
}
.group-deselect-all-button:hover {
  background: #8a94a6;
}

/* Group Button Checkboxes */
.group-rollback-checkbox,
.group-keep-checkbox,
.group-deselect-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  pointer-events: none; /* Prevent checkbox from interfering with button clicks */
}

.group-rollback-checkbox {
  accent-color: white;
}
.group-keep-checkbox {
  accent-color: white;
}
.group-deselect-checkbox {
  accent-color: white;
}

/* Group State Visual Indicators */
.group.fully-reviewed {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(89, 211, 160, 0.3);
}

.group.fully-reviewed > summary {
  background: linear-gradient(135deg, rgba(89, 211, 160, 0.1) 0%, rgba(89, 211, 160, 0.05) 100%);
  border-left: 4px solid var(--accent-2);
}

.group.fully-reviewed > summary::before {
  color: var(--accent-2);
}

.group.fully-reviewed .reason {
  color: var(--accent-2);
}

.group.fully-rollback {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(124, 154, 255, 0.3);
}

.group.fully-rollback > summary {
  background: linear-gradient(135deg, rgba(124, 154, 255, 0.1) 0%, rgba(124, 154, 255, 0.05) 100%);
  border-left: 4px solid var(--accent);
}

.group.fully-rollback > summary::before {
  color: var(--accent);
}

.group.fully-rollback .reason {
  color: var(--accent);
}

.group.mixed-state {
  border-color: #ff9500;
  box-shadow: 0 0 0 1px rgba(255, 149, 0, 0.3);
}

.group.mixed-state > summary {
  background: linear-gradient(135deg, rgba(255, 149, 0, 0.1) 0%, rgba(255, 149, 0, 0.05) 100%);
  border-left: 4px solid #ff9500;
}

.group.mixed-state > summary::before {
  color: #ff9500;
}

.group.mixed-state .reason {
  color: #ff9500;
}

/* Add completion indicator to group summary */
.group.fully-reviewed > summary::after,
.group.fully-rollback > summary::after,
.group.mixed-state > summary::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

.group.fully-reviewed > summary::after {
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(89, 211, 160, 0.4);
}

.group.fully-rollback > summary::after {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(124, 154, 255, 0.4);
}

.group.mixed-state > summary::after {
  background: #ff9500;
  box-shadow: 0 0 8px rgba(255, 149, 0, 0.4);
}

/* Groups with unmarked items - needs attention */
.group.partially-processed {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.2);
  animation: pulse-attention 3s ease-in-out infinite;
}

.group.partially-processed > summary {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.08) 0%, rgba(255, 107, 107, 0.03) 100%);
  border-left: 4px solid var(--danger);
}

.group.partially-processed > summary::before {
  color: var(--danger);
}

.group.partially-processed .reason {
  color: var(--danger);
}

.group.partially-processed > summary::after {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
  animation: pulse-dot 2s ease-in-out infinite;
}

/* Progress indicator for groups */
.group-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 500;
}

.progress-text {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  min-width: 28px;
  text-align: center;
}

.group.partially-processed .group-progress {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.1);
}

.group.fully-reviewed .group-progress {
  color: var(--accent-2);
  background: rgba(89, 211, 160, 0.1);
}

.group.fully-rollback .group-progress {
  color: var(--accent);
  background: rgba(124, 154, 255, 0.1);
}

.group.mixed-state .group-progress {
  color: #ff9500;
  background: rgba(255, 149, 0, 0.1);
}

/* Progress bar within the indicator */
.progress-bar {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: width 0.3s ease;
  position: relative;
}

.group.partially-processed .progress-fill {
  background: var(--danger);
}

.group.fully-reviewed .progress-fill {
  background: var(--accent-2);
}

.group.fully-rollback .progress-fill {
  background: var(--accent);
}

.group.mixed-state .progress-fill {
  background: #ff9500;
}

/* Subtle animations for attention */
@keyframes pulse-attention {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.2);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.4);
  }
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
  }
  50% {
    box-shadow: 0 0 12px rgba(255, 107, 107, 0.6);
  }
}



.group .items {
  padding: 16px;
  background: var(--bg);
  border-radius: 0 0 10px 10px;
  position: relative;
}

.item {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  position: relative;
  margin-bottom: 12px;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.item:last-child { margin-bottom: 0; }

.item:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(124, 154, 255, 0.3);
}

.item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.3;
  border-radius: 0 0 0 8px;
  transition: background-color 0.3s ease, opacity 0.3s ease;
}

/* Collapsed Item Styling */
.item.collapsed {
  max-height: 60px;
  overflow: hidden;
  opacity: 0.7;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.item.collapsed:hover {
  opacity: 0.9;
}

/* Temporarily expanded collapsed item */
.item.collapsed.expanded {
  max-height: none;
  overflow: visible;
  opacity: 0.95;
}

/* Hide detailed content when collapsed (but not when expanded) */
.item.collapsed:not(.expanded) .failure-stats,
.item.collapsed:not(.expanded) .screenshots,
.item.collapsed:not(.expanded) .git-revert-section {
  display: none;
}

/* Visual cue for clickable collapsed items */
.item.collapsed .item-header {
  position: relative;
}

.item.collapsed .item-header::before {
  content: '👁 ';
  font-size: 14px;
  opacity: 0.6;
  pointer-events: none;
  margin-right: 6px;
}

.item.collapsed.expanded .item-header::before {
  content: '🔽 ';
}

/* State-specific accent colors */
.item.reviewed::before {
  background: var(--accent-2);
  opacity: 0.6;
}

.item.rollback::before {
  background: var(--accent);
  opacity: 0.8;
}

/* Collapsed item summary styling */
.item.collapsed .item-header {
  margin-bottom: 0;
}

.item.collapsed .test-name {
  font-size: 13px;
  opacity: 0.8;
}

.item.collapsed .meta {
  font-size: 11px;
  opacity: 0.6;
}

.item-header {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.item-header .titles {
  flex: 1;
}
.item .test-name {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 15px;
  color: var(--text);
}
.item .meta {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

/* Checkbox Container Styling */
.item-checkboxes {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* Rollback Checkbox Styling */
.rollback-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rollback-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.rollback-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}

/* Reviewed Checkbox Styling */
.reviewed-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.reviewed-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-2);
  cursor: pointer;
}
.reviewed-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  cursor: pointer;
  user-select: none;
}

/* Failure Stats Styling */
.failure-stats { margin-bottom: 15px; }
.stats-item {
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.stats-grid { display: grid; gap: 6px; }
.stats-row { display: flex; align-items: center; gap: 8px; }
.stats-label {
  font-weight: 600;
  color: var(--accent);
  min-width: 80px;
  font-size: 12px;
}
.stats-value {
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  word-break: break-all;
}

/* Retry Dropdown Styling */
.retry-dropdown {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.retry-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  border-radius: 8px;
  background: var(--panel);
  transition: background-color 0.2s ease;
}
.retry-summary:hover {
  background: #1a1f2e;
}
.retry-summary::-webkit-details-marker {
  display: none;
}
.retry-content {
  padding: 0 8px 8px 8px;
}
.retry-stats-item {
  margin-bottom: 6px;
  background: #090b0f;
}

/* Failure Text Dropdown Styling */
.failure-text-dropdown {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.failure-text-summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  list-style: none;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.05);
  transition: background-color 0.2s ease;
  border-bottom: 1px solid transparent;
}
.failure-text-summary:hover {
  background: rgba(255, 107, 107, 0.1);
}

/* System Error specific styling */
.system-err-summary {
  color: #ff9500;
  background: rgba(255, 149, 0, 0.05);
}
.system-err-summary:hover {
  background: rgba(255, 149, 0, 0.1);
}

/* System Output specific styling */
.system-out-summary {
  color: var(--accent-2);
  background: rgba(89, 211, 160, 0.05);
}
.system-out-summary:hover {
  background: rgba(89, 211, 160, 0.1);
}
.failure-text-summary::-webkit-details-marker {
  display: none;
}
.failure-text-dropdown[open] .failure-text-summary {
  border-bottom-color: var(--border);
}
.failure-text-content {
  padding: 0;
}
.failure-text-pre {
  background: #0b0d12;
  margin: 0;
  padding: 12px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  font-family: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Git Revert Section Styling */
.git-revert-section {
  margin-top: 12px;
  padding: 12px;
  background: rgba(89, 211, 160, 0.05);
  border: 1px solid rgba(89, 211, 160, 0.2);
  border-radius: 8px;
}
.git-revert-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: 8px;
}
.git-revert-code {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0b0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
.git-command {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 12px;
  color: var(--accent-2);
  background: transparent;
  border: none;
  outline: none;
  word-break: break-all;
}
.git-copy-button {
  background: var(--accent-2);
  color: var(--bg);
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}
.git-copy-button:hover {
  background: #4fc084;
}

/* Screenshots Styling */
.screenshots {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.screenshot-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}
.screenshot-name {
  padding: 8px 10px;
  background: #0b0d12;
  font-size: 12px;
  color: var(--accent-2);
  font-family: ui-monospace, monospace;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.screenshot-image {
  width: 100%;
  display: block;
  background: #000;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.screenshot-image:hover {
  opacity: 0.9;
}

/* Screenshot Modal Styling */
.screenshot-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}
.modal-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  font-size: 24px;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.9);
}
.modal-image {
  max-width: 100%;
  max-height: calc(95vh - 60px);
  object-fit: contain;
  background: #000;
}
.modal-caption {
  padding: 12px 16px;
  background: var(--panel);
  color: var(--accent-2);
  font-family: ui-monospace, monospace;
  font-size: 14px;
  border-top: 1px solid var(--border);
}

.hidden { display: none !important; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #202534;
  color: var(--muted);
  font-size: 12px;
}

.danger { color: var(--danger); }


