/* ============================================================
   SHEPHERD.JS — NexiBook Dark Theme Override
   Replaces the default white Shepherd modals with dark-themed,
   high-contrast modals matching NexiBook Gold DNA.
   ============================================================ */

/* ---- Modal element (the popup card) ---- */
.shepherd-element {
  background: var(--color-bg-elevated, #1a1d24) !important;
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1)) !important;
  border-radius: 16px !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(var(--color-primary-rgb), 0.08) !important;
  max-width: 420px !important;
  z-index: 10000 !important;
}

/* ---- Arrow ---- */
.shepherd-arrow,
.shepherd-arrow::before {
  background: var(--color-bg-elevated, #1a1d24) !important;
  border: none !important;
}

/* ---- Header ---- */
.shepherd-header {
  background: transparent !important;
  padding: 1.25rem 1.25rem 0 !important;
  border-bottom: none !important;
}

.shepherd-title {
  color: var(--color-primary) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif !important;
  letter-spacing: -0.01em !important;
}

.shepherd-cancel-icon {
  color: rgba(255, 255, 255, 0.4) !important;
  font-size: 1.75em !important;
  transition: color 0.2s ease !important;
}

.shepherd-cancel-icon:hover {
  color: var(--color-primary) !important;
}

/* ---- Text content ---- */
.shepherd-text {
  color: var(--color-text, #F1F5F9) !important;
  font-size: 0.9rem !important;
  line-height: 1.65 !important;
  padding: 1rem 1.25rem !important;
  font-family: 'Inter', sans-serif !important;
}

.shepherd-text h4 {
  color: var(--color-primary) !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  margin: 0 0 0.5rem 0 !important;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif !important;
}

.shepherd-text p {
  color: var(--color-text-secondary, #94A3B8) !important;
  margin-bottom: 0.5rem !important;
}

.shepherd-text p:last-child {
  margin-bottom: 0 !important;
}

.shepherd-text .text-muted {
  color: var(--color-text-muted, #64748B) !important;
}

.shepherd-text strong {
  color: var(--color-text, #F1F5F9) !important;
  font-weight: 600 !important;
}

.shepherd-text ul,
.shepherd-text ol {
  padding-left: 1.2rem !important;
  margin: 0.5rem 0 !important;
}

.shepherd-text li {
  color: var(--color-text-secondary, #94A3B8) !important;
  margin-bottom: 0.35rem !important;
  font-size: 0.85rem !important;
}

.shepherd-text li strong {
  color: var(--color-primary) !important;
}

/* ---- Footer / Buttons ---- */
.shepherd-footer {
  padding: 0.75rem 1.25rem 1.25rem !important;
  border-top: none !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 0.5rem !important;
}

/* Primary button — gold */
.shepherd-button,
.shepherd-button-primary,
.shepherd-button.shepherd-button-primary {
  background: var(--color-primary) !important;
  color: #0F172A !important;
  border: none !important;
  border-radius: 10px !important;
  padding: 0.55rem 1.25rem !important;
  font-weight: 600 !important;
  font-size: 0.875rem !important;
  font-family: 'Inter', sans-serif !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.2) !important;
}

.shepherd-button:hover,
.shepherd-button-primary:hover {
  background: #FFC800 !important;
  box-shadow: 0 4px 16px rgba(var(--color-primary-rgb), 0.35) !important;
  transform: translateY(-1px) !important;
}

.shepherd-button:active,
.shepherd-button-primary:active {
  transform: translateY(0) !important;
}

/* Secondary button — ghost */
.shepherd-button-secondary,
.shepherd-button.shepherd-button-secondary {
  background: transparent !important;
  color: var(--color-text-secondary, #94A3B8) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 10px !important;
  padding: 0.55rem 1.25rem !important;
  font-weight: 500 !important;
  font-size: 0.875rem !important;
  font-family: 'Inter', sans-serif !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
}

.shepherd-button-secondary:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--color-text, #F1F5F9) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* ---- Modal overlay — darker for better focus ---- */
.shepherd-modal-overlay-container {
  fill: rgba(0, 0, 0, 0.65) !important;
}

/* ---- Highlighted element — gold glow ring ---- */
.shepherd-target.shepherd-enabled {
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.35) !important;
  border-radius: 8px !important;
  transition: box-shadow 0.3s ease !important;
}

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
  .shepherd-element {
    max-width: calc(100vw - 32px) !important;
    margin: 0 16px !important;
    border-radius: 12px !important;
  }

  .shepherd-header {
    padding: 1rem 1rem 0 !important;
  }

  .shepherd-text {
    padding: 0.75rem 1rem !important;
    font-size: 0.85rem !important;
  }

  .shepherd-text h4 {
    font-size: 1rem !important;
  }

  .shepherd-footer {
    padding: 0.5rem 1rem 1rem !important;
    flex-wrap: wrap !important;
  }

  .shepherd-button,
  .shepherd-button-primary,
  .shepherd-button-secondary {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
  }
}

/* ---- Light theme adaptation ---- */
[data-theme="light"] .shepherd-element {
  background: #FFFFFF !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(var(--color-primary-rgb), 0.15) !important;
}

[data-theme="light"] .shepherd-arrow,
[data-theme="light"] .shepherd-arrow::before {
  background: #FFFFFF !important;
}

[data-theme="light"] .shepherd-text {
  color: #1E293B !important;
}

[data-theme="light"] .shepherd-text p {
  color: #475569 !important;
}

[data-theme="light"] .shepherd-text strong {
  color: #0F172A !important;
}

[data-theme="light"] .shepherd-text li {
  color: #475569 !important;
}

[data-theme="light"] .shepherd-text li strong {
  color: #B8860B !important;
}

[data-theme="light"] .shepherd-text .text-muted {
  color: #64748B !important;
}

[data-theme="light"] .shepherd-cancel-icon {
  color: rgba(0, 0, 0, 0.35) !important;
}

[data-theme="light"] .shepherd-cancel-icon:hover {
  color: #B8860B !important;
}

[data-theme="light"] .shepherd-button-secondary {
  color: #475569 !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .shepherd-button-secondary:hover {
  background: rgba(0, 0, 0, 0.04) !important;
  color: #0F172A !important;
}

[data-theme="light"] .shepherd-modal-overlay-container {
  fill: rgba(0, 0, 0, 0.45) !important;
}

[data-theme="light"] .shepherd-target.shepherd-enabled {
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.3) !important;
}

/* ---- Containing block fix for fixed positioning ---- */
/* body/html may have "contain: content" (includes "paint") which creates
   a new containing block, breaking position:fixed relative to viewport.
   Remove containment during tours so fixed positioning works correctly. */
body.shepherd-has-active-tour,
html:has(.shepherd-has-active-tour) {
  contain: none !important;
}

/* ---- Centered steps (no attachTo — e.g. welcome step) ---- */
/* Floating UI sets inline styles (WITHOUT !important) for positioning.
   CSS !important beats inline styles per CSS cascade, so we use CSS-only
   centering via inset:0 + margin:auto — no transform needed, immune to
   the trial-tenant transform:none rule. */
.shepherd-element.shepherd-centered,
.shepherd-element.shepherd-force-center {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  height: fit-content !important;
  z-index: 10001 !important;
  width: 90vw !important;
  max-width: 420px !important;
}

/* ---- Animation ---- */
/* IMPORTANT: Animations must NEVER set the 'transform' property.
   Floating UI (used by Shepherd v11) controls transforms via inline
   styles for positioning. CSS animations with transform + !important
   override inline styles and break positioning completely.
   Only opacity-based animations are safe. */

/* Gentle fade-in for all steps */
.shepherd-element {
  animation: shepherdFadeIn 0.25s ease-out;
}

@keyframes shepherdFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─────────────────────────────────────────────────────────────
   CRITICAL FIX: Kill ALL CSS transforms on non-Shepherd elements
   when a tour is active.

   WHY: CSS transforms on any ancestor element create a new
   "containing block" per CSS spec. This makes position:fixed
   and Floating UI calculations break — popups appear at random
   positions instead of near their target elements.

   The body class is added by tour.js on tour start and removed
   on complete/cancel (Shepherd v11 doesn't add it natively).
   ───────────────────────────────────────────────────────────── */
body.shepherd-has-active-tour *:not([class*="shepherd"]):not([data-popper-placement]):not([data-popper-arrow]):not(.shepherd-modal-overlay-container) {
  transform: none !important;
  will-change: auto !important;
  animation: none !important;
}

/* Ensure the modal overlay SVG container is not affected */
body.shepherd-has-active-tour .shepherd-modal-overlay-container {
  transform: unset;
  animation: unset;
}
