/**
 * ActivGate Onboarding System
 * ============================
 * Styles for welcome experience, feature tours, and progress tracking.
 *
 * Components:
 * - Welcome Modal (.ag-welcome-*)
 * - Feature Tour (.ag-tour-*)
 * - Progress Checklist (.ag-checklist-*)
 * - Profile Completion (.ag-profile-progress-*)
 * - Contextual Tips (.ag-tip-*)
 */

/* ==========================================================================
   1. Welcome Modal
   ========================================================================== */

.ag-welcome-modal {
  position: fixed;
  inset: 0;
  z-index: var(--ag-z-modal, 1000);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--ag-space-4);
}

.ag-welcome-modal.is-open {
  display: flex;
}

.ag-welcome-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.ag-welcome-dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  background: var(--ag-color-bg-surface);
  border-radius: var(--ag-radius-2xl);
  box-shadow: var(--ag-shadow-2xl);
  animation: ag-modal-enter 0.3s ease-out;
}

.ag-welcome-header {
  position: relative;
  padding: var(--ag-space-8) var(--ag-space-6) var(--ag-space-4);
  text-align: center;
  background: linear-gradient(135deg, var(--ag-color-brand-primary), var(--ag-color-brand-secondary));
  color: var(--ag-color-text-on-dark);
  border-radius: var(--ag-radius-2xl) var(--ag-radius-2xl) 0 0;
}

.ag-welcome-illustration {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--ag-space-4);
}

.ag-welcome-illustration img,
.ag-welcome-illustration svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ag-welcome-title {
  margin: 0;
  font-size: var(--ag-font-size-2xl);
  font-weight: 600;
  font-family: var(--ag-font-serif);
}

.ag-welcome-subtitle {
  margin: var(--ag-space-2) 0 0;
  font-size: var(--ag-font-size-base);
  opacity: 0.9;
}

.ag-welcome-close {
  position: absolute;
  top: var(--ag-space-4);
  right: var(--ag-space-4);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: var(--ag-radius-lg);
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ag-welcome-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.ag-welcome-body {
  padding: var(--ag-space-6);
}

.ag-welcome-features {
  display: grid;
  gap: var(--ag-space-4);
  margin-bottom: var(--ag-space-6);
}

.ag-welcome-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--ag-space-4);
  padding: var(--ag-space-4);
  background: var(--ag-color-bg-surface-alt);
  border-radius: var(--ag-radius-lg);
}

.ag-welcome-feature-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--ag-color-brand-primary), var(--ag-color-brand-accent));
  border-radius: var(--ag-radius-lg);
  color: white;
  font-size: 24px;
}

.ag-welcome-feature-content h3 {
  margin: 0 0 var(--ag-space-1);
  font-size: var(--ag-font-size-base);
  font-weight: 600;
  color: var(--ag-color-text-heading);
}

.ag-welcome-feature-content p {
  margin: 0;
  font-size: var(--ag-font-size-sm);
  color: var(--ag-color-text-muted);
  line-height: 1.5;
}

.ag-welcome-actions {
  display: flex;
  gap: var(--ag-space-3);
  justify-content: center;
}

.ag-welcome-actions .ag-btn {
  min-width: 140px;
}

/* ==========================================================================
   2. Feature Tour
   ========================================================================== */

.ag-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--ag-z-modal, 1000) + 10);
  pointer-events: none;
}

.ag-tour-highlight {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75);
  border-radius: var(--ag-radius-lg);
  pointer-events: auto;
  animation: ag-pulse-ring 2s ease infinite;
}

.ag-tour-tooltip {
  position: absolute;
  z-index: calc(var(--ag-z-modal, 1000) + 20);
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--ag-color-bg-surface);
  border-radius: var(--ag-radius-xl);
  box-shadow: var(--ag-shadow-2xl);
  pointer-events: auto;
  animation: ag-slide-up 0.3s ease-out;
}

.ag-tour-tooltip--top {
  transform: translateX(-50%);
}

.ag-tour-tooltip--bottom {
  transform: translateX(-50%);
}

.ag-tour-tooltip--left {
  transform: translateY(-50%);
}

.ag-tour-tooltip--right {
  transform: translateY(-50%);
}

.ag-tour-arrow {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--ag-color-bg-surface);
  transform: rotate(45deg);
}

