/* ============================================
   Tutorial / Guided Tour System
   ============================================ */

/* ── Overlay Backdrop ─────────────────────── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 99990;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.tutorial-overlay.active {
  pointer-events: auto;
}

/* Spotlight cutout using box-shadow */
.tutorial-spotlight {
  position: fixed;
  z-index: 99991;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
  transition: all 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Pulsing ring around spotlight */
.tutorial-spotlight::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 14px;
  border: 2.5px solid var(--accent, #6c5ce7);
  animation: tutorialSpotlightPulse 2s ease-in-out infinite;
}
@keyframes tutorialSpotlightPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.03); }
}

/* ── Tooltip Card ─────────────────────────── */
.tutorial-tooltip {
  position: fixed;
  z-index: 99995;
  width: 370px;
  max-width: calc(100vw - 32px);
  background: rgba(30, 30, 50, 0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 0;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(108, 92, 231, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: tutorialTooltipEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  color: #f0f0f0;
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
}

[data-theme="light"] .tutorial-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1a1a2e;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 40px rgba(108, 92, 231, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

@keyframes tutorialTooltipEnter {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tooltip arrow (triangle) */
.tutorial-tooltip[data-position="bottom"]::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: rgba(30, 30, 50, 0.92);
}
[data-theme="light"] .tutorial-tooltip[data-position="bottom"]::before {
  border-bottom-color: rgba(255, 255, 255, 0.95);
}
.tutorial-tooltip[data-position="top"]::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(30, 30, 50, 0.92);
}
[data-theme="light"] .tutorial-tooltip[data-position="top"]::before {
  border-top-color: rgba(255, 255, 255, 0.95);
}
.tutorial-tooltip[data-position="left"]::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-left-color: rgba(30, 30, 50, 0.92);
}
.tutorial-tooltip[data-position="right"]::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  border: 8px solid transparent;
  border-right-color: rgba(30, 30, 50, 0.92);
}

/* ── Tooltip inner sections ──────────────── */
.tutorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
}
.tutorial-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #a29bfe;
  background: rgba(108, 92, 231, 0.15);
  padding: 4px 10px;
  border-radius: 20px;
}
[data-theme="light"] .tutorial-step-badge {
  background: rgba(108, 92, 231, 0.12);
  color: #6c5ce7;
}

.tutorial-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.tutorial-close-btn:hover {
  background: rgba(255, 60, 60, 0.25);
  color: #ff6b6b;
}

.tutorial-body {
  padding: 6px 18px 12px;
}
.tutorial-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.4;
}
.tutorial-description {
  font-size: 13.5px;
  line-height: 1.65;
  opacity: 0.85;
  margin: 0;
}

/* Animation preview area */
.tutorial-animation-area {
  padding: 0 18px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Typing animation */
.tutorial-typing-demo {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 14px;
  font-family: 'Fira Code', 'SF Mono', monospace;
  font-size: 13px;
  color: #74b9ff;
  min-height: 32px;
  overflow: hidden;
}
[data-theme="light"] .tutorial-typing-demo {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0984e3;
}
.tutorial-typing-text {
  display: inline;
  border-right: 2px solid currentColor;
  animation: tutorialBlink 0.7s step-end infinite;
  white-space: nowrap;
}
@keyframes tutorialBlink {
  50% { border-color: transparent; }
}

/* Click animation indicator */
.tutorial-click-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fd79a8;
  animation: tutorialClickBounce 1.2s ease-in-out infinite;
}
@keyframes tutorialClickBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* Scroll indicator */
.tutorial-scroll-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fdcb6e;
}
.tutorial-scroll-arrow {
  animation: tutorialScrollAnim 1.5s ease-in-out infinite;
}
@keyframes tutorialScrollAnim {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(6px); }
}

/* ── Footer / Navigation ─────────────────── */
.tutorial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
[data-theme="light"] .tutorial-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

/* Progress dots */
.tutorial-progress {
  display: flex;
  gap: 5px;
}
.tutorial-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: all 0.3s;
}
[data-theme="light"] .tutorial-dot {
  background: rgba(0, 0, 0, 0.12);
}
.tutorial-dot.active {
  background: #6c5ce7;
  width: 20px;
  border-radius: 10px;
}
.tutorial-dot.done {
  background: #00b894;
}

