/* ============================================================
   Interactive Onboarding Tour
   driver.js-style highlight + popover
   prefix: ob-
   ============================================================ */

:root {
  --ob-overlay-bg: rgba(0, 0, 0, 0.5);
  --ob-popover-bg: #ffffff;
  --ob-popover-radius: 12px;
  --ob-popover-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.1);
  --ob-popover-max-width: 320px;
  --ob-text-primary: #1e293b;
  --ob-text-secondary: #64748b;
  --ob-text-muted: #94a3b8;
  --ob-accent: var(--accent-blue, #1E40AF);
  --ob-accent-hover: #1e3a8a;
  --ob-accent-light: rgba(30, 64, 175, 0.08);
  --ob-accent-purple: var(--accent-purple, #7c3aed);
  --ob-accent-green: var(--accent-green, #059669);
  --ob-border: #e2e8f0;
  --ob-transition-duration: 0.4s;
  --ob-transition-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --ob-highlight-padding: 6px;
  --ob-highlight-radius: 8px;
}

/* ---- Overlay with clip-path highlight ---- */

.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 10038;
  background: var(--ob-overlay-bg);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.ob-overlay.ob-visible {
  opacity: 1;
  pointer-events: auto;
}

.ob-overlay.ob-has-clip {
  transition: opacity 0.25s ease, clip-path var(--ob-transition-duration) var(--ob-transition-easing);
}

/* ---- Breathing ring around highlight ---- */

.ob-breathing-ring {
  position: fixed;
  z-index: 10039;
  border-radius: var(--ob-highlight-radius);
  pointer-events: none;
  opacity: 0;
  transition:
    top var(--ob-transition-duration) var(--ob-transition-easing),
    left var(--ob-transition-duration) var(--ob-transition-easing),
    width var(--ob-transition-duration) var(--ob-transition-easing),
    height var(--ob-transition-duration) var(--ob-transition-easing),
    opacity 0.3s ease;
}

.ob-breathing-ring.ob-ring-visible {
  opacity: 1;
  animation: ob-breathe 2s ease-in-out infinite;
}

@keyframes ob-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 3px rgba(30, 64, 175, 0.3),
      0 0 12px rgba(30, 64, 175, 0.15);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(30, 64, 175, 0.2),
      0 0 20px rgba(30, 64, 175, 0.1);
  }
}

/* ---- Popover ---- */

.ob-popover {
  position: fixed;
  z-index: 10039;
  width: calc(100% - 24px);
  max-width: var(--ob-popover-max-width);
  background: var(--ob-popover-bg);
  border-radius: var(--ob-popover-radius);
  box-shadow: var(--ob-popover-shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  overflow: visible;
}

.ob-popover.ob-popover-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ob-popover.ob-popover-above {
  transform: translateY(-8px);
}

.ob-popover.ob-popover-above.ob-popover-visible {
  transform: translateY(0);
}

.ob-popover.ob-popover-centered {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
}

.ob-popover.ob-popover-centered.ob-popover-visible {
  transform: translate(-50%, -50%) scale(1);
}

/* ---- Popover arrow ---- */

.ob-popover-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--ob-popover-bg);
  transform: rotate(45deg);
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

.ob-popover-arrow.ob-arrow-top {
  top: -6px;
}

.ob-popover-arrow.ob-arrow-bottom {
  bottom: -6px;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

.ob-popover.ob-popover-centered .ob-popover-arrow {
  display: none;
}

/* ---- Progress bar ---- */

.ob-progress-bar {
  width: 100%;
  height: 3px;
  background: var(--ob-border);
  border-radius: var(--ob-popover-radius) var(--ob-popover-radius) 0 0;
  overflow: hidden;
}

.ob-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ob-accent), var(--ob-accent-purple), var(--ob-accent-green));
  border-radius: 3px;
  transition: width 0.4s var(--ob-transition-easing);
}