.ag-tour-tooltip--top .ag-tour-arrow {
  bottom: -8px;
  left: 50%;
  margin-left: -8px;
}

.ag-tour-tooltip--bottom .ag-tour-arrow {
  top: -8px;
  left: 50%;
  margin-left: -8px;
}

.ag-tour-tooltip--left .ag-tour-arrow {
  right: -8px;
  top: 50%;
  margin-top: -8px;
}

.ag-tour-tooltip--right .ag-tour-arrow {
  left: -8px;
  top: 50%;
  margin-top: -8px;
}

.ag-tour-content {
  padding: var(--ag-space-4);
}

.ag-tour-step-indicator {
  display: flex;
  align-items: center;
  gap: var(--ag-space-2);
  margin-bottom: var(--ag-space-2);
}

.ag-tour-step-number {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ag-color-brand-primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  border-radius: 50%;
}

.ag-tour-step-label {
  font-size: var(--ag-font-size-xs);
  color: var(--ag-color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ag-tour-title {
  margin: 0 0 var(--ag-space-2);
  font-size: var(--ag-font-size-lg);
  font-weight: 600;
  color: var(--ag-color-text-heading);
}

.ag-tour-description {
  margin: 0;
  font-size: var(--ag-font-size-sm);
  color: var(--ag-color-text-body);
  line-height: 1.6;
}

.ag-tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--ag-space-3) var(--ag-space-4);
  border-top: 1px solid var(--ag-color-border);
  background: var(--ag-color-bg-surface-alt);
  border-radius: 0 0 var(--ag-radius-xl) var(--ag-radius-xl);
}

.ag-tour-skip {
  background: none;
  border: none;
  color: var(--ag-color-text-muted);
  font-size: var(--ag-font-size-sm);
  cursor: pointer;
  padding: var(--ag-space-2);
}

.ag-tour-skip:hover {
  color: var(--ag-color-text-body);
}

.ag-tour-nav {
  display: flex;
  gap: var(--ag-space-2);
}

.ag-tour-dots {
  display: flex;
  align-items: center;
  gap: var(--ag-space-1);
}

.ag-tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ag-color-border);
  transition: background 0.2s ease, transform 0.2s ease;
}

.ag-tour-dot.is-active {
  background: var(--ag-color-brand-primary);
  transform: scale(1.25);
}

.ag-tour-dot.is-completed {
  background: var(--ag-color-success);
}

/* ==========================================================================
   3. Getting Started Checklist
   ========================================================================== */

