/* Tutorial Overlay System */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
    overscroll-behavior: none;
}

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

.tutorial-overlay.active .tutorial-popup {
    animation: tutorialFadeIn 0.4s ease;
}

@keyframes tutorialFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tutorial-highlight {
    position: fixed;
    border: 3px solid #007bff;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75),
                0 0 20px rgba(0, 123, 255, 0.5),
                inset 0 0 20px rgba(0, 123, 255, 0.2);
    z-index: 999998;
    pointer-events: none;
    transition: all 0.3s ease;
}

.tutorial-popup {
    position: fixed;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    min-width: 300px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.tutorial-popup.top {
    margin-bottom: 20px;
}

.tutorial-popup.bottom {
    margin-top: 20px;
}

.tutorial-popup.left {
    margin-right: 20px;
}

.tutorial-popup.right {
    margin-left: 20px;
}

.tutorial-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.tutorial-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.tutorial-step-indicator {
    font-size: 14px;
    opacity: 0.9;
    margin-left: 10px;
    font-weight: 400;
}

.tutorial-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.tutorial-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.tutorial-body {
    padding: 20px;
}

.tutorial-content {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    margin: 0 0 20px 0;
}

.tutorial-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 10px 0;
}

.tutorial-footer {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.tutorial-footer-left {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tutorial-footer-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
}

.tutorial-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

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

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

.tutorial-btn-prev {
    background: #6c757d;
    color: white;
}

.tutorial-btn-prev:hover {
    background: #5a6268;
}

.tutorial-btn-prev:disabled {
    background: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    transform: none;
}

.tutorial-btn-next {
    background: #007bff;
    color: white;
}

.tutorial-btn-next:hover {
    background: #0056b3;
}

.tutorial-btn-finish {
    background: #28a745;
    color: white;
}

.tutorial-btn-finish:hover {
    background: #218838;
}

.tutorial-btn-skip {
    background: transparent;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.tutorial-btn-skip:hover {
    background: #f8f9fa;
    color: #495057;
}

.tutorial-btn-disable {
    background: #dc3545;
    color: white;
    border: none;
}

.tutorial-btn-disable:hover {
    background: #c82333;
    color: white;
}

.tutorial-btn-disable i {
    margin-right: 5px;
}

.tutorial-progress {
    margin: 15px 0 0 0;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
}

.tutorial-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 2px;
}

/* Arrow pointing to highlighted element */
.tutorial-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    z-index: 999999;
}

.tutorial-popup.top .tutorial-arrow {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0 10px;
    border-color: #ffffff transparent transparent transparent;
}

.tutorial-popup.bottom .tutorial-arrow {
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 10px 10px 10px;
    border-color: transparent transparent #ffffff transparent;
}

.tutorial-popup.left .tutorial-arrow {
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 10px 0 10px 10px;
    border-color: transparent transparent transparent #ffffff;
}

.tutorial-popup.right .tutorial-arrow {
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 10px 10px 10px 0;
    border-color: transparent #ffffff transparent transparent;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .tutorial-popup {
        max-width: 90%;
        min-width: 280px;
        margin: 10px !important;
    }
    
    .tutorial-content {
        font-size: 14px;
    }
    
    .tutorial-title {
        font-size: 16px;
    }
    
    .tutorial-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tutorial-footer-left,
    .tutorial-footer-right {
        width: 100%;
        justify-content: center;
    }
    
    .tutorial-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .tutorial-btn {
        width: 100%;
    }
}

/* Loading state */
.tutorial-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #6c757d;
}

.tutorial-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: tutorialSpin 0.8s linear infinite;
}

@keyframes tutorialSpin {
    to {
        transform: rotate(360deg);
    }
}

.tutorial-popup:not(.top):not(.bottom):not(.center):not(.left):not(.right){
    left: 50% !important;
    transform: translatex(-50%);
    margin: 0 !important;
}