/*
 * First-login tutorial: "Tutorial" button, dimmed backdrop with a highlight, bubble.
 * Buttons reuse the manual's pill classes (crm-manual-btn), so both look the same. Sizes in rem so
 * the bubble follows the user's font size; colours from Filament's variables for dark mode.
 */

/* The manual buttons and the Tutorial button share one row when both are there. */
.crm-manual-buttons:has(+ .crm-tour-buttons) {
    display: inline-flex;
    vertical-align: top;
    margin-right: 0.375rem;
}

.crm-tour-buttons {
    display: inline-flex;
    vertical-align: top;
    margin-top: 0.5rem;
}

.crm-tour-btn-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    color: var(--primary-600);
}

.dark .crm-tour-btn-icon {
    color: var(--primary-400);
}

/* Overlay: outside Livewire, above the panel (Filament modals use z-index 40, the topbar 30). */
.crm-tour {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
}

/* Catches clicks so nothing on the page is triggered by accident; the page still scrolls. */
.crm-tour-shield {
    position: fixed;
    inset: 0;
    pointer-events: auto;
    background: transparent;
}

.crm-tour-centered .crm-tour-shield {
    background: rgba(14, 32, 56, 0.55);
}

/* The highlight: a transparent box whose huge shadow dims everything else. */
.crm-tour-spot {
    position: fixed;
    border-radius: 0.75rem;
    box-shadow: 0 0 0 2px var(--crm-gold, #b08d3c), 0 0 0 200vmax rgba(14, 32, 56, 0.55);
    transition: left 0.2s ease, top 0.2s ease, width 0.2s ease, height 0.2s ease;
    pointer-events: none;
}

.crm-tour-bubble {
    position: fixed;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: 0.875rem;
    background: var(--color-white, #fff);
    color: var(--gray-800);
    box-shadow: 0 18px 40px rgba(14, 32, 56, 0.35), 0 0 0 1px rgba(14, 32, 56, 0.08);
    pointer-events: auto;
    animation: crm-tour-in 0.18s ease-out;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.crm-tour-bubble:focus {
    outline: none;
}

.crm-tour-bubble:focus-visible {
    outline: 2px solid var(--crm-gold-light, #d9bc78);
    outline-offset: 2px;
}

@keyframes crm-tour-in {
    from { opacity: 0; transform: translateY(0.375rem); }
    to { opacity: 1; transform: none; }
}

.crm-tour-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-radius: 0.875rem 0.875rem 0 0;
    background: var(--crm-navy, #0e2038);
}

.crm-tour-counter {
    margin: 0;
    color: var(--crm-gold-light, #d9bc78);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Big enough to hit with a thumb. */
.crm-tour-close {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.crm-tour-close:hover,
.crm-tour-close:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

.crm-tour-close:focus-visible {
    outline: 2px solid var(--crm-gold-light, #d9bc78);
    outline-offset: 2px;
}

.crm-tour-title {
    margin: 0;
    padding: 0.875rem 1rem 0.25rem;
    color: var(--gray-950);
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.35;
}

.crm-tour-text {
    margin: 0;
    padding: 0 1rem 0.875rem;
    overflow-wrap: anywhere;
}

.crm-tour-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 1rem 0.875rem;
    border-top: 1px solid var(--gray-200);
}

.crm-tour-nav {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.crm-tour-foot .crm-manual-btn {
    min-height: 2.5rem;
    padding-inline: 1rem;
    font-size: 0.875rem;
}

.crm-tour-link {
    min-height: 2.5rem;
    padding: 0 0.25rem;
    background: none;
    color: var(--gray-600);
    font-size: 0.875rem;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.crm-tour-link:hover {
    color: var(--gray-900);
}

.crm-tour-link:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.crm-tour [hidden] {
    display: none !important;
}

/* Dark mode */
.dark .crm-tour-bubble {
    background: var(--gray-900);
    color: var(--gray-200);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.dark .crm-tour-title {
    color: #fff;
}

.dark .crm-tour-foot {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.dark .crm-tour-link {
    color: var(--gray-300);
}

.dark .crm-tour-link:hover {
    color: #fff;
}

.dark .crm-tour-spot {
    box-shadow: 0 0 0 2px var(--crm-gold-light, #d9bc78), 0 0 0 200vmax rgba(0, 0, 0, 0.6);
}

.dark .crm-tour-centered .crm-tour-shield {
    background: rgba(0, 0, 0, 0.6);
}

/* Reduced motion: no slide, no gliding highlight. */
.crm-tour-still .crm-tour-spot,
.crm-tour-still .crm-tour-bubble {
    transition: none;
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .crm-tour-spot,
    .crm-tour-bubble {
        transition: none;
        animation: none;
    }
}

@media print {
    .crm-tour,
    .crm-tour-buttons {
        display: none !important;
    }
}
