/**
 * ERP Tutorial System - Bootstrap-Styled CSS
 * 
 * A reusable onboarding/tutorial overlay system that integrates
 * seamlessly with Bootstrap themes.
 */

/* ============================================
   OVERLAY - Dark backdrop
   ============================================ */
.erp-tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.35);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* ============================================
   SPOTLIGHT - Highlighted element effect
   ============================================ */
.erp-tutorial-spotlight {
    position: relative;
    z-index: 9999 !important;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    animation: erp-spotlight-pulse 2s ease-in-out infinite;
}

.erp-tutorial-spotlight::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid var(--bs-primary, #009ef7);
    border-radius: 6px;
    pointer-events: none;
}

@keyframes erp-spotlight-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35),
            0 0 0 0 rgba(0, 158, 247, 0.4);
    }

    50% {
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35),
            0 0 0 8px rgba(0, 158, 247, 0.1);
    }
}

/* ============================================
   TOOLTIP - Step content container
   ============================================ */
.erp-tutorial-tooltip {
    position: fixed;
    z-index: 10000;
    max-width: 400px;
    min-width: 280px;
    background-color: var(--bs-body-bg, #ffffff);
    border-radius: 0.625rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Prevent overflow outside viewport */
    overflow: visible;
}

.erp-tutorial-tooltip.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* Theme support for dark mode */
[data-bs-theme="dark"] .erp-tutorial-tooltip {
    background-color: var(--bs-gray-800, #1e1e2d);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.5);
}

/* ============================================
   TOOLTIP ARROW
   ============================================ */
.erp-tutorial-tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 10px solid transparent;
}

/* Arrow positions */
.erp-tutorial-tooltip[data-position="bottom"] .erp-tutorial-tooltip-arrow {
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--bs-body-bg, #ffffff);
}

.erp-tutorial-tooltip[data-position="top"] .erp-tutorial-tooltip-arrow {
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--bs-body-bg, #ffffff);
}

.erp-tutorial-tooltip[data-position="left"] .erp-tutorial-tooltip-arrow {
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: var(--bs-body-bg, #ffffff);
}

.erp-tutorial-tooltip[data-position="right"] .erp-tutorial-tooltip-arrow {
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: var(--bs-body-bg, #ffffff);
}

/* Dark mode arrow colors */
[data-bs-theme="dark"] .erp-tutorial-tooltip[data-position="bottom"] .erp-tutorial-tooltip-arrow {
    border-bottom-color: var(--bs-gray-800, #1e1e2d);
}

[data-bs-theme="dark"] .erp-tutorial-tooltip[data-position="top"] .erp-tutorial-tooltip-arrow {
    border-top-color: var(--bs-gray-800, #1e1e2d);
}

[data-bs-theme="dark"] .erp-tutorial-tooltip[data-position="left"] .erp-tutorial-tooltip-arrow {
    border-left-color: var(--bs-gray-800, #1e1e2d);
}

[data-bs-theme="dark"] .erp-tutorial-tooltip[data-position="right"] .erp-tutorial-tooltip-arrow {
    border-right-color: var(--bs-gray-800, #1e1e2d);
}

/* ============================================
   TOOLTIP HEADER
   ============================================ */
.erp-tutorial-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color, #eff2f5);
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.erp-tutorial-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bs-gray-900, #181c32);
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-bs-theme="dark"] .erp-tutorial-title {
    color: var(--bs-gray-100, #f5f8fa);
}

.erp-tutorial-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.erp-tutorial-progress {
    font-size: 0.75rem;
    color: var(--bs-gray-500, #a1a5b7);
    background-color: var(--bs-gray-100, #f5f8fa);
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    font-weight: 500;
    white-space: nowrap;
}

[data-bs-theme="dark"] .erp-tutorial-progress {
    background-color: var(--bs-gray-700, #2b2b40);
    color: var(--bs-gray-400, #b5b5c3);
}

/* ============================================
   TOOLTIP CONTENT
   ============================================ */
.erp-tutorial-content {
    padding: 1.25rem;
    color: var(--bs-gray-700, #5e6278);
    font-size: 0.95rem;
    line-height: 1.6;
}

[data-bs-theme="dark"] .erp-tutorial-content {
    color: var(--bs-gray-400, #b5b5c3);
}

/* ============================================
   TOOLTIP ACTIONS (Button Container)
   ============================================ */
.erp-tutorial-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--bs-border-color, #eff2f5);
    gap: 0.5rem;
}

.erp-tutorial-actions-left {
    display: flex;
    gap: 0.5rem;
}

.erp-tutorial-actions-right {
    display: flex;
    gap: 0.5rem;
}

/* Button styling - uses Bootstrap classes but adds custom tweaks */
.erp-tutorial-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0.475rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.erp-tutorial-btn-skip {
    background-color: transparent;
    color: var(--bs-gray-500, #a1a5b7);
}

.erp-tutorial-btn-skip:hover {
    color: var(--bs-gray-700, #5e6278);
    background-color: var(--bs-gray-100, #f5f8fa);
}

[data-bs-theme="dark"] .erp-tutorial-btn-skip:hover {
    background-color: var(--bs-gray-700, #2b2b40);
    color: var(--bs-gray-300, #cdcdd4);
}

.erp-tutorial-btn-prev {
    background-color: var(--bs-gray-200, #f1f1f2);
    color: var(--bs-gray-700, #5e6278);
}

.erp-tutorial-btn-prev:hover {
    background-color: var(--bs-gray-300, #e4e6ef);
}

[data-bs-theme="dark"] .erp-tutorial-btn-prev {
    background-color: var(--bs-gray-700, #2b2b40);
    color: var(--bs-gray-300, #cdcdd4);
}

[data-bs-theme="dark"] .erp-tutorial-btn-prev:hover {
    background-color: var(--bs-gray-600, #3f4254);
}

.erp-tutorial-btn-next,
.erp-tutorial-btn-finish {
    background-color: var(--bs-primary, #009ef7);
    color: #ffffff;
}

.erp-tutorial-btn-next:hover,
.erp-tutorial-btn-finish:hover {
    background-color: var(--bs-primary-dark, #0095e8);
}

.erp-tutorial-btn-next i,
.erp-tutorial-btn-prev i {
    font-size: 0.8rem;
}

.erp-tutorial-btn-next i {
    margin-left: 0.375rem;
}

.erp-tutorial-btn-prev i {
    margin-right: 0.375rem;
}

/* ============================================
   PROGRESS BAR (Optional visual indicator)
   ============================================ */
.erp-tutorial-progress-bar {
    height: 4px;
    background-color: var(--bs-gray-200, #f1f1f2);
    border-radius: 0 0 0.625rem 0.625rem;
    overflow: hidden;
}

.erp-tutorial-progress-bar-fill {
    height: 100%;
    background-color: var(--bs-primary, #009ef7);
    transition: width 0.3s ease;
}

[data-bs-theme="dark"] .erp-tutorial-progress-bar {
    background-color: var(--bs-gray-700, #2b2b40);
}

/* ============================================
   CLOSE BUTTON
   ============================================ */
.erp-tutorial-close {
    position: relative;
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
    color: var(--bs-gray-400, #b5b5c3);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    margin-left: 0.25rem;
}

.erp-tutorial-close:hover {
    background-color: var(--bs-gray-100, #f5f8fa);
    color: var(--bs-gray-600, #7e8299);
}

[data-bs-theme="dark"] .erp-tutorial-close:hover {
    background-color: var(--bs-gray-700, #2b2b40);
    color: var(--bs-gray-300, #cdcdd4);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 576px) {
    .erp-tutorial-tooltip {
        max-width: calc(100vw - 32px);
        min-width: auto;
        width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px !important;
    }

    .erp-tutorial-tooltip-arrow {
        display: none;
    }

    .erp-tutorial-header {
        padding: 0.875rem 1rem;
    }

    .erp-tutorial-content {
        padding: 1rem;
    }

    .erp-tutorial-actions {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
    }

    .erp-tutorial-title {
        font-size: 1rem;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.erp-tutorial-hidden {
    display: none !important;
}

/* Disable scrolling when tutorial is active */
body.erp-tutorial-active {
    overflow: hidden;
}

/* Ensure highlighted elements are clickable during tutorial */
.erp-tutorial-spotlight * {
    pointer-events: auto;
}