/* ── FlowViewer — Real-time progress UI (Rafias IA) ────────────────────── */

/* Container floating bottom-right */
.fv-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 420px;
  max-width: calc(100vw - 40px);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.fv-host > * { pointer-events: auto; }

/* Toast (acciones <2s) */
.fv-toast {
  background: var(--go-white);
  border: 1px solid var(--go-gray-2);
  border-left: 4px solid var(--go-orange);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(38,38,38,0.12);
  font-size: 13px;
  color: var(--go-black);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fv-fade-in 0.18s ease-out;
}
.fv-toast--success { border-left-color: var(--green); }
.fv-toast--error   { border-left-color: var(--red); }

/* Modal flotante normal */
.fv-card {
  background: var(--go-white);
  border: 1px solid var(--go-gray-2);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(38,38,38,0.14);
  overflow: hidden;
  animation: fv-fade-in 0.22s ease-out;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.fv-card--minimized .fv-body { display: none; }
.fv-card--minimized .fv-stepper { display: none; }

/* Header */
.fv-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #FFF8F1 0%, var(--go-white) 100%);
  border-bottom: 1px solid var(--go-gray-2);
}
.fv-header__icon {
  font-size: 16px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--go-orange-tint);
  color: var(--go-orange);
  flex-shrink: 0;
}
.fv-card--success .fv-header__icon {
  background: rgba(0,163,110,0.10);
  color: var(--green);
}
.fv-card--error .fv-header__icon {
  background: rgba(220,38,38,0.10);
  color: var(--red);
}
.fv-header__title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: var(--go-black);
  line-height: 1.3;
  letter-spacing: -0.1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fv-header__subtitle {
  font-size: 11px;
  color: var(--go-gray-1);
  margin-top: 2px;
  font-weight: 400;
}
.fv-header__actions {
  display: flex;
  gap: 4px;
}
.fv-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--go-gray-1);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.fv-btn:hover { background: var(--go-orange-tint); color: var(--go-orange); }

/* Stepper bar */
.fv-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 14px 8px;
  background: var(--go-white);
}
.fv-step-pip {
  flex: 1;
  height: 4px;
  background: var(--go-gray-2);
  border-radius: 2px;
  position: relative;
  transition: background 0.4s ease-out;
}
.fv-step-pip:not(:last-child) { margin-right: 3px; }
.fv-step-pip--done { background: var(--green); }
.fv-step-pip--active {
  background: linear-gradient(90deg, var(--go-orange) 0%, var(--go-orange-hot) 100%);
  animation: fv-pulse 1.6s ease-in-out infinite;
}
.fv-step-pip--error { background: var(--red); }

.fv-progress-text {
  font-size: 10px;
  color: var(--go-gray-1);
  margin-left: 8px;
  white-space: nowrap;
  letter-spacing: 0.3px;
  font-weight: 600;
}

/* Body — activity feed */
.fv-body {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 14px 14px;
  background: var(--go-white);
}
.fv-body::-webkit-scrollbar { width: 4px; }
.fv-body::-webkit-scrollbar-thumb { background: var(--go-gray-2); border-radius: 2px; }

.fv-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--go-black);
  line-height: 1.4;
  border-bottom: 1px solid #F0F0EA;
}
.fv-step:last-child { border-bottom: none; }

.fv-step__icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  border-radius: 50%;
  margin-top: 1px;
}

.fv-step--pending { color: var(--go-gray-2); }
.fv-step--pending .fv-step__icon { color: var(--go-gray-2); }

.fv-step--in-progress { color: var(--go-orange); font-weight: 500; }
.fv-step--in-progress .fv-step__icon {
  color: var(--go-orange);
  animation: fv-spin 1s linear infinite;
}

.fv-step--success { color: var(--go-black); }
.fv-step--success .fv-step__icon {
  color: var(--green);
  background: rgba(0,163,110,0.10);
}

.fv-step--error { color: var(--red); }
.fv-step--error .fv-step__icon {
  color: var(--red);
  background: rgba(220,38,38,0.10);
}

.fv-step__title {
  flex: 1;
  word-wrap: break-word;
}
.fv-step__message {
  font-size: 11px;
  color: var(--go-gray-1);
  margin-top: 2px;
  font-weight: 400;
}
.fv-step__duration {
  font-size: 10.5px;
  color: var(--go-gray-1);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  align-self: center;
}

/* Animations */
@keyframes fv-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fv-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes fv-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

/* Responsive — mobile */
@media (max-width: 640px) {
  .fv-host {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
  }
  .fv-card {
    border-radius: 14px 14px 0 0;
    border-bottom: none;
  }
  .fv-body { max-height: 240px; }
}

/* Accessibility — prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .fv-card, .fv-toast,
  .fv-step--in-progress .fv-step__icon,
  .fv-step-pip--active { animation: none !important; }
  .fv-step-pip { transition: none !important; }
}