/* ---- Custom content area (particles, workflow, confetti) ---- */

.ob-popover-custom {
  position: relative;
  overflow: hidden;
}

.ob-popover-custom:empty {
  display: none;
}

/* ---- Content ---- */

.ob-popover-content {
  padding: 16px 20px 0;
  text-align: center;
}

.ob-popover-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ob-text-primary);
  line-height: 1.3;
  margin: 0;
}

.ob-popover-desc {
  font-size: 13px;
  color: var(--ob-text-secondary);
  line-height: 1.6;
  margin: 8px 0 0;
}

/* Progressive reveal */
.ob-reveal-title { animation: ob-fade-in 0.3s ease both; }
.ob-reveal-desc  { animation: ob-fade-in 0.3s ease 0.1s both; }
.ob-reveal-footer { animation: ob-fade-in 0.3s ease 0.2s both; }

@keyframes ob-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Step indicator ---- */

.ob-popover-step-indicator {
  text-align: center;
  font-size: 11px;
  color: var(--ob-text-muted);
  padding: 10px 0 0;
  font-variant-numeric: tabular-nums;
}

/* ---- Footer ---- */

.ob-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 16px;
  gap: 8px;
}

.ob-popover-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ob-btn-skip {
  font-size: 12px;
  color: var(--ob-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.ob-btn-skip:hover {
  color: var(--ob-text-secondary);
  background: var(--ob-accent-light);
}

.ob-btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ob-border);
  border-radius: 8px;
  background: transparent;
  color: var(--ob-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ob-btn-back:hover {
  background: var(--ob-accent-light);
  border-color: var(--ob-accent);
  color: var(--ob-accent);
}

.ob-btn-next {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background: var(--ob-accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.ob-btn-next:hover {
  background: var(--ob-accent-hover);
}

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

.ob-btn-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ---- Checkbox ---- */

.ob-checkbox-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ob-text-muted);
  cursor: pointer;
  user-select: none;
  padding: 0 20px 14px;
}

.ob-checkbox-row.ob-hidden {
  display: none;
}

.ob-checkbox-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--ob-accent);
  cursor: pointer;
  margin: 0;
}

/* ---- Workflow 3-step illustration ---- */

.ob-workflow-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 16px 8px;
}

.ob-workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 90px;
  opacity: 0;
  transform: scale(0.7);
}

.ob-workflow-step.ob-wf-enter {
  animation: ob-wf-pop 0.4s var(--ob-transition-easing) forwards;
}

.ob-workflow-step:nth-child(1).ob-wf-enter { animation-delay: 0s; }
.ob-workflow-step:nth-child(3).ob-wf-enter { animation-delay: 0.15s; }
.ob-workflow-step:nth-child(5).ob-wf-enter { animation-delay: 0.3s; }

@keyframes ob-wf-pop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

.ob-workflow-step-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ob-workflow-step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ob-text-primary);
}

.ob-workflow-arrow {
  flex-shrink: 0;
  color: var(--ob-text-muted);
  opacity: 0;
}

.ob-workflow-arrow.ob-wf-enter {
  animation: ob-fade-in 0.3s ease forwards;
}

.ob-workflow-arrow:nth-child(2).ob-wf-enter { animation-delay: 0.1s; }
.ob-workflow-arrow:nth-child(4).ob-wf-enter { animation-delay: 0.25s; }

/* ---- Welcome particles ---- */

.ob-particles {
  position: relative;
  width: 100%;
  height: 80px;
  overflow: hidden;
}

.ob-particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0;
  animation: ob-float 3s ease-in-out infinite;
}

@keyframes ob-float {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  20% {
    opacity: 0.8;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateY(-35px) scale(1);
  }
}

/* ---- Confetti celebration ---- */

.ob-confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ob-confetti {
  position: absolute;
  width: 4px;
  height: 8px;
  border-radius: 1px;
  animation: ob-confetti-burst 1.2s ease-out forwards;
}

