/* ---------- UPLOAD CARD ---------- */
.upload-card {
  max-width: 520px;
  margin: 0 auto 24px;
}

.upload-card form {
  display: flex;
  gap: 14px;
  flex-direction: column;
  align-items: center;
}

/* ---------- FILE INPUT ENHANCEMENTS ---------- */
.file-input-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.file-input {
  width: 240px;
  height: 160px;
  border: 2px dashed var(--border-light);
  border-radius: 12px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s ease;
}

.file-input:hover {
  background: #eef2ff;
  border-color: var(--brand);
}

.file-input.hidden {
  display: none;
}

.file-selected {
  width: 240px;
  height: 160px;
  border: 2px solid var(--brand);
  border-radius: 12px;
  background: #f0f4ff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  position: relative;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.file-name {
  font-weight: 600;
  color: var(--brand);
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
}

.file-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.1);
  color: #666;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.file-remove:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  transform: scale(1.1);
}

.file-icon {
  font-size: 24px;
}

.file-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.file-meta {
  margin-top: 8px;
  text-align: center;
}

#fileName {
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- ERROR MESSAGE ---------- */
#uploadError {
  color: var(--danger);
  font-weight: 600;
  font-size: 14px;
  min-height: 10px;
  line-height: 10px;
  text-align: center;
  margin-top: -10px;
  margin-bottom: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#uploadError:not(:empty) {
  opacity: 1;
}

/* ---------- PROCESSING STATE ---------- */
#processingState {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--brand);
  font-weight: 600;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bfdbfe;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#uploadForm.loading .file-input,
#uploadForm.loading .file-selected,
#uploadForm.loading button[type="submit"] {
  opacity: 0.7;
  pointer-events: none;
}

#uploadForm.loading #processingState {
  display: inline-flex;
}

/* ---------- RESULTS ACTIONS ---------- */
#resultsActions {
  width: 100%;
  display: none;
  justify-content: flex-end;
  margin-bottom: 16px;
}

body.has-results #resultsActions {
  display: flex;
}

/* ---------- RESULTS MODE BEHAVIOR ---------- */
body.has-results .upload-card {
  display: none;
}

/* ---------- PERFORMANCE SECTION ---------- */
.performance-shell {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

/* STATIC Y AXIS */
.performance-y-axis {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 80px;
  font-size: 12px;
}

.performance-y-axis .title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
}

.performance-y-axis .ticks {
  position: relative;
  height: 360px;
  flex: 1;
}

.performance-y-axis .tick {
  position: absolute;
  transform: translateY(-50%);
}

/* SCROLL AREA */
.performance-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  padding: 16px 16px 16px 0;
}

#performanceChart {
  min-height: 360px;
  max-height: 360px;
}

.performance-x-label {
  text-align: center;
  margin-top: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Message when the charting library fails to load */
.chart-error-msg {
  color: #64748b;
  font-weight: 600;
}

/* ---------- PERFORMANCE TOGGLES ---------- */
.perf-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.perf-toggle {
  border: 1px solid var(--border-light);
  background: var(--bg-soft);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.perf-toggle.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ---------- STATUS & TABLE VIEWPORTS ---------- */
#errorSummaryViewport {
  max-height: 520px;
  overflow-y: auto;
}

#slowRoutesViewport {
  max-height: 420px;
  overflow-y: auto;
}

/* ---------- TIMELINE ---------- */
#timeline {
  font-family: monospace;
  background: #0f172a;
  color: #e5e7eb;
  padding: 14px;
  height: 360px;
  overflow-y: auto;
  border-radius: 12px;
  font-size: 13px;
  border: 1px solid #1e293b;
}

.error {
  color: #ef4444;
}

.http-error {
  color: #fb923c;
}

.high-latency {
  color: #fde047;
}

.card #timeline {
  margin-top: 8px;
}

/* Results Actions Container */
.results-actions-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Expiry Info Styling - Footer style */
.expiry-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  background: none;
  border: none;
  padding: 8px 12px;
}

.expiry-label {
  font-weight: 500;
  font-style: normal;
}

.expiry-date {
  font-weight: 500;
  color: var(--text-muted);
  font-family: inherit;
  font-style: normal;
}

/* Responsive */
@media (max-width: 768px) {
  .results-actions-container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .expiry-info {
    justify-content: center;
    order: 2;
    padding: 8px 12px;
  }

  .primary-button {
    order: 1;
  }
}
