/**
 * Onboarding Tutorial Styles
 *
 * Spotlight-style guided tour with overlay and tooltips.
 */

/* ===================================================================
   OVERLAY
   =================================================================== */

.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    /* No background here - let spotlight box-shadow handle darkening */
    background: transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tutorial-overlay--active {
    opacity: 1;
    visibility: visible;
}

/* ===================================================================
   SPOTLIGHT
   =================================================================== */

.tutorial-spotlight-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.tutorial-spotlight {
    position: fixed;
    border-radius: 12px;
    /* Transparent background lets the actual highlighted content show through */
    background: transparent;
    /* Strong box-shadow creates the dark overlay around the spotlight */
    /* Inset shadow adds a subtle inner glow to brighten the highlighted area */
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.85),
        inset 0 0 0 3px rgba(255, 255, 255, 0.95),
        inset 0 0 30px 10px rgba(255, 255, 255, 0.15),
        0 0 20px 4px rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Subtle pulse animation on spotlight border */
@keyframes spotlightPulse {
    0%, 100% {
        box-shadow:
            0 0 0 9999px rgba(0, 0, 0, 0.85),
            inset 0 0 0 3px rgba(255, 255, 255, 0.95),
            inset 0 0 30px 10px rgba(255, 255, 255, 0.15),
            0 0 20px 4px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow:
            0 0 0 9999px rgba(0, 0, 0, 0.85),
            inset 0 0 0 4px rgba(255, 255, 255, 0.8),
            inset 0 0 40px 15px rgba(255, 255, 255, 0.1),
            0 0 30px 8px rgba(255, 255, 255, 0.4);
    }
}

.tutorial-overlay--active .tutorial-spotlight {
    animation: spotlightPulse 2s ease-in-out infinite;
}

/* ===================================================================
   TOOLTIP
   =================================================================== */

.tutorial-tooltip {
    position: fixed;
    z-index: 9999;
    width: 440px;
    max-width: calc(100vw - 32px);
    background: white;
    border-radius: 16px;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

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

/* Arrow */
.tutorial-tooltip::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);
}

.tutorial-tooltip--top::before {
    bottom: -8px;
    left: 50%;
    margin-left: -8px;
}

.tutorial-tooltip--bottom::before {
    top: -8px;
    left: 50%;
    margin-left: -8px;
}

.tutorial-tooltip--left::before {
    right: -8px;
    top: 50%;
    margin-top: -8px;
}

.tutorial-tooltip--right::before {
    left: -8px;
    top: 50%;
    margin-top: -8px;
}

/* ===================================================================
   TOOLTIP CONTENT
   =================================================================== */

.tutorial-tooltip__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 12px;
}

.tutorial-tooltip__icon {
    font-size: 28px;
    line-height: 1;
}

.tutorial-tooltip__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-gray-900, #111827);
    line-height: 1.3;
}

.tutorial-tooltip__content {
    margin: 0;
    padding: 0 20px 16px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-gray-600, #4B5563);
}

/* ===================================================================
   FOOTER & ACTIONS
   =================================================================== */

.tutorial-tooltip__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--color-gray-100, #F3F4F6);
    background: var(--color-gray-50, #F9FAFB);
    border-radius: 0 0 16px 16px;
    gap: 12px;
}

/* Progress dots */
.tutorial-tooltip__progress {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.tutorial-progress-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-gray-300, #D1D5DB);
    transition: all 0.2s ease;
}

