/**
 * Simulation Onboarding Styles
 * Responsive overlay system with spotlight effects and tooltips
 * Designed for accessibility and mobile optimization
 */

/* =======================
   Overlay System
   ======================= */

.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.onboarding-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.onboarding-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* =======================
   Spotlight Effects
   ======================= */

.onboarding-spotlight {
    position: relative;
    z-index: 10001;
    border-radius: 8px;
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.5),
        0 0 0 8px rgba(59, 130, 246, 0.25),
        0 0 50px rgba(59, 130, 246, 0.3);
    animation: spotlightPulse 2s ease-in-out infinite;
    transition: all 0.3s ease-out;
}

@keyframes spotlightPulse {
    0%, 100% { 
        box-shadow: 
            0 0 0 4px rgba(59, 130, 246, 0.5),
            0 0 0 8px rgba(59, 130, 246, 0.25),
            0 0 50px rgba(59, 130, 246, 0.3);
    }
    50% { 
        box-shadow: 
            0 0 0 6px rgba(59, 130, 246, 0.7),
            0 0 0 12px rgba(59, 130, 246, 0.4),
            0 0 80px rgba(59, 130, 246, 0.5);
    }
}

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

.onboarding-tooltip {
    position: fixed;
    z-index: 10002;
    max-width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    transition: all 0.2s ease-out;
    pointer-events: auto;
}

.onboarding-tooltip.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.tooltip-content {
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
}

.tooltip-header {
    padding: 20px 20px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.tooltip-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

.tooltip-progress {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 16px;
}

.tooltip-body {
    padding: 20px;
}

.tooltip-message {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #374151;
}

.tooltip-footer {
    padding: 16px 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f3f4f6;
}

.tooltip-nav {
    display: flex;
    gap: 8px;
}

/* Tooltip Buttons */
.onboarding-tooltip button {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-skip {
    background: transparent;
    color: #6b7280;
    text-decoration: underline;
    padding: 8px 0;
}

.btn-skip:hover {
    color: #374151;
}

.btn-prev {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-prev:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.btn-next {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-next:active,
.btn-prev:active {
    transform: translateY(0);
}

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

.tooltip-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transform: rotate(45deg);
}

.tooltip-arrow.arrow-top {
    bottom: -7px;
    left: 50%;
    margin-left: -6px;
    border-top: none;
    border-left: none;
}

.tooltip-arrow.arrow-bottom {
    top: -7px;
    left: 50%;
    margin-left: -6px;
    border-bottom: none;
    border-right: none;
}

.tooltip-arrow.arrow-left {
    right: -7px;
    top: 50%;
    margin-top: -6px;
    border-left: none;
    border-bottom: none;
}

.tooltip-arrow.arrow-right {
    left: -7px;
    top: 50%;
    margin-top: -6px;
    border-right: none;
    border-top: none;
}

/* =======================
   Help Button
   ======================= */

.simulation-help-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    animation: helpButtonIntro 0.5s ease-out;
}

.simulation-help-button:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

.simulation-help-button:active {
    transform: translateY(0) scale(1);
}

.simulation-help-button.help-button-subtle {
    opacity: 0.7;
    transform: scale(0.9);
}

.simulation-help-button.help-button-subtle:hover {
    opacity: 1;
    transform: translateY(-2px) scale(1);
}

.help-button-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-button-content i {
    font-size: 20px;
}

.help-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.help-tooltip::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1f2937;
}

.simulation-help-button:hover .help-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(-8px);
}

