/* =============================================================================
   GROW50X SDR — Interactive Product Tour / Onboarding Guide
   Matches the Enterprise Design System v3.0 (dark-first, light opt-in)
============================================================================= */

/* ─── Overlay Backdrop ────────────────────────────────────────────────────── */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.guide-overlay.active {
  pointer-events: auto;
}

/* Four-piece backdrop: top, bottom, left, right panels around the spotlight */
.guide-backdrop {
  position: fixed;
  background: rgba(0, 0, 0, 0.68);
  z-index: 10001;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

[data-theme="light"] .guide-backdrop {
  background: rgba(0, 0, 0, 0.45);
}

/* ─── Spotlight Cutout ────────────────────────────────────────────────────── */
.guide-spotlight {
  position: fixed;
  z-index: 10002;
  border-radius: var(--radius-md, 10px);
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.35),
    0 0 24px rgba(99, 102, 241, 0.2),
    0 0 60px rgba(99, 102, 241, 0.08);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

[data-theme="light"] .guide-spotlight {
  box-shadow:
    0 0 0 4px rgba(79, 70, 229, 0.3),
    0 0 20px rgba(79, 70, 229, 0.15),
    0 0 50px rgba(79, 70, 229, 0.06);
}

/* Pulsing glow animation */
.guide-spotlight::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: inherit;
  border: 2px solid rgba(99, 102, 241, 0.25);
  animation: guide-pulse 2s ease-in-out infinite;
}

@keyframes guide-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.015); }
}

/* ─── Tooltip ─────────────────────────────────────────────────────────────── */
.guide-tooltip {
  position: fixed;
  z-index: 10003;
  width: 370px;
  max-width: calc(100vw - 32px);
  background: var(--bg-glass, rgba(17, 17, 21, 0.85));
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.05));
  border-radius: var(--radius-lg, 14px);
  box-shadow: var(--shadow-xl, 0 24px 48px rgba(0,0,0,0.4));
  padding: 0;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

.guide-tooltip.pos-top    { transform: translateY(-10px); }
.guide-tooltip.pos-top.visible { transform: translateY(0); }
.guide-tooltip.pos-left   { transform: translateX(-10px); }
.guide-tooltip.pos-left.visible  { transform: translateX(0); }
.guide-tooltip.pos-right  { transform: translateX(10px); }
.guide-tooltip.pos-right.visible { transform: translateX(0); }

/* ─── Tooltip Progress Bar ────────────────────────────────────────────────── */
.guide-progress-bar {
  height: 3px;
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
  border-radius: var(--radius-lg, 14px) var(--radius-lg, 14px) 0 0;
  overflow: hidden;
}

.guide-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary, #6366f1), #818cf8, var(--accent-primary, #6366f1));
  background-size: 200% 100%;
  animation: guide-progress-shimmer 2.5s ease infinite;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: inherit;
}

@keyframes guide-progress-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Tooltip Content ─────────────────────────────────────────────────────── */
.guide-tooltip-content {
  padding: 1.25rem 1.35rem 1rem;
}

.guide-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-primary, #6366f1);
  margin-bottom: 0.65rem;
}

