/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(118, 255, 122, 0.2);

  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #374151;

  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-glow: rgba(34, 197, 94, 0.15);

  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.15);

  --red-400: #f87171;
  --red-500: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.15);

  --blue-400: #60a5fa;
  --blue-500: #3b82f6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-glow-green: 0 0 20px rgba(34, 197, 94, 0.15), 0 0 60px rgba(34, 197, 94, 0.05);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.4);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ===== Layout ===== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 32px;
  gap: 24px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 197, 94, 0.06), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(59, 130, 246, 0.04), transparent),
    var(--bg-primary);
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow-green);
  font-size: 22px;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.refresh-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
}

.refresh-btn:active {
  transform: scale(0.97);
}

.refresh-btn .icon {
  font-size: 16px;
  transition: transform var(--transition-normal);
}

.refresh-btn:hover .icon {
  transform: rotate(90deg);
}

.refresh-btn.spinning .icon {
  animation: spin 0.8s linear infinite;
}

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

/* ===== Progress Bar ===== */
.progress-section {
  flex-shrink: 0;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-count .done {
  color: var(--green-400);
  font-weight: 600;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green-500), var(--green-400));
  transition: width var(--transition-slow);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}

/* ===== Steps List ===== */
.steps-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== Step Card ===== */
.step-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.step-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

/* States */
.step-card.disabled {
  opacity: 0.38;
  pointer-events: none;
}

.step-card.disabled .step-label {
  color: var(--text-disabled);
}

.step-card.pending {
  cursor: default;
}

.step-card.pending:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.step-card.running {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.step-card.running::before {
  opacity: 1;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.03), transparent);
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

.step-card.completed {
  border-color: rgba(34, 197, 94, 0.15);
  background: rgba(34, 197, 94, 0.03);
}

.step-card.error {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.03);
  cursor: pointer;
}

.step-card.error:hover {
  background: rgba(239, 68, 68, 0.06);
}

.step-card.update-available {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.04);
  cursor: default;
}

.step-card.update-available:hover {
  background: rgba(245, 158, 11, 0.06);
}

/* Step Index */
.step-index {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.step-card.disabled .step-index {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-disabled);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
}

.step-card.pending .step-index {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
}

.step-card.running .step-index {
  background: rgba(59, 130, 246, 0.12);
  color: var(--blue-400);
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  animation: pulse-blue 1.5s ease-in-out infinite;
}

@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
}

.step-card.completed .step-index {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: white;
  border: none;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}

.step-card.error .step-index {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-400);
  border: 1.5px solid rgba(239, 68, 68, 0.3);
}

.step-card.update-available .step-index {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-400);
  border: 1.5px solid rgba(245, 158, 11, 0.3);
  animation: pulse-amber 1.5s ease-in-out infinite;
}

@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* Step Content */
.step-content {
  flex: 1;
  min-width: 0;
}

.step-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: color var(--transition-fast);
  line-height: 1.4;
}

.step-card.completed .step-label {
  text-decoration: line-through;
  text-decoration-color: var(--green-500);
  text-decoration-thickness: 1.5px;
  color: var(--text-muted);
}

.step-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-card.completed .step-detail {
  color: var(--green-500);
  opacity: 0.7;
}

.step-card.error .step-detail {
  color: var(--red-400);
  opacity: 0.8;
}

.step-card.update-available .step-detail {
  color: var(--amber-400);
  opacity: 0.85;
}

.step-card.update-available .step-label {
  color: var(--text-primary);
}

/* Step Actions */
.step-action {
  flex-shrink: 0;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  letter-spacing: 0.2px;
}

.action-btn.install {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: white;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.action-btn.install:hover {
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
  transform: translateY(-1px);
}

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

.action-btn.retry {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.action-btn.retry:hover {
  background: rgba(239, 68, 68, 0.18);
}

.action-btn.update {
  background: linear-gradient(135deg, var(--amber-500), #d97706);
  color: white;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.action-btn.update:hover {
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}

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

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--blue-400);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Status Badge */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.status-badge.checking {
  background: rgba(59, 130, 246, 0.1);
  color: var(--blue-400);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge.done {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green-400);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red-400);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ===== Error Log Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 200ms ease-out;
  padding: 24px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  max-width: 560px;
  width: 100%;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  animation: slide-up 250ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-error-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-step-name {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 24px 20px;
  overflow-y: auto;
  flex: 1;
}

.error-log {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--red-400);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  border: none;
}

.modal-btn.secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.modal-btn.secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.modal-btn.primary {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: white;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.modal-btn.primary:hover {
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

/* ===== Section Divider ===== */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.section-divider .line {
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.section-divider .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ===== Animations ===== */
.step-card {
  animation: step-enter 300ms ease-out both;
}

@keyframes step-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger the animation for each step */
.step-card:nth-child(1) { animation-delay: 50ms; }
.step-card:nth-child(2) { animation-delay: 100ms; }
.step-card:nth-child(3) { animation-delay: 150ms; }
.step-card:nth-child(4) { animation-delay: 200ms; }
.step-card:nth-child(5) { animation-delay: 250ms; }
.step-card:nth-child(6) { animation-delay: 300ms; }
.step-card:nth-child(7) { animation-delay: 350ms; }
.step-card:nth-child(8) { animation-delay: 400ms; }
.step-card:nth-child(9) { animation-delay: 450ms; }
.step-card:nth-child(10) { animation-delay: 500ms; }

/* ===== Tooltip / Info ===== */
.info-icon {
  color: var(--text-muted);
  font-size: 14px;
  cursor: help;
  transition: color var(--transition-fast);
}

.info-icon:hover {
  color: var(--text-secondary);
}

/* ===== Footer ===== */
.app-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.footer-text {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-text .heart {
  color: var(--red-400);
}