@keyframes helpButtonIntro {
    0% {
        opacity: 0;
        transform: scale(0) rotate(180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes helpSuggest {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 4px 12px rgba(0, 0, 0, 0.15),
            0 2px 4px rgba(0, 0, 0, 0.1);
    }
    20%, 60% { 
        transform: scale(1.1);
        box-shadow: 
            0 8px 20px rgba(102, 126, 234, 0.3),
            0 4px 8px rgba(102, 126, 234, 0.2);
    }
    40%, 80% { 
        transform: scale(1);
        box-shadow: 
            0 4px 12px rgba(0, 0, 0, 0.15),
            0 2px 4px rgba(0, 0, 0, 0.1);
    }
}

/* =======================
   Mobile Optimizations
   ======================= */

@media (max-width: 768px) {
    .onboarding-tooltip {
        max-width: calc(100vw - 40px);
        left: 20px !important;
        right: 20px;
        width: auto;
    }
    
    .tooltip-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .tooltip-progress {
        margin-left: 0;
        align-self: flex-end;
    }
    
    .tooltip-body {
        padding: 16px;
    }
    
    .tooltip-footer {
        padding: 12px 16px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .tooltip-nav {
        justify-content: center;
    }
    
    .btn-skip {
        text-align: center;
        order: 2;
    }
    
    .simulation-help-button {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
    }
    
    .help-button-content i {
        font-size: 18px;
    }
    
    .help-tooltip {
        display: none; /* Hide tooltip on mobile to avoid overlap */
    }
    
    /* Adjust spotlight for mobile */
    .onboarding-spotlight {
        box-shadow: 
            0 0 0 2px rgba(59, 130, 246, 0.5),
            0 0 0 4px rgba(59, 130, 246, 0.25),
            0 0 30px rgba(59, 130, 246, 0.3);
    }
    
    @keyframes spotlightPulse {
        0%, 100% { 
            box-shadow: 
                0 0 0 2px rgba(59, 130, 246, 0.5),
                0 0 0 4px rgba(59, 130, 246, 0.25),
                0 0 30px rgba(59, 130, 246, 0.3);
        }
        50% { 
            box-shadow: 
                0 0 0 3px rgba(59, 130, 246, 0.7),
                0 0 0 6px rgba(59, 130, 246, 0.4),
                0 0 50px rgba(59, 130, 246, 0.5);
        }
    }
}

@media (max-width: 480px) {
    .onboarding-tooltip {
        max-width: calc(100vw - 20px);
        left: 10px !important;
    }
    
    .tooltip-title {
        font-size: 16px;
    }
    
    .tooltip-message {
        font-size: 14px;
    }
    
    .simulation-help-button {
        width: 44px;
        height: 44px;
        bottom: 16px;
        right: 16px;
    }
    
    .help-button-content i {
        font-size: 16px;
    }
}

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

/* Focus styles for keyboard navigation */
.onboarding-tooltip button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.simulation-help-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .onboarding-backdrop {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .onboarding-tooltip {
        border: 2px solid #000;
    }
    
    .tooltip-header {
        background: #000;
    }
    
    .onboarding-spotlight {
        border: 3px solid #ffff00;
        box-shadow: 0 0 0 6px #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .onboarding-overlay,
    .onboarding-tooltip,
    .simulation-help-button,
    .onboarding-spotlight {
        transition: none;
        animation: none;
    }
    
    .onboarding-spotlight {
        box-shadow: 0 0 0 4px #3b82f6;
    }
}

/* =======================
   Enhanced Animations for Smart Onboarding
   ======================= */

/* Spotlight animation variations */
@keyframes spotlightGlowPulse {
    0%, 100% { 
        box-shadow: 
            0 0 0 4px rgba(59, 130, 246, 0.5),
            0 0 0 8px rgba(59, 130, 246, 0.25),
            0 0 30px rgba(59, 130, 246, 0.3),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
    50% { 
        box-shadow: 
            0 0 0 6px rgba(59, 130, 246, 0.8),
            0 0 0 12px rgba(59, 130, 246, 0.4),
            0 0 60px rgba(59, 130, 246, 0.6),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
}

@keyframes buttonSpotlightPulse {
    0%, 100% { 
        box-shadow: 
            0 0 0 4px rgba(34, 197, 94, 0.5),
            0 0 0 8px rgba(34, 197, 94, 0.25),
            0 0 20px rgba(34, 197, 94, 0.3),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
    50% { 
        box-shadow: 
            0 0 0 6px rgba(34, 197, 94, 0.8),
            0 0 0 12px rgba(34, 197, 94, 0.4),
            0 0 40px rgba(34, 197, 94, 0.5),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
}

@keyframes conversionGlow {
    0%, 100% { 
        box-shadow: 
            0 0 0 4px rgba(245, 158, 11, 0.6),
            0 0 0 8px rgba(245, 158, 11, 0.3),
            0 0 20px rgba(245, 158, 11, 0.4),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
    33% { 
        box-shadow: 
            0 0 0 6px rgba(245, 158, 11, 0.8),
            0 0 0 12px rgba(245, 158, 11, 0.5),
            0 0 40px rgba(245, 158, 11, 0.6),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
    66% { 
        box-shadow: 
            0 0 0 8px rgba(245, 158, 11, 0.9),
            0 0 0 16px rgba(245, 158, 11, 0.6),  
            0 0 60px rgba(245, 158, 11, 0.8),
            0 0 0 9999px rgba(0, 0, 0, 0.75);
    }
}

/* Element highlighting animations */
.onboarding-preview-highlight {
    animation: previewHighlight 2s ease-in-out;
    border: 2px solid rgba(59, 130, 246, 0.5) !important;
    border-radius: 8px !important;
}

@keyframes previewHighlight {
    0% { 
        background-color: transparent;
        transform: scale(1);
    }
    50% { 
        background-color: rgba(59, 130, 246, 0.1);
        transform: scale(1.02);
    }
    100% { 
        background-color: transparent;
        transform: scale(1);
    }
}

.onboarding-suggest-click {
    animation: suggestClick 1.5s ease-in-out 3;
    position: relative;
}

@keyframes suggestClick {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }
}

.onboarding-result-highlight {
    animation: resultHighlight 2s ease-in-out;
    position: relative;
    z-index: 1;
}

@keyframes resultHighlight {
    0% { 
        background-color: transparent;
        box-shadow: none;
    }
    25% { 
        background-color: rgba(168, 85, 247, 0.1);
        box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.3);
    }
    75% { 
        background-color: rgba(168, 85, 247, 0.05);
        box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.2);
    }
    100% { 
        background-color: transparent;
        box-shadow: none;
    }
}

.onboarding-conversion-highlight {
    animation: conversionHighlight 3s ease-in-out infinite;
    border: 2px solid transparent !important;
    border-radius: 12px !important;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(45deg, #f59e0b, #f97316, #f59e0b) border-box !important;
}

@keyframes conversionHighlight {
    0%, 100% { 
        border-color: rgba(245, 158, 11, 0.3);
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
    }
    50% { 
        border-color: rgba(245, 158, 11, 0.6);
        box-shadow: 0 0 30px rgba(245, 158, 11, 0.4);
    }
}

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

.tooltip-details {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    font-size: 14px;
    color: #6b7280;
}

.onboarding-feature-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.onboarding-feature-list li {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.onboarding-feature-list i {
    margin-right: 8px;
    color: #3b82f6;
    width: 16px;
    text-align: center;
}

.onboarding-tip {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
    font-size: 14px;
}

.onboarding-tip i {
    color: #3b82f6;
    margin-right: 8px;
}

.onboarding-setting-guide {
    margin-top: 8px;
}

.setting-explanation {
    margin-bottom: 8px;
    font-size: 13px;
    color: #6b7280;
}

.setting-explanation strong {
    color: #374151;
}

.onboarding-process-info {
    margin-top: 12px;
}

.onboarding-process-info h6 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.onboarding-process-info ol {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: #6b7280;
}

.onboarding-process-info li {
    margin-bottom: 4px;
}

.onboarding-results-guide {
    margin-top: 12px;
}

.result-section {
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(168, 85, 247, 0.05);
    border-radius: 4px;
    font-size: 14px;
}

.result-section strong {
    color: #7c3aed;
}

.onboarding-upgrade-benefits {
    margin-top: 12px;
}

.onboarding-upgrade-benefits h6 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.premium-features-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
}

.premium-features-list li {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
    color: #6b7280;
}

.premium-features-list i {
    margin-right: 8px;
    color: #f59e0b;
    width: 16px;
    text-align: center;
}

.upgrade-cta {
    text-align: center;
    margin-top: 16px;
}

.btn-upgrade {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-upgrade:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    color: white;
    text-decoration: none;
}

/* Progress bar in tooltip header */
.progress-bar-container {
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 4px;
    overflow: hidden;
}

.progress-bar-container .progress-bar {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* =======================
   Enhanced Mobile Optimizations
   ======================= */

@media (max-width: 768px) {
    /* Enhanced mobile tooltip positioning */
    .onboarding-tooltip {
        max-width: calc(100vw - 20px);
        left: 10px !important;
        right: 10px;
        width: auto;
        transform: none !important;
    }
    
    .onboarding-tooltip.visible {
        transform: none !important;
    }
    
    /* Mobile-specific animations */
    .onboarding-preview-highlight {
        animation-duration: 1.5s;
    }
    
    .onboarding-suggest-click {
        animation-duration: 1s;
        animation-iteration-count: 2;
    }
    
    /* Touch-friendly buttons */
    .onboarding-tooltip button {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* Improved readability */
    .tooltip-message {
        font-size: 16px;
        line-height: 1.6;
    }
    
    .tooltip-title {
        font-size: 20px;
    }
    
    /* Feature lists on mobile */
    .onboarding-feature-list li,
    .premium-features-list li {
        font-size: 15px;
        margin-bottom: 10px;
    }
    
    /* Mobile process info */
    .onboarding-process-info ol {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    /* Extra small mobile adjustments */
    .onboarding-tooltip {
        max-width: calc(100vw - 16px);
        left: 8px !important;
    }
    
    .tooltip-header {
        padding: 12px;
    }
    
    .tooltip-body {
        padding: 12px;
    }
    
    .tooltip-footer {
        padding: 8px 12px 12px;
    }
    
    /* Smaller feature icons */
    .onboarding-feature-list i,
    .premium-features-list i {
        font-size: 14px;
    }
}

/* =======================
   Touch Device Optimizations
   ======================= */

@media (hover: none) and (pointer: coarse) {
    /* Touch-specific styles */
    .simulation-help-button {
        width: 52px;
        height: 52px;
    }
    
    .help-button-content i {
        font-size: 20px;
    }
    
    /* Remove hover effects on touch devices */
    .simulation-help-button:hover {
        transform: none;
        box-shadow: 
            0 4px 12px rgba(0, 0, 0, 0.15),
            0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .help-tooltip {
        display: none;
    }
    
    /* Touch-friendly interaction areas */
    .onboarding-tooltip button {
        min-height: 48px;
        touch-action: manipulation;
    }
}

/* =======================
   High Performance Mode
   ======================= */

@media (prefers-reduced-motion: reduce) {
    /* Disable all animations for reduced motion */
    .onboarding-overlay,
    .onboarding-tooltip,
    .simulation-help-button,
    .onboarding-spotlight,
    .onboarding-preview-highlight,
    .onboarding-suggest-click,
    .onboarding-result-highlight,
    .onboarding-conversion-highlight {
        animation: none !important;
        transition: none !important;
    }
    
    /* Maintain functionality without animations */
    .onboarding-tooltip.visible {
        opacity: 1;
        transform: none;  
    }
    
    .onboarding-overlay.active {
        opacity: 1;
    }
    
    /* Static spotlight styles */
    .onboarding-spotlight {
        box-shadow: 0 0 0 3px #3b82f6;
        border-radius: 8px;
    }
}

/* =======================
   Dark Mode Support
   ======================= */

@media (prefers-color-scheme: dark) {
    .onboarding-tooltip {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .tooltip-header {
        background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    }
    
    .tooltip-message {
        color: #d1d5db;
    }
    
    .tooltip-footer {
        border-color: #374151;
    }
    
    .btn-prev {
        background: #374151;
        color: #d1d5db;
        border-color: #4b5563;
    }
    
    .btn-prev:hover {
        background: #4b5563;
    }
    
    .btn-skip {
        color: #9ca3af;
    }
    
    .btn-skip:hover {
        color: #d1d5db;
    }
    
    /* Dark mode tooltip content */
    .onboarding-tip {
        background: rgba(59, 130, 246, 0.15);
        border-color: rgba(59, 130, 246, 0.3);
        color: #d1d5db;
    }
    
    .result-section {
        background: rgba(168, 85, 247, 0.1);
        color: #d1d5db;
    }
    
    .result-section strong {
        color: #a78bfa;
    }
    
    .setting-explanation {
        color: #9ca3af;
    }
    
    .setting-explanation strong {
        color: #d1d5db;
    }
}

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

@media print {
    .onboarding-overlay,
    .onboarding-tooltip,
    .simulation-help-button,
    .spotlight-overlay {
        display: none !important;
    }
}