/* Asta Thread Styles */

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2), 0 0 30px rgba(139, 92, 246, 0.1);
  }
  50% {
    box-shadow: 0 0 25px rgba(99, 102, 241, 0.4), 0 0 50px rgba(139, 92, 246, 0.25);
  }
}

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

.animate-fade-in {
  animation: fadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ========================================================= */
/* TWITTER-STYLE THREAD TREE BRANCHING CONNECTORS           */
/* ========================================================= */

/* Root Demigod trunk stem descending downward */
.thread-root-stem {
  position: relative;
  width: 2px;
  background: linear-gradient(to bottom, #6366f1, #3b82f6 40%, #334155);
  margin-left: 2rem; /* aligns with Demigod icon center */
  height: 28px;
}

/* Thread Level 1: Connected Apps container */
.thread-app-wrapper {
  position: relative;
  padding-left: 2.75rem; /* space for the trunk line and elbow */
  margin-bottom: 2rem;
}

/* Continuous vertical trunk line connecting all apps */
.thread-trunk-line {
  position: absolute;
  left: 2rem;
  top: -28px;
  bottom: 0;
  width: 2px;
  background-color: #334155;
  transition: background-color 0.2s ease;
}

/* If it is the last app, stop the trunk line at the app's connector curve */
.thread-app-wrapper:last-child > .thread-trunk-line {
  bottom: calc(100% - 24px);
}

/* Curved connector branching off the trunk into the App Card */
.thread-app-elbow {
  position: absolute;
  left: 2rem;
  top: 0;
  width: 1.5rem;
  height: 24px;
  border-left: 2px solid #334155;
  border-bottom: 2px solid #334155;
  border-bottom-left-radius: 14px;
  pointer-events: none;
}

/* ========================================================= */
/* LEVEL 2: SUBCATEGORY WRAPPER & BRANCHING                 */
/* ========================================================= */

.subcat-wrapper {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 1.25rem;
}

.subcat-trunk-line {
  position: absolute;
  left: 0.85rem;
  top: -12px;
  bottom: 0;
  width: 2px;
  background-color: #334155;
}

.subcat-wrapper:last-child > .subcat-trunk-line {
  bottom: calc(100% - 20px);
}

.subcat-elbow {
  position: absolute;
  left: 0.85rem;
  top: 0;
  width: 1.15rem;
  height: 20px;
  border-left: 2px solid #334155;
  border-bottom: 2px solid #334155;
  border-bottom-left-radius: 10px;
  pointer-events: none;
}

/* Container for apps inside a subcategory */
.subcat-apps-container {
  position: relative;
  margin-top: 0.75rem;
  padding-left: 1.75rem;
  transition: all 0.25s ease;
}

.subcat-apps-trunk-line {
  position: absolute;
  left: 0.75rem;
  top: -8px;
  bottom: 16px;
  width: 2px;
  background-color: #334155;
}

.subcat-app-item {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.subcat-app-elbow {
  position: absolute;
  left: 0.75rem;
  top: -2px;
  width: 1.25rem;
  height: 18px;
  border-left: 2px solid #334155;
  border-bottom: 2px solid #334155;
  border-bottom-left-radius: 10px;
  pointer-events: none;
}

/* ========================================================= */
/* LEVEL 3: SUB-THREADS (USE CASES UNDER APP)               */
/* ========================================================= */

.usecases-container {
  position: relative;
  margin-top: 1rem;
  padding-left: 2.5rem; /* indented sub-thread level */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Vertical guide line for use cases under this specific app */
.usecases-trunk-line {
  position: absolute;
  left: 1.25rem;
  top: -12px;
  bottom: 18px;
  width: 2px;
  background-color: #334155;
  border-radius: 2px;
}

/* Use Case item wrapper */
.usecase-item-wrapper {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.usecase-item-wrapper:last-child {
  margin-bottom: 0.5rem;
}

/* Curved branch connector into the use case card */
.usecase-elbow {
  position: absolute;
  left: 1.25rem;
  top: -4px;
  width: 1.5rem;
  height: 22px;
  border-left: 2px solid #334155;
  border-bottom: 2px solid #334155;
  border-bottom-left-radius: 12px;
  pointer-events: none;
}

/* If last usecase, stop trunk line at the curve */
.usecase-item-wrapper:last-child ~ .usecases-trunk-line,
.usecases-container .usecase-item-wrapper:last-child::after {
  content: '';
}

/* ========================================================= */
/* LEVEL 3: SUB-STEPS (NESTED UNDER USE CASE)               */
/* ========================================================= */

.substeps-container {
  position: relative;
  margin-top: 0.75rem;
  padding-left: 2rem;
  border-left: 2px dashed #334155;
  margin-left: 1.5rem;
}

.substep-item {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
}

.substep-elbow {
  position: absolute;
  left: -2px;
  top: 0;
  width: 1.25rem;
  height: 14px;
  border-left: 2px solid #475569;
  border-bottom: 2px solid #475569;
  border-bottom-left-radius: 8px;
}

/* App Card styling */
.app-card {
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.app-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 0 15px rgba(99, 102, 241, 0.1);
}

.app-card:hover .thread-app-elbow {
  border-color: #6366f1;
}

/* Use Case Card styling */
.usecase-card {
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.usecase-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 6px 20px -4px rgba(0, 0, 0, 0.3), 0 0 12px rgba(16, 185, 129, 0.08);
}

.usecase-card:hover .usecase-elbow {
  border-color: #10b981;
}

/* Pulsing dot indicator */
.pulse-dot {
  position: relative;
}
.pulse-dot::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  opacity: 0.6;
}

/* ========================================================= */
/* USE CASE PROGRESS BAR                                    */
/* ========================================================= */

.uc-progress-track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.6);
  overflow: hidden;
  flex: 1;
  min-width: 60px;
}

.uc-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.uc-progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { left: -60%; }
  100% { left: 150%; }
}

.uc-progress-fill.is-done::after {
  display: none;
}

.uc-progress-fill.is-idle::after {
  display: none;
}

@keyframes runPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

.uc-run-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid;
  transition: all 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.uc-run-btn:hover  { transform: scale(1.05); }
.uc-run-btn:active { transform: scale(0.96); }

.uc-run-btn.state-idle    { color: #34d399; background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); }
.uc-run-btn.state-running { color: #fbbf24; background: rgba(251,191,36,0.12);  border-color: rgba(251,191,36,0.3); animation: runPulse 0.9s ease-in-out infinite; }
.uc-run-btn.state-done    { color: #818cf8; background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.3); }

/* Launch UC run btn variant */
.uc-run-btn.launch-idle    { color: #38bdf8; background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.3); }
.uc-run-btn.launch-running { color: #fbbf24; background: rgba(251,191,36,0.12);  border-color: rgba(251,191,36,0.3); animation: runPulse 0.9s ease-in-out infinite; }
.uc-run-btn.launch-done    { color: #34d399; background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.3); }

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}
