/* ═══════════════════════════════════════════════════════════════
   History Tab
   ═══════════════════════════════════════════════════════════════ */

.history-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.history-header h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: var(--fg);
}

.history-header p {
  margin: 0;
  color: var(--muted-fg);
  font-size: 0.9rem;
}


.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--muted);
  padding: 14px;
}

.history-card-main {
  min-width: 0;
  flex: 1;
}

.history-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.history-task-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  color: var(--fg);
}

.history-status-badge {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-completed {
  background: rgba(39, 201, 63, 0.12);
  color: var(--success);
}

.status-running,
.status-uploaded {
  background: var(--accent-light);
  color: var(--accent);
}

.status-failed {
  background: rgba(255, 95, 86, 0.12);
  color: var(--error);
}

.history-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.history-meta-grid span {
  display: block;
  color: var(--muted-fg);
  font-size: 0.76rem;
  margin-bottom: 2px;
}

.history-meta-grid strong {
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 500;
}

.history-file-line,
.history-error,
.history-empty,
.history-no-result {
  color: var(--muted-fg);
  font-size: 0.86rem;
  line-height: 1.6;
}

.history-error {
  color: var(--error);
  margin-top: 6px;
}

.history-empty {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}

.history-empty.error {
  color: var(--error);
}

.history-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.history-download-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.history-download {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-download svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.history-download-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted-fg);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .history-header,
  .history-card {
    flex-direction: column;
  }

  .history-filters,
  .history-meta-grid {
    grid-template-columns: 1fr;
  }

  .history-actions {
    align-items: stretch;
  }
}
