/**
 * Tutorial System Styles
 *
 * Styles for the interactive tutorial overlay, tooltips, and animations.
 * Supports both light and dark themes.
 */

 :root {
    /* Light theme variables */
    --tutorial-tip-bg-color: #fff;
    --tutorial-tip-text-color: #333333;
    --tutorial-bg-secondary: #dedede;
}

body.dark-theme {
    /* Dark theme variables */
    --tutorial-tip-bg-color: #525354;
    --tutorial-tip-text-color: #fff;
    --tutorial-bg-secondary: #f5f5f5;
}

/* ============================================================================
   Overlay & Backdrop
   ============================================================================ */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent; /* No background by default - dimming is done via spotlight box-shadow */
    z-index: 999998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Dimmed background for center mode (Welcome step) */
.tutorial-overlay.dimmed {
    background: rgba(0, 0, 0, 0.5);
}

/* ============================================================================
   Spotlight (Highlighted Element)
   ============================================================================ */

.tutorial-spotlight {
    position: absolute;
    border: 3px solid var(--primary-color, #4A90E2);
    border-radius: 8px;
    pointer-events: none; /* Allow clicks through to highlighted element */
    transition: all 0.3s ease;
    z-index: 999999; /* Higher than everything to show the border */
    animation: spotlight-pulse 2s ease-in-out infinite;
    /* Use massive box-shadow to dim everything EXCEPT the highlighted area */
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5), /* Huge spread creates dimming around spotlight */
                0 0 20px 5px rgba(74, 144, 226, 0.6), /* Blue glow */
                0 0 40px 10px rgba(74, 144, 226, 0.4); /* Outer blue glow */
    background: transparent;
}

@keyframes spotlight-pulse {
    0%, 100% {
        border-color: var(--primary-color, #4A90E2);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5),
                    0 0 20px 5px rgba(74, 144, 226, 0.6),
                    0 0 40px 10px rgba(74, 144, 226, 0.4);
    }
    50% {
        border-color: rgba(74, 144, 226, 1);
        border-width: 4px;
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5),
                    0 0 30px 8px rgba(74, 144, 226, 0.8),
                    0 0 60px 15px rgba(74, 144, 226, 0.5);
    }
}

/* ============================================================================
   Tooltip
   ============================================================================ */

.tutorial-tooltip {
    position: fixed;
    background: var(--tutorial-tip-bg-color, #ffffff);
    color: var(--tutorial-tip-text-color, #333333);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                0 4px 16px rgba(0, 0, 0, 0.2),
                0 0 2px rgba(0, 0, 0, 0.1); /* Strong shadow to stand out */
    max-width: 550px; /* Increased from 400px to accommodate more content */
    min-width: 320px;
    z-index: 1000000;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1); /* Subtle border for definition */
}

.tutorial-tooltip.active {
    opacity: 1;
}

/* ============================================================================
   Tooltip Content
   ============================================================================ */

.tutorial-tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tutorial-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 20px 0 20px;
    gap: 12px;
}

.tutorial-tooltip-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--tutorial-tip-text-color, #333333);
    line-height: 1.3;
}