.ag-checklist {
  background: var(--ag-color-surface, #ffffff);
  border: 1px solid var(--ag-color-border, #e5e7eb);
  border-radius: var(--ag-radius-xl, 16px);
  box-shadow: var(--ag-shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
  overflow: hidden;
}

.ag-checklist-header {
  padding: var(--ag-space-4);
  background: linear-gradient(135deg, var(--ag-color-brand-primary), var(--ag-color-brand-secondary));
  color: white;
}

.ag-checklist-title {
  margin: 0;
  font-size: var(--ag-text-lg, 18px);
  font-weight: 600;
  color: white;
}

.ag-checklist-progress {
  margin-top: var(--ag-space-3);
}

.ag-checklist-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--ag-radius-full);
  overflow: hidden;
}

.ag-checklist-progress-fill {
  height: 100%;
  background: white;
  border-radius: var(--ag-radius-full);
  transition: width 0.4s ease;
}

.ag-checklist-progress-text {
  display: flex;
  justify-content: space-between;
  margin-top: var(--ag-space-2);
  font-size: var(--ag-font-size-sm);
  opacity: 0.9;
}

.ag-checklist-body {
  padding: var(--ag-space-2) 0;
}

.ag-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: var(--ag-space-3);
  padding: var(--ag-space-3) var(--ag-space-4);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.ag-checklist-item:hover {
  background: var(--ag-color-surface-alt, #f8fafc);
}

.ag-checklist-item.is-completed {
  opacity: 0.6;
}

.ag-checklist-check {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ag-color-border, #e5e7eb);
  border-radius: 50%;
  background: var(--ag-color-surface, #ffffff);
  color: transparent;
  transition: all 0.2s ease;
}

.ag-checklist-item.is-completed .ag-checklist-check {
  background: var(--ag-color-success, #22c55e);
  border-color: var(--ag-color-success, #22c55e);
  color: white;
}

.ag-checklist-item-content {
  flex: 1;
  min-width: 0;
}

.ag-checklist-item-title {
  margin: 0;
  font-size: var(--ag-text-sm, 14px);
  font-weight: 600;
  color: var(--ag-color-text-heading, #111827);
}

.ag-checklist-item.is-completed .ag-checklist-item-title {
  text-decoration: line-through;
}

.ag-checklist-item-description {
  margin: var(--ag-space-1, 4px) 0 0;
  font-size: var(--ag-text-xs, 12px);
  color: var(--ag-color-text-muted, #6b7280);
  line-height: 1.5;
}

.ag-checklist-item-arrow {
  color: var(--ag-color-text-subtle);
  transition: transform 0.2s ease;
}

.ag-checklist-item:hover .ag-checklist-item-arrow {
  transform: translateX(4px);
  color: var(--ag-color-brand-primary);
}

.ag-checklist-dismiss {
  display: block;
  width: 100%;
  padding: var(--ag-space-3, 12px) var(--ag-space-4, 16px);
  border: none;
  border-top: 1px solid var(--ag-color-border, #e5e7eb);
  background: var(--ag-color-surface, #ffffff);
  color: var(--ag-color-text-muted, #6b7280);
  font-size: var(--ag-text-sm, 14px);
  cursor: pointer;
  transition: color 0.2s ease;
}

.ag-checklist-dismiss:hover {
  color: var(--ag-color-text-body);
}

/* Floating checklist widget */
.ag-checklist-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 90;
  width: 272px;
  max-width: calc(100vw - var(--ag-space-8, 32px));
}

.ag-checklist-widget.is-collapsed .ag-checklist-body,
.ag-checklist-widget.is-collapsed .ag-checklist-dismiss {
  display: none;
}

.ag-checklist-toggle {
  position: absolute;
  top: var(--ag-space-4, 16px);
  right: var(--ag-space-4, 16px);
  background: rgba(255, 255, 255, 0.25);
  border: none;
  border-radius: var(--ag-radius-md, 8px);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ag-checklist-toggle:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Show collapse icon (chevron up) when expanded, expand icon (chevron down) when collapsed */
.ag-checklist-toggle svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.ag-checklist-toggle__expand { display: none; }

.ag-checklist-widget.is-collapsed .ag-checklist-toggle__collapse { display: none; }
.ag-checklist-widget.is-collapsed .ag-checklist-toggle__expand { display: inline; }

/* ==========================================================================
   4. Profile Completion Progress
   ========================================================================== */

.ag-profile-progress {
  background: var(--ag-color-bg-surface);
  border: 1px solid var(--ag-color-border);
  border-radius: var(--ag-radius-xl);
  padding: var(--ag-space-4);
}

.ag-profile-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ag-space-3);
}

.ag-profile-progress-title {
  margin: 0;
  font-size: var(--ag-font-size-base);
  font-weight: 600;
  color: var(--ag-color-text-heading);
}

.ag-profile-progress-percent {
  font-size: var(--ag-font-size-2xl);
  font-weight: 600;
  color: var(--ag-color-brand-primary);
}

.ag-profile-progress-bar {
  height: 12px;
  background: var(--ag-color-bg-surface-alt);
  border-radius: var(--ag-radius-full);
  overflow: hidden;
}

.ag-profile-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ag-color-brand-primary), var(--ag-color-brand-accent));
  border-radius: var(--ag-radius-full);
  transition: width 0.5s ease;
}

.ag-profile-progress-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--ag-space-2);
  margin-top: var(--ag-space-4);
}

.ag-profile-progress-section {
  display: flex;
  align-items: center;
  gap: var(--ag-space-2);
  padding: var(--ag-space-2);
  border-radius: var(--ag-radius-md);
  font-size: var(--ag-font-size-xs);
  color: var(--ag-color-text-muted);
}

.ag-profile-progress-section.is-completed {
  color: var(--ag-color-success);
}

.ag-profile-progress-section-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ag-color-bg-surface-alt);
  font-size: 10px;
}

.ag-profile-progress-section.is-completed .ag-profile-progress-section-icon {
  background: var(--ag-color-success-soft);
}

/* ==========================================================================
   5. Contextual Tips
   ========================================================================== */

.ag-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ag-space-2);
  padding: var(--ag-space-3) var(--ag-space-4);
  background: var(--ag-color-info-soft);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--ag-radius-lg);
  font-size: var(--ag-font-size-sm);
  color: var(--ag-color-text-body);
  line-height: 1.5;
}