.guide-step-badge .guide-section-name {
  color: var(--text-muted, #71717a);
  font-weight: 500;
}

.guide-tooltip-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary, #f4f4f5);
  margin: 0 0 0.5rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.guide-tooltip-body {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--text-secondary, #a1a1aa);
  line-height: 1.6;
  margin: 0;
}

.guide-tooltip-body strong {
  color: var(--text-primary, #f4f4f5);
  font-weight: 600;
}

/* ─── Tooltip Footer (buttons) ────────────────────────────────────────────── */
.guide-tooltip-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1.35rem;
  border-top: 1px solid var(--border-soft, #1f1f23);
}

.guide-tooltip-footer .guide-nav-group {
  display: flex;
  gap: 0.4rem;
}

.guide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.guide-btn-skip {
  background: transparent;
  color: var(--text-muted, #71717a);
  border-color: transparent;
}
.guide-btn-skip:hover {
  color: var(--text-secondary, #a1a1aa);
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
}

.guide-btn-prev {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
  color: var(--text-secondary, #a1a1aa);
  border-color: var(--border, #27272a);
}
.guide-btn-prev:hover {
  background: var(--bg-transparent-10, rgba(255, 255, 255, 0.08));
  color: var(--text-primary, #f4f4f5);
}

.guide-btn-next {
  background: var(--accent-primary, #6366f1);
  color: #fff;
  border-color: var(--accent-primary, #6366f1);
}
.guide-btn-next:hover {
  background: var(--accent-hover, #5254cc);
  border-color: var(--accent-hover, #5254cc);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
}

.guide-btn-finish {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-color: #10b981;
}
.guide-btn-finish:hover {
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

/* ─── Arrow Pointer ───────────────────────────────────────────────────────── */
.guide-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg-glass, rgba(17, 17, 21, 0.85));
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.05));
  transform: rotate(45deg);
  z-index: -1;
}

.guide-tooltip.pos-bottom .guide-arrow {
  top: -7px;
  left: 50%;
  margin-left: -6px;
  border-bottom: none;
  border-right: none;
}
.guide-tooltip.pos-top .guide-arrow {
  bottom: -7px;
  left: 50%;
  margin-left: -6px;
  border-top: none;
  border-left: none;
}
.guide-tooltip.pos-left .guide-arrow {
  right: -7px;
  top: 50%;
  margin-top: -6px;
  border-left: none;
  border-bottom: none;
}
.guide-tooltip.pos-right .guide-arrow {
  left: -7px;
  top: 50%;
  margin-top: -6px;
  border-right: none;
  border-top: none;
}

/* ─── Welcome / Completion Splash (centered overlay) ─────────────────────── */
.guide-splash {
  position: fixed;
  z-index: 10003;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 440px;
  max-width: calc(100vw - 40px);
  background: var(--bg-glass, rgba(17, 17, 21, 0.85));
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.05));
  border-radius: var(--radius-xl, 18px);
  box-shadow: var(--shadow-xl);
  padding: 2.2rem 2rem;
  text-align: center;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  font-family: 'Inter', sans-serif;
}
.guide-splash.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.guide-splash-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.guide-splash h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary, #f4f4f5);
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
}

.guide-splash p {
  font-size: 0.85rem;
  color: var(--text-secondary, #a1a1aa);
  line-height: 1.6;
  margin: 0 0 1.5rem;
}

.guide-splash .guide-splash-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

/* ─── Floating Help Button ────────────────────────────────────────────────── */
.guide-help-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-primary, #6366f1);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(99, 102, 241, 0.3),
    0 0 0 0 rgba(99, 102, 241, 0.2);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: guide-help-entrance 0.5s 1s both cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guide-help-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

@keyframes guide-help-entrance {
  from { opacity: 0; transform: scale(0) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ─── Help Menu Dropdown ──────────────────────────────────────────────────── */
.guide-help-menu {
  position: fixed;
  bottom: 78px;
  right: 24px;
  z-index: 9001;
  background: var(--bg-glass, rgba(17, 17, 21, 0.85));
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border-glass, rgba(255, 255, 255, 0.05));
  border-radius: var(--radius-md, 10px);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.35));
  min-width: 200px;
  padding: 0.35rem;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: 'Inter', sans-serif;
}

.guide-help-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.guide-help-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary, #a1a1aa);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  text-align: left;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s ease;
}

.guide-help-menu-item:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
  color: var(--text-primary, #f4f4f5);
}

.guide-help-menu-item .guide-menu-icon {
  font-size: 0.95rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.guide-help-menu-item .guide-menu-star {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--warning, #fbbf24);
}

.guide-help-menu-divider {
  height: 1px;
  background: var(--border-soft, #1f1f23);
  margin: 0.25rem 0.5rem;
}

/* ─── Tour-active body lock ───────────────────────────────────────────────── */
body.guide-active {
  overflow: hidden;
}

/* Highlighted target element gets a visual ring — no position change to avoid
   breaking fixed/absolute ancestors (sidebar is z-index:100 in a grid). */
.guide-target-highlight {
  z-index: 10002 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35) !important;
  border-radius: var(--radius-sm, 6px);
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .guide-tooltip {
    width: calc(100vw - 24px);
    max-width: none;
    left: 12px !important;
    right: 12px !important;
  }

  .guide-splash {
    width: calc(100vw - 24px);
    padding: 1.5rem 1.2rem;
  }
}

/* Phones: the nav rail becomes a fixed 60px bottom tab bar — float the help
   button above it, or it covers the last tab (Admin). */
@media (max-width: 767px) {
  .guide-help-btn {
    width: 40px;
    height: 40px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: 14px;
    font-size: 1rem;
  }

  .guide-help-menu {
    right: 14px;
    bottom: calc(120px + env(safe-area-inset-bottom));
  }
}