.tutorial-progress-dot--active {
    background: var(--color-primary-600, #1E4A86);
    transform: scale(1.2);
}

.tutorial-progress-dot--completed {
    background: var(--color-success, #10B981);
}

/* Action buttons */
.tutorial-tooltip__actions {
    display: flex;
    gap: 10px;
}

.tutorial-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.tutorial-btn--skip {
    background: transparent;
    color: var(--color-gray-500, #6B7280);
}

.tutorial-btn--skip:hover {
    color: var(--color-gray-700, #374151);
    background: var(--color-gray-100, #F3F4F6);
}

.tutorial-btn--back {
    background: var(--color-gray-100, #F3F4F6);
    color: var(--color-gray-700, #374151);
}

.tutorial-btn--back:hover {
    background: var(--color-gray-200, #E5E7EB);
    color: var(--color-gray-900, #111827);
}

.tutorial-btn--next {
    background: var(--color-primary-700, #163A6B);
    color: white;
}

.tutorial-btn--next:hover {
    background: var(--color-primary-800, #0F2B51);
}

.tutorial-btn--next:focus-visible,
.tutorial-btn--back:focus-visible {
    outline: 2px solid var(--color-primary-500, #2659A0);
    outline-offset: 2px;
}

.tutorial-btn svg {
    width: 14px;
    height: 14px;
}

/* Nav buttons container (Back + Next) */
.tutorial-tooltip__nav-buttons {
    display: flex;
    gap: 8px;
}

/* ===================================================================
   MOBILE ADJUSTMENTS
   =================================================================== */

@media (max-width: 640px) {
    .tutorial-tooltip {
        width: calc(100vw - 32px);
        max-width: none;
        left: 16px !important;
        right: 16px !important;
    }

    .tutorial-tooltip__header {
        padding: 16px 16px 10px;
    }

    .tutorial-tooltip__icon {
        font-size: 24px;
    }

    .tutorial-tooltip__title {
        font-size: 16px;
    }

    .tutorial-tooltip__content {
        padding: 0 16px 12px;
        font-size: 14px;
    }

    .tutorial-tooltip__footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
    }

    .tutorial-tooltip__actions {
        width: 100%;
        justify-content: space-between;
    }

    .tutorial-tooltip__nav-buttons {
        flex: 1;
        justify-content: flex-end;
    }

    .tutorial-btn {
        justify-content: center;
    }

    .tutorial-btn--skip {
        flex-shrink: 0;
    }

    .tutorial-btn--back,
    .tutorial-btn--next {
        padding: 8px 12px;
    }

    /* Adjust arrow for mobile */
    .tutorial-tooltip--top::before,
    .tutorial-tooltip--bottom::before {
        left: 50%;
    }
}

/* ===================================================================
   REDUCED MOTION
   =================================================================== */

@media (prefers-reduced-motion: reduce) {
    .tutorial-overlay {
        transition: opacity 0.15s ease;
    }

    .tutorial-spotlight {
        transition: none;
        animation: none !important;
    }

    .tutorial-tooltip {
        transition: opacity 0.15s ease;
        transform: none;
    }

    .tutorial-tooltip--visible {
        transform: none;
    }
}

/* ===================================================================
   FORCE LIGHT MODE DURING TUTORIAL
   =================================================================== */

/*
 * The tutorial always displays in light/bright mode for maximum contrast,
 * regardless of the user's theme preference (dark, sepia, or system dark mode).
 * This ensures the spotlight highlight is clearly visible against the dark overlay.
 */

/* Override dark theme when tutorial is active */
[data-theme="dark"] .tutorial-tooltip,
[data-theme="sepia"] .tutorial-tooltip,
.tutorial-tooltip {
    background: white !important;
}

[data-theme="dark"] .tutorial-tooltip::before,
[data-theme="sepia"] .tutorial-tooltip::before,
.tutorial-tooltip::before {
    background: white !important;
}

[data-theme="dark"] .tutorial-tooltip__title,
[data-theme="sepia"] .tutorial-tooltip__title,
.tutorial-tooltip__title {
    color: #111827 !important;
}

[data-theme="dark"] .tutorial-tooltip__content,
[data-theme="sepia"] .tutorial-tooltip__content,
.tutorial-tooltip__content {
    color: #4B5563 !important;
}

[data-theme="dark"] .tutorial-tooltip__footer,
[data-theme="sepia"] .tutorial-tooltip__footer,
.tutorial-tooltip__footer {
    background: #F9FAFB !important;
    border-color: #F3F4F6 !important;
}

[data-theme="dark"] .tutorial-btn--skip,
[data-theme="sepia"] .tutorial-btn--skip,
.tutorial-btn--skip {
    color: #6B7280 !important;
    background: transparent !important;
}

[data-theme="dark"] .tutorial-btn--skip:hover,
[data-theme="sepia"] .tutorial-btn--skip:hover,
.tutorial-btn--skip:hover {
    color: #374151 !important;
    background: #F3F4F6 !important;
}

[data-theme="dark"] .tutorial-btn--back,
[data-theme="sepia"] .tutorial-btn--back,
.tutorial-btn--back {
    background: #F3F4F6 !important;
    color: #374151 !important;
}

[data-theme="dark"] .tutorial-btn--back:hover,
[data-theme="sepia"] .tutorial-btn--back:hover,
.tutorial-btn--back:hover {
    background: #E5E7EB !important;
    color: #111827 !important;
}

[data-theme="dark"] .tutorial-btn--next,
[data-theme="sepia"] .tutorial-btn--next,
.tutorial-btn--next {
    background: #163A6B !important;
    color: white !important;
}

[data-theme="dark"] .tutorial-btn--next:hover,
[data-theme="sepia"] .tutorial-btn--next:hover,
.tutorial-btn--next:hover {
    background: #0F2B51 !important;
}

[data-theme="dark"] .tutorial-progress-dot,
[data-theme="sepia"] .tutorial-progress-dot,
.tutorial-progress-dot {
    background: #D1D5DB !important;
}

[data-theme="dark"] .tutorial-progress-dot--active,
[data-theme="sepia"] .tutorial-progress-dot--active,
.tutorial-progress-dot--active {
    background: #1E4A86 !important;
}

[data-theme="dark"] .tutorial-progress-dot--completed,
[data-theme="sepia"] .tutorial-progress-dot--completed,
.tutorial-progress-dot--completed {
    background: #10B981 !important;
}

/* Ensure spotlight stays transparent in all themes so content shows through */
[data-theme="dark"] .tutorial-spotlight,
[data-theme="sepia"] .tutorial-spotlight,
.tutorial-spotlight {
    background: transparent !important;
}

/* Also handle system-level dark mode preference */
@media (prefers-color-scheme: dark) {
    .tutorial-tooltip {
        background: white !important;
    }

    .tutorial-tooltip::before {
        background: white !important;
    }

    .tutorial-tooltip__title {
        color: #111827 !important;
    }

    .tutorial-tooltip__content {
        color: #4B5563 !important;
    }

    .tutorial-tooltip__footer {
        background: #F9FAFB !important;
        border-color: #F3F4F6 !important;
    }

    .tutorial-btn--skip {
        color: #6B7280 !important;
    }

    .tutorial-btn--skip:hover {
        color: #374151 !important;
        background: #F3F4F6 !important;
    }

    .tutorial-btn--back {
        background: #F3F4F6 !important;
        color: #374151 !important;
    }

    .tutorial-btn--back:hover {
        background: #E5E7EB !important;
        color: #111827 !important;
    }

    .tutorial-progress-dot {
        background: #D1D5DB !important;
    }

    .tutorial-spotlight {
        background: transparent !important;
    }
}