.ag-tip-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ag-color-brand-primary);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
}

.ag-tip-dismiss {
  position: absolute;
  top: var(--ag-space-2);
  right: var(--ag-space-2);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ag-color-text-muted);
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.ag-tip-dismiss:hover {
  opacity: 1;
}

/* Inline tip (within forms) */
.ag-tip--inline {
  margin: var(--ag-space-2) 0;
  width: 100%;
}

/* Floating tip (pointing to element) */
.ag-tip--floating {
  position: absolute;
  z-index: var(--ag-z-popover);
  max-width: 280px;
  box-shadow: var(--ag-shadow-lg);
}

/* Spotlight highlight for tips */
.ag-spotlight {
  position: relative;
}

.ag-spotlight::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px dashed var(--ag-color-brand-primary);
  border-radius: var(--ag-radius-lg);
  pointer-events: none;
  animation: ag-pulse-border 2s ease infinite;
}

/* ==========================================================================
   6. Empty States
   ========================================================================== */

.ag-empty-state {
  text-align: center;
  padding: var(--ag-space-12) var(--ag-space-6);
  max-width: 400px;
  margin: 0 auto;
}

.ag-empty-state-illustration {
  width: 200px;
  height: 160px;
  margin: 0 auto var(--ag-space-6);
}

.ag-empty-state-illustration img,
.ag-empty-state-illustration svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ag-empty-state-title {
  margin: 0 0 var(--ag-space-2);
  font-size: var(--ag-font-size-xl);
  font-weight: 600;
  color: var(--ag-color-text-heading);
}

.ag-empty-state-description {
  margin: 0 0 var(--ag-space-6);
  font-size: var(--ag-font-size-base);
  color: var(--ag-color-text-muted);
  line-height: 1.6;
}

.ag-empty-state-suggestions {
  text-align: left;
  background: var(--ag-color-bg-surface-alt);
  border-radius: var(--ag-radius-lg);
  padding: var(--ag-space-4);
  margin-top: var(--ag-space-6);
}

.ag-empty-state-suggestions-title {
  margin: 0 0 var(--ag-space-3);
  font-size: var(--ag-font-size-sm);
  font-weight: 600;
  color: var(--ag-color-text-heading);
}

.ag-empty-state-suggestions-list {
  margin: 0;
  padding: 0 0 0 var(--ag-space-4);
  font-size: var(--ag-font-size-sm);
  color: var(--ag-color-text-muted);
  line-height: 1.8;
}

/* ==========================================================================
   7. Animations
   ========================================================================== */

@keyframes ag-pulse-ring {
  0%, 100% {
    box-shadow:
      0 0 0 9999px rgba(15, 23, 42, 0.75),
      0 0 0 0 rgba(46, 116, 184, 0.4);
  }
  50% {
    box-shadow:
      0 0 0 9999px rgba(15, 23, 42, 0.75),
      0 0 0 8px rgba(46, 116, 184, 0);
  }
}

@keyframes ag-pulse-border {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ==========================================================================
   9. Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .ag-welcome-dialog,
  .ag-tour-tooltip,
  .ag-tour-highlight,
  .ag-checklist-progress-fill,
  .ag-profile-progress-fill {
    animation: none;
    transition: none;
  }
}

/* ==========================================================================
   10. Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .ag-checklist-widget {
    left: 16px;
    bottom: 16px;
    width: calc(100vw - 32px);
  }

  .ag-welcome-dialog {
    max-width: calc(100vw - var(--ag-space-8));
    margin: var(--ag-space-4);
  }

  .ag-welcome-header {
    padding: var(--ag-space-6) var(--ag-space-4) var(--ag-space-4);
  }

  .ag-welcome-body {
    padding: var(--ag-space-4);
  }

  .ag-tour-tooltip {
    width: calc(100vw - 32px);
    max-width: none;
    position: fixed !important;
    bottom: 16px !important;
    left: 16px !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
  }

  .ag-tour-arrow {
    display: none;
  }
}