@keyframes ob-confetti-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform:
      translate(var(--ob-confetti-x, 50px), var(--ob-confetti-y, -80px))
      rotate(var(--ob-confetti-rot, 360deg))
      scale(0.5);
  }
}

/* ---- Document choice dialog ---- */

.ob-doc-choice {
  padding: 20px;
  text-align: center;
}

.ob-doc-choice-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ob-text-primary);
  margin: 0 0 16px;
}

.ob-doc-choice-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ob-doc-choice-btn {
  width: 100%;
  height: 38px;
  border: 1px solid var(--ob-border);
  border-radius: 8px;
  background: transparent;
  color: var(--ob-text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ob-doc-choice-btn:hover {
  background: var(--ob-accent-light);
  border-color: var(--ob-accent);
}

.ob-doc-choice-btn.ob-doc-choice-primary {
  background: var(--ob-accent);
  color: #ffffff;
  border-color: var(--ob-accent);
}

.ob-doc-choice-btn.ob-doc-choice-primary:hover {
  background: var(--ob-accent-hover);
}

.ob-doc-choice-btn.ob-doc-choice-skip {
  border: none;
  color: var(--ob-text-muted);
  font-size: 12px;
  height: 32px;
}

.ob-doc-choice-btn.ob-doc-choice-skip:hover {
  color: var(--ob-text-secondary);
}

/* ---- Checkmark animation for final step ---- */

.ob-checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ob-accent-green), #34d399);
  margin: 12px auto 8px;
  opacity: 0;
  transform: scale(0.5);
}

.ob-checkmark.ob-check-enter {
  animation: ob-check-pop 0.5s var(--ob-transition-easing) forwards;
}

@keyframes ob-check-pop {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { opacity: 1; transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

.ob-checkmark svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
  stroke-width: 3;
  fill: none;
}

/* ---- Global Apply hint (floating, non-step) ---- */

.ob-apply-hint {
  position: fixed;
  z-index: 10040;
  max-width: 240px;
  background: var(--ob-popover-bg);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 1px 4px rgba(0, 0, 0, 0.08);
  padding: 10px 14px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.ob-apply-hint.ob-apply-hint-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ob-apply-hint-arrow {
  position: absolute;
  top: -6px;
  width: 12px;
  height: 12px;
  background: var(--ob-popover-bg);
  transform: rotate(45deg);
  box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

.ob-apply-hint-text {
  font-size: 12px;
  color: var(--ob-text-secondary);
  line-height: 1.5;
  text-align: center;
}

/* ---- Responsive (narrow sidebar) ---- */

@media (max-width: 360px) {
  .ob-popover {
    width: calc(100% - 16px);
  }

  .ob-popover-content {
    padding: 12px 14px 0;
  }

  .ob-popover-title {
    font-size: 15px;
  }

  .ob-popover-desc {
    font-size: 12px;
  }

  .ob-popover-footer {
    padding: 10px 14px 12px;
  }

  .ob-workflow-steps {
    gap: 6px;
    padding: 16px 10px 6px;
  }

  .ob-workflow-step-icon {
    width: 36px;
    height: 36px;
  }
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .ob-overlay,
  .ob-overlay.ob-has-clip,
  .ob-popover,
  .ob-breathing-ring,
  .ob-progress-fill {
    transition-duration: 0.01ms !important;
  }

  .ob-breathing-ring.ob-ring-visible {
    animation: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.3);
  }

  .ob-particle,
  .ob-confetti,
  .ob-workflow-step,
  .ob-workflow-arrow,
  .ob-checkmark,
  .ob-reveal-title,
  .ob-reveal-desc,
  .ob-reveal-footer {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .ob-checkmark {
    opacity: 1 !important;
    transform: scale(1) !important;
  }

  .ob-workflow-step {
    opacity: 1 !important;
    transform: scale(1) !important;
  }
}
