/* ==========================================================================
   Guided Tour — first-login walkthrough + per-page help tours
   Engine: js/guided-tour.js   Steps: js/guided-tour-steps.js
   ========================================================================== */

/* Sidebar footer trigger — pulses after the welcome tour ends */
#ivl-tour-trigger.ivl-tour-pulse {
    animation: ivl-tour-pulse 1.8s ease-out 3;
}

@keyframes ivl-tour-pulse {
    0% { box-shadow: 0 0 0 0 rgba(18, 128, 124, 0.55); }
    100% { box-shadow: 0 0 0 14px rgba(18, 128, 124, 0); }
}

/* Root layer — sits above Bootstrap modals, the sidebar and status banners */
.ivl-tour-root {
    position: fixed;
    inset: 0;
    z-index: 10060;
    pointer-events: none;
}

.ivl-tour-blocker {
    position: fixed;
    inset: 0;
    pointer-events: auto;
    background: transparent;
}

.ivl-tour-root.is-centered .ivl-tour-blocker {
    background: rgba(14, 16, 21, 0.6);
}

.ivl-tour-spotlight {
    position: fixed;
    border-radius: var(--radius-lg, 12px);
    box-shadow:
        0 0 0 3px var(--brand-tertiary, #4DB6AC),
        0 0 0 9999px rgba(14, 16, 21, 0.6);
    pointer-events: none;
    transition:
        top 300ms cubic-bezier(0.4, 0, 0.2, 1),
        left 300ms cubic-bezier(0.4, 0, 0.2, 1),
        width 300ms cubic-bezier(0.4, 0, 0.2, 1),
        height 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ivl-tour-root.is-centered .ivl-tour-spotlight {
    display: none;
}

/* Popover card — matches the dashboard white card with teal top strip */
.ivl-tour-popover {
    position: fixed;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-primary, #FFFFFF);
    color: var(--text-primary, #0E1015);
    border-top: 4px solid var(--brand-primary, #12807C);
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 20px 40px rgba(14, 16, 21, 0.25);
    padding: var(--space-6, 24px);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.ivl-tour-popover.is-visible {
    opacity: 1;
    transform: none;
}

.ivl-tour-root.is-centered .ivl-tour-popover {
    width: min(440px, calc(100vw - 24px));
    text-align: center;
}

.ivl-tour-popover:focus {
    outline: none;
}

.ivl-tour-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    margin-bottom: var(--space-2, 8px);
}

.ivl-tour-root.is-centered .ivl-tour-header {
    justify-content: center;
    position: relative;
}

.ivl-tour-eyebrow {
    font-size: var(--font-size-xs, 12px);
    font-weight: 600;
    color: var(--brand-primary, #12807C);
    text-transform: uppercase;
    margin: 0 auto 0 0;
}

.ivl-tour-root.is-centered .ivl-tour-eyebrow {
    margin: 0;
    padding: 0 36px;
}

.ivl-tour-voice,
.ivl-tour-close {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary, #50646A);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.ivl-tour-root.is-centered .ivl-tour-close {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.ivl-tour-root.is-centered .ivl-tour-voice {
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.ivl-tour-voice:hover,
.ivl-tour-close:hover {
    background: rgba(18, 128, 124, 0.1);
    color: var(--brand-primary, #12807C);
}

.ivl-tour-voice.is-on {
    background: rgba(18, 128, 124, 0.12);
    color: var(--brand-primary, #12807C);
}

.ivl-tour-voice:focus-visible,
.ivl-tour-close:focus-visible,
.ivl-tour-popover .btn:focus-visible {
    outline: 3px solid var(--brand-tertiary, #4DB6AC);
    outline-offset: 2px;
}

.ivl-tour-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-3, 12px);
    border-radius: 50%;
    background: rgba(18, 128, 124, 0.1);
    color: var(--brand-primary, #12807C);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.ivl-tour-title {
    font-size: var(--font-size-lg, 18px);
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 var(--space-2, 8px);
    color: var(--text-primary, #0E1015);
}

.ivl-tour-root.is-centered .ivl-tour-title {
    font-size: var(--font-size-xl, 20px);
}

.ivl-tour-body {
    font-size: var(--font-size-sm, 14px);
    line-height: 1.6;
    color: var(--text-secondary, #50646A);
    margin: 0;
}

.ivl-tour-body p {
    margin: 0 0 var(--space-2, 8px);
}

.ivl-tour-body p:last-child {
    margin-bottom: 0;
}

.ivl-tour-progress {
    display: flex;
    gap: 6px;
    margin: var(--space-4, 16px) 0 0;
    padding: 0;
    list-style: none;
}

.ivl-tour-root.is-centered .ivl-tour-progress {
    justify-content: center;
}

.ivl-tour-progress li {
    height: 4px;
    flex: 1 1 0;
    max-width: 32px;
    border-radius: 9999px;
    background: var(--neutral-300, #CBD5E1);
    transition: background-color 200ms ease;
}

.ivl-tour-progress li.is-done {
    background: var(--brand-primary, #12807C);
}

.ivl-tour-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2, 8px);
    margin-top: var(--space-4, 16px);
    flex-wrap: wrap;
}

.ivl-tour-footer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2, 8px);
    margin-left: auto;
    min-width: 0;
    max-width: 100%;
}

/* Long "Next: <section>" labels wrap instead of overflowing at larger text sizes */
.ivl-tour-footer-actions .btn {
    white-space: normal;
    max-width: 100%;
}

.ivl-tour-skip {
    border: 0;
    background: transparent;
    padding: 6px 4px;
    color: var(--text-secondary, #50646A);
    font-size: var(--font-size-sm, 14px);
    text-decoration: underline;
    cursor: pointer;
}

.ivl-tour-skip:hover {
    color: var(--brand-primary, #12807C);
}

.ivl-tour-extra {
    margin-top: var(--space-3, 12px);
}

.ivl-tour-link {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: var(--font-size-sm, 14px);
    font-weight: 600;
    color: var(--brand-primary, #12807C);
    cursor: pointer;
}

.ivl-tour-link:hover {
    text-decoration: underline;
}

.ivl-tour-link:focus-visible {
    outline: 3px solid var(--brand-tertiary, #4DB6AC);
    outline-offset: 2px;
}

/* Arrow pointing at the highlighted element */
.ivl-tour-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--bg-primary, #FFFFFF);
    transform: rotate(45deg);
}

.ivl-tour-popover[data-placement="bottom"] .ivl-tour-arrow { top: -9px; }
.ivl-tour-popover[data-placement="top"] .ivl-tour-arrow { bottom: -7px; }
.ivl-tour-popover[data-placement="right"] .ivl-tour-arrow { left: -7px; }
.ivl-tour-popover[data-placement="left"] .ivl-tour-arrow { right: -7px; }

.ivl-tour-popover[data-placement="bottom"] .ivl-tour-arrow {
    background: var(--brand-primary, #12807C);
}

.ivl-tour-root.is-centered .ivl-tour-arrow {
    display: none;
}

/* Small screens — dock the card to the bottom as a sheet */
@media (max-width: 575.98px) {
    .ivl-tour-root:not(.is-centered) .ivl-tour-popover {
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        bottom: 12px !important;
        width: auto;
        max-height: 50vh;
        padding: var(--space-4, 16px);
    }

    .ivl-tour-root:not(.is-centered) .ivl-tour-arrow {
        display: none;
    }
}

/* Accessibility modes */
body.dark-mode .ivl-tour-popover,
body.dark-mode .ivl-tour-arrow {
    background: var(--bg-secondary, #1E293B);
}

body.dark-mode .ivl-tour-popover[data-placement="bottom"] .ivl-tour-arrow {
    background: var(--brand-primary, #12807C);
}

body.high-contrast .ivl-tour-popover {
    border: 2px solid var(--text-primary, #000000);
    border-top-width: 4px;
    box-shadow: none;
}

body.high-contrast .ivl-tour-spotlight {
    box-shadow:
        0 0 0 4px #FFD400,
        0 0 0 9999px rgba(0, 0, 0, 0.75);
}

@media (prefers-reduced-motion: reduce) {
    .ivl-tour-spotlight,
    .ivl-tour-popover,
    .ivl-tour-progress li {
        transition: none;
    }

    #ivl-tour-trigger.ivl-tour-pulse {
        animation: none;
    }
}

@media print {
    .ivl-tour-root {
        display: none !important;
    }
}