.tutorial-nav-buttons {
  display: flex;
  gap: 8px;
}
.tutorial-btn {
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.tutorial-btn-prev {
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}
.tutorial-btn-prev:hover {
  background: rgba(255, 255, 255, 0.15);
}
[data-theme="light"] .tutorial-btn-prev {
  background: rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .tutorial-btn-prev:hover {
  background: rgba(0, 0, 0, 0.12);
}

.tutorial-btn-next {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.35);
}
.tutorial-btn-next:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.5);
}
.tutorial-btn-finish {
  background: linear-gradient(135deg, #00b894, #55efc4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 184, 148, 0.35);
}

/* ── Floating Hand Pointer ───────────────── */
.tutorial-hand {
  position: fixed;
  z-index: 99993;
  font-size: 28px;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.tutorial-hand.click {
  animation: tutorialHandClick 1.4s ease-in-out infinite;
}
.tutorial-hand.type {
  animation: tutorialHandType 1s ease-in-out infinite;
}
@keyframes tutorialHandClick {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20%      { transform: translate(0, 6px) scale(0.9); }
  40%      { transform: translate(0, 0) scale(1); }
}
@keyframes tutorialHandType {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  75%      { transform: translateX(3px); }
}

/* Click ripple effect on highlighted element */
.tutorial-ripple {
  position: fixed;
  z-index: 99992;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  pointer-events: none;
}
.tutorial-ripple::before,
.tutorial-ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2.5px solid #6c5ce7;
  animation: tutorialRippleWave 1.8s ease-out infinite;
}
.tutorial-ripple::after {
  animation-delay: 0.5s;
}
@keyframes tutorialRippleWave {
  0%   { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ── Help FAB (Floating Action Button) ────── */
.tutorial-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99980;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  box-shadow:
    0 4px 20px rgba(108, 92, 231, 0.5),
    0 0 0 4px rgba(108, 92, 231, 0.15);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tutorialFabPulse 3s ease-in-out infinite;
}
.tutorial-fab:hover {
  transform: scale(1.1) rotate(-5deg);
  box-shadow:
    0 6px 28px rgba(108, 92, 231, 0.65),
    0 0 0 6px rgba(108, 92, 231, 0.2);
}
@keyframes tutorialFabPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(108,92,231,0.5), 0 0 0 4px rgba(108,92,231,0.15); }
  50%      { box-shadow: 0 4px 20px rgba(108,92,231,0.5), 0 0 0 8px rgba(108,92,231,0.08); }
}

/* FAB tooltip label */
.tutorial-fab-label {
  position: absolute;
  right: calc(100% + 10px);
  white-space: nowrap;
  background: rgba(30, 30, 50, 0.9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transform: translateX(5px);
  transition: all 0.3s;
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
}
[data-theme="light"] .tutorial-fab-label {
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.tutorial-fab:hover .tutorial-fab-label {
  opacity: 1;
  transform: translateX(0);
}

/* ── Tutorial Menu (page selector) ────────── */
.tutorial-menu {
  position: fixed;
  bottom: 86px;
  right: 24px;
  z-index: 99981;
  width: 280px;
  background: rgba(30, 30, 50, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: tutorialMenuEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: none;
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
}
[data-theme="light"] .tutorial-menu {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.tutorial-menu.show {
  display: block;
}
@keyframes tutorialMenuEnter {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tutorial-menu-title {
  padding: 10px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a29bfe;
  display: flex;
  align-items: center;
  gap: 6px;
}
[data-theme="light"] .tutorial-menu-title {
  color: #6c5ce7;
}

.tutorial-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: inherit;
  width: 100%;
  text-align: left;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.tutorial-menu-item:hover {
  background: rgba(108, 92, 231, 0.12);
}
.tutorial-menu-item .menu-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(108, 92, 231, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.tutorial-menu-item .menu-label {
  font-weight: 500;
}
.tutorial-menu-item .menu-steps {
  font-size: 11px;
  opacity: 0.5;
  margin-left: auto;
}

/* ── Welcome Modal ───────────────────────── */
.tutorial-welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tutorial-welcome-card {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: rgba(30, 30, 50, 0.95);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  animation: tutorialTooltipEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Noto Sans Thai', 'Inter', sans-serif;
  color: #f0f0f0;
}
[data-theme="light"] .tutorial-welcome-card {
  background: rgba(255, 255, 255, 0.97);
  color: #1a1a2e;
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 24px 60px rgba(0,0,0,0.15);
}
.tutorial-welcome-icon {
  font-size: 56px;
  margin-bottom: 12px;
  display: block;
}
.tutorial-welcome-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
}
.tutorial-welcome-card p {
  font-size: 14px;
  opacity: 0.75;
  line-height: 1.6;
  margin: 0 0 24px;
}
.tutorial-welcome-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.tutorial-welcome-actions .tutorial-btn {
  padding: 10px 24px;
  font-size: 14px;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 600px) {
  .tutorial-tooltip {
    width: calc(100vw - 24px);
    border-radius: 12px;
  }
  .tutorial-fab {
    bottom: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
    font-size: 20px;
  }
  .tutorial-menu {
    right: 16px;
    right: 16px;
    width: auto;
    bottom: 72px;
  }
}
