* {
  box-sizing: border-box;
}
:root {
  --step-gap: 4rem;
  --step-completed-color: #10b981; /* Success green for completed steps */
}

body {
  font-family: var(--vscode-font-family);
  font-size: var(--vscode-font-size);
  background: var(--vscode-sideBar-background);
  color: var(--vscode-foreground);
}

#initview-container {
  height: 100vh;
  /* max-width: 600px; */
  margin: 0 auto;
  padding: 1rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow-x: hidden;
}

/* Header */
.header-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  position: relative;
  margin-top: 2rem;
  margin-bottom: 1.5rem;
}

.header {
  text-align: center;
  animation: fadeIn 0.6s ease;
}

.help-btn {
  position: absolute;
  right: 0;
  top: 0;
  background: none;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--vscode-descriptionForeground);
  transition: all 0.2s ease;
}

.help-btn:hover {
  background: var(--vscode-toolbar-hoverBackground);
  color: var(--vscode-foreground);
}

.help-btn:focus,
.help-btn:active {
  outline: none;
  border: none;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

/* Loading */
.loading-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.logo {
  width: 48px;
  height: 48px;
}

.wave-wrapper {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}

.wave-bar {
  background: var(--vscode-foreground);
  border-radius: 50px;
  width: 4px; /* md uses w-0.5 => ~2px, lg => 4px */
  height: 30px;
  animation: wave-bars 1s ease-in-out infinite;
}

@keyframes wave-bars {
  0%,
  100% {
    transform: scaleY(1);
    opacity: 0.5;
  }
  50% {
    transform: scaleY(0.6);
    opacity: 1;
  }
}

#init-message {
  font-size: 1rem;
  color: var(--vscode-descriptionForeground);
  font-weight: 500;
}

/* Timeline */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  /* flex: 1; */
  gap: var(--step-gap);
}

.step {
  flex: 1;
  position: relative;
  padding-left: 40px; /* Space for indicator */
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.4;
  }
}

.step:nth-child(1) {
  animation-delay: 0.05s;
}
.step:nth-child(2) {
  animation-delay: 0.1s;
}
.step:nth-child(3) {
  animation-delay: 0.15s;
}
.step:nth-child(4) {
  animation-delay: 0.2s;
}
.step:nth-child(5) {
  animation-delay: 0.25s;
}

/* Step Indicator */
.step-indicator {
  position: absolute;
  left: 0;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--vscode-input-border);
  background: var(--vscode-editor-background);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.step-indicator .codicon {
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
}

.step.completed .step-indicator {
  border-color: #10b981;
  background: #10b981;
}

.step.completed .step-indicator .codicon {
  color: white;
}

.step.failed .step-indicator {
  border-color: var(--vscode-errorForeground);
  background: var(--vscode-errorForeground);
}

.step.failed .step-indicator .codicon {
  color: white;
}

.step.in-progress .step-indicator {
  border-color: var(--vscode-button-background);
}

.step.in-progress .step-indicator .codicon {
  color: var(--vscode-button-background);
  animation: spin 2s linear infinite;
}

/* Connector Line */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  bottom: calc(var(--step-gap) * -1);
  width: 2px;
  background: var(--vscode-editor-background);
}

.step.completed:not(:last-child)::before {
  background: #10b981;
  opacity: 0.3;
}

/* Step Content */
.step-content {
  min-height: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
  overflow-wrap: break-word;
}

.step-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--vscode-foreground);
  line-height: 24px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.step.idle .step-title {
  color: var(--vscode-descriptionForeground);
}

.step-description {
  font-size: 0.9rem;
  color: var(--vscode-descriptionForeground);
  line-height: 1.7 !important;
  margin: 1rem 0;
  max-width: 100%;
  overflow-wrap: break-word; /* wraps long text or code */
  word-break: break-word; /* handles really long tokens (for paths) */
}