.tutorial-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--tutorial-tip-text-color, #666666);
    padding: 15px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.tutorial-close-btn:hover {
    background: var(--hover-bg, #f5f5f5);
    color: #333333;
}

body.dark-mode .tutorial-close-btn {
    color: var(--secondary-text, #999999);
}

body.dark-mode .tutorial-close-btn:hover {
    background: var(--hover-bg, #3a3a3a);
    color: var(--text-color, #e0e0e0);
}

.tutorial-tooltip-body {
    padding: 0 20px;
}

.tutorial-tooltip-description {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    color: var(--message-bot-color, #666666);
    white-space: pre-wrap; /* Preserve line breaks and formatting */
}

.tutorial-tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px 20px 20px;
    gap: 12px;
}

.tutorial-btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.tutorial-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    white-space: nowrap;
}

.tutorial-btn:focus {
    outline: 2px solid var(--primary-color, #4A90E2);
    outline-offset: 2px;
}

/* Primary button */
.tutorial-btn-primary {
    background: var(--primary-color, #4A90E2);
    color: white;
}

.tutorial-btn-primary:hover {
    background: var(--primary-hover, #357ABD);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
}

.tutorial-btn-primary:active {
    transform: translateY(0);
}

body.dark-mode .tutorial-btn-primary:hover {
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.5);
}

/* Secondary button */
.tutorial-btn-secondary {
    background: var(--tutorial-bg-secondary, #f5f5f5);
    color: #333333;
}

.tutorial-btn-secondary:hover {
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(168, 168, 168, 0.3);
}

/* Info button (Jump to step) */
.tutorial-btn-info {
    background: var(--tutorial-info-bg, #17a2b8);
    color: white;
}

.tutorial-btn-info:hover {
    background: var(--tutorial-info-hover, #138496);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(23, 162, 184, 0.3);
}

.tutorial-btn-info:active {
    transform: translateY(0);
}

body.dark-mode .tutorial-btn-info:hover {
    box-shadow: 0 4px 8px rgba(23, 162, 184, 0.5);
}

/* Text button (Skip) */
.tutorial-btn-text {
    background: transparent;
    color: var(--secondary-text, #666666);
    padding: 10px 12px;
}

.tutorial-btn-text:hover {
    background: var(--hover-bg, #f5f5f5);
    color: var(--text-color, #333333);
}

body.dark-mode .tutorial-btn-text {
    color: var(--secondary-text, #999999);
}

body.dark-mode .tutorial-btn-text:hover {
    background: var(--hover-bg, #3a3a3a);
    color: var(--text-color, #e0e0e0);
}

/* ============================================================================
   Highlight Animations
   ============================================================================ */

/* Pulse highlight (for clickable elements) */
.pulse-highlight {
    animation: tutorial-pulse 1.5s ease-in-out infinite;
}

@keyframes tutorial-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 8px rgba(74, 144, 226, 0);
    }
}

/* Glow highlight (for informational elements) */
.glow-highlight {
    animation: tutorial-glow 2s ease-in-out infinite;
}

@keyframes tutorial-glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(74, 144, 226, 0.6);
    }
}

/* ============================================================================
   Notification Badge & Arrow (for user menu)
   ============================================================================ */

/* Small badge for menu item */
.tutorial-notification-badge {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    animation: tutorial-badge-pulse 2s ease-in-out infinite;
    z-index: 10;
}

@keyframes tutorial-badge-pulse {
    0%, 100% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) scale(1.3);
        opacity: 0.8;
    }
}

/* Animated arrow pointing to user avatar */
.tutorial-notification-arrow {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: var(--primary-color, #4A90E2);
    animation: tutorial-arrow-bounce 1.2s ease-in-out infinite;
    z-index: 1000;
    pointer-events: none;
}

body.dark-mode .tutorial-notification-arrow {
    color: var(--primary-color, #6BB6FF);
}

@keyframes tutorial-arrow-bounce {
    0%, 100% {
        transform: translateY(-50%) translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) translateX(-8px);
        opacity: 0.7;
    }
}

/* Animated arrow for menu item (deprecated - kept for compatibility) */
.tutorial-menu-arrow {
    position: absolute;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--primary-color, #4A90E2);
    animation: tutorial-arrow-bounce 1s ease-in-out infinite;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
    .tutorial-tooltip {
        max-width: calc(100vw - 40px);
        min-width: auto;
        width: calc(100vw - 40px);
    }

    .tutorial-tooltip-title {
        font-size: 16px;
    }

    .tutorial-tooltip-description {
        font-size: 13px;
    }

    .tutorial-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .tutorial-tooltip-footer {
        flex-direction: column;
        gap: 8px;
    }

    .tutorial-btn-group {
        width: 100%;
        justify-content: flex-end;
    }

    .tutorial-btn-secondary {
        width: 100%;
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tutorial-spotlight {
        border-width: 4px;
    }

    .tutorial-tooltip {
        border: 2px solid var(--text-color, #333333);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tutorial-overlay,
    .tutorial-tooltip,
    .tutorial-spotlight,
    .pulse-highlight,
    .glow-highlight,
    .tutorial-notification-badge,
    .tutorial-menu-arrow {
        animation: none !important;
        transition: none !important;
    }

    .tutorial-btn:hover {
        transform: none !important;
    }
}

/* Focus visible for keyboard navigation */
.tutorial-btn:focus-visible {
    outline: 2px solid var(--primary-color, #4A90E2);
    outline-offset: 2px;
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
    .tutorial-overlay,
    .tutorial-spotlight,
    .tutorial-tooltip,
    .tutorial-notification-badge,
    .tutorial-menu-arrow {
        display: none !important;
    }
}