.step-description .codicon {
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.cmd-text,
.step-action {
  color: var(--vscode-foreground);
  font-size: 1rem;
  margin: 12px 0;
}
/* Error & Shell */
.step-error {
  font-size: 0.9rem;
  color: var(--vscode-foreground);
  font-weight: bold;
  margin: 1rem 0;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shell-command-container {
  width: 100%;
  display: flex;
  align-items: center;
  margin-top: 8px;
  background: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  margin-top: 8px;
  padding: 12px;
  border-radius: 8px;
  font-family: "SF Mono", monospace;
  font-size: 16px;
  color: var(--vscode-descriptionForeground);
  overflow-x: auto;
}

.shell-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
}

.shell-command {
  overflow-wrap: break-word;
  word-break: break-all;
  white-space: pre-wrap;
  max-width: 100%;
}

.dollarSign::before {
  content: "$";
  margin-right: 1rem;
  color: var(--vscode-button-background);
}

.copy-btn {
  background: none;
  border: none;
  color: var(--vscode-foreground);
  cursor: pointer;
  padding: 4px;
  margin-left: 8px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.copy-btn:hover {
  opacity: 1;
  background-color: var(--vscode-toolbar-hoverBackground);
}

.step-action-btn {
  background: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.5rem;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.step-action-btn:hover {
  background: var(--vscode-button-hoverBackground);
}

.step-action-btn:active {
  transform: translateY(0);
}

.step-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.step-action-btn .codicon {
  flex-shrink: 0;
}

.step-action-btn.cancel-btn,
.step-action-btn.secondary-btn {
  background: transparent;
  border: 1px solid var(--vscode-input-border);
  color: var(--vscode-foreground);
}

.step-action-btn.cancel-btn:hover,
.step-action-btn.secondary-btn:hover {
  background: var(--vscode-toolbar-hoverBackground);
}

.spin {
  animation: spin 1s linear infinite;
}

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

.step-actions-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.step-actions-container .step-action-btn {
  width: 100%;
}

.step-actions-container .step-action {
  margin: 0.5rem 0 0 0;
}

.step-disclaimer-label {
  font-size: 0.85rem;
  color: var(--vscode-foreground);
  margin: 0.5rem 0 0.25rem 0;
  font-weight: 500;
}

.step-disclaimer {
  font-size: 0.85rem;
  color: var(--vscode-foreground);
  background: var(--vscode-input-background);
  border: 1px solid var(--vscode-input-border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.5rem 0;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-disclaimer .codicon {
  color: var(--vscode-descriptionForeground);
  flex-shrink: 0;
}

/* Manual command dropdown */
.manual-command-details {
  margin: 0.75rem 0;
}

.manual-command-summary {
  cursor: pointer;
  color: var(--vscode-descriptionForeground);
  font-size: 0.9rem;
  padding: 0.25rem 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.manual-command-summary::-webkit-details-marker {
  display: none;
}

.manual-command-summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--vscode-descriptionForeground);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s ease;
}

.manual-command-details[open] .manual-command-summary::before {
  transform: rotate(90deg);
}

.manual-command-summary:hover {
  color: var(--vscode-foreground);
}

.manual-command-summary:hover::before {
  border-left-color: var(--vscode-foreground);
}

.manual-command-details .shell-command-container {
  margin-top: 0.5rem;
}

.install-error-alert {
  background: var(--vscode-inputValidation-errorBackground);
  border: 1px solid var(--vscode-inputValidation-errorBorder);
  color: var(--vscode-errorForeground);
  border-radius: 4px;
  padding: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.install-error-alert .codicon {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Progress */
.progress {
  margin-top: 48px;
  text-align: center;
  font-size: 12px;
  color: var(--vscode-descriptionForeground);
  display: none;
}

.progress.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

.progress-bar {
  width: 100%;
  height: 2px;
  background: var(--vscode-input-border);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-image: var(--codeflash-gradient-bg);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Responsive */
@media (max-width: 640px) {
  .header {
    margin-bottom: 40px;
  }

  h1 {
    font-size: 20px;
  }
}

.restart-btn {
  background: var(--vscode-input-background);
  color: var(--vscode-editor-foreground);
  border: 1px solid var(--vscode-input-border);
  font-weight: bold;
  border: 1px solid var(--vscode-editorWidget-border, transparent);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 13px;
  line-height: 18px;
  cursor: pointer;
  outline: none;
  transition:
    background-color 0.1s ease,
    border-color 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
  margin-top: auto;
  width: 100%;
}

.vscode-button:hover {
  background-color: var(--vscode-button-hoverBackground);
}

.vscode-button:active {
  background-color: var(--vscode-button-hoverBackground);
  opacity: 0.9;
}

.vscode-button:focus {
  outline: 1px solid var(--vscode-focusBorder);
  outline-offset: 2px;
}

.vscode-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Button with icon */
.restart-btn.codicon {
  font-size: 16px;
  line-height: 18px;
}

/* Init content wrapper - contains loading and steps */
.init-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 0; /* Allow shrinking in flex container */
}

/* Init form container - hidden by default */
#init-form-container {
  display: none;
  width: 100%;
  flex: 1;
}

/* Step Progress Indicator */
.step-progress-container {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  animation: fadeIn 0.4s ease;
}

.step-progress-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 50px;
  position: relative;
}

.step-progress-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid var(--vscode-input-border);
  background: var(--vscode-editor-background);
  color: var(--vscode-descriptionForeground);
}

.step-progress-item.completed .step-progress-circle {
  background: var(--step-completed-color);
  border-color: var(--step-completed-color);
  color: white;
}

.step-progress-item.completed .step-progress-circle .codicon {
  font-size: 11px;
}

.step-progress-item.current .step-progress-circle {
  border-color: var(--vscode-button-background);
  background: var(--vscode-button-background);
  color: var(--vscode-button-foreground);
  animation: pulse-current 2s ease-in-out infinite;
}

@keyframes pulse-current {
  0%,
  100% {
    /* Use transform and opacity for better performance and theme compatibility */
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--vscode-button-background);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 4px var(--vscode-button-background);
    opacity: 0.7;
  }
}

.step-progress-item.pending .step-progress-circle {
  opacity: 0.5;
}

.step-progress-label {
  font-size: 10px;
  color: var(--vscode-descriptionForeground);
  text-align: center;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.step-progress-item.current .step-progress-label {
  color: var(--vscode-foreground);
  font-weight: 500;
}

.step-progress-item.completed .step-progress-label {
  color: var(--step-completed-color);
}

.step-progress-item.pending .step-progress-label {
  opacity: 0.5;
}

.step-progress-connector {
  flex: 1;
  height: 2px;
  background: var(--vscode-input-border);
  min-width: 16px;
  max-width: 32px;
  margin: 0 3px;
  margin-bottom: 18px; /* Align with circles, accounting for label height */
  transition: background 0.3s ease;
}

.step-progress-connector.completed {
  background: var(--step-completed-color);
}

/* Responsive adjustments for step progress */
@media (max-width: 300px) {
  .step-progress-item {
    min-width: 40px;
  }

  .step-progress-circle {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }

  .step-progress-label {
    font-size: 9px;
  }

  .step-progress-connector {
    min-width: 10px;
    margin-bottom: 16px;
  }
}
