/* Tour guiado reutilizable (assets/js/feature-tour.js). */

.mgt {
    --mgt-primary: var(--mg-primary, #dc3751);
    --mgt-indigo: #6366f1;
    --mgt-emerald: #10b981;
    --mgt-amber: #f59e0b;
    --mgt-ink: #0f172a;
    --mgt-muted: #64748b;
    --mgt-surface: #fff;
    --mgt-line: rgba(15, 23, 42, 0.08);
    position: fixed;
    inset: 0;
    z-index: 1990;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.22s ease;
}

.mgt-block {
    position: fixed;
    pointer-events: auto;
}

.mgt.is-leaving .mgt-block {
    pointer-events: none;
}

/* Lo que se abre desde la sección resaltada (selects, offcanvas, alertas) va sobre el tour. */
body.mgt-open .select2-container--open,
body.mgt-open .offcanvas,
body.mgt-open .offcanvas-backdrop,
body.mgt-open .modal,
body.mgt-open .modal-backdrop,
body.mgt-open .swal2-container,
body.mgt-open .tooltip,
body.mgt-open .popover,
body.mgt-open .dropdown-menu.show {
    z-index: 2000 !important;
}

.mgt *,
.mgt *::before,
.mgt *::after {
    box-sizing: border-box;
}

.mgt.is-open {
    opacity: 1;
}

.mgt.is-leaving {
    opacity: 0;
    pointer-events: none;
}

.mgt-spot {
    position: fixed;
    border-radius: 16px;
    box-shadow:
        0 0 0 3px rgba(220, 55, 81, 0.55),
        0 0 0 9999px rgba(15, 23, 42, 0.62);
    transition: top 0.38s cubic-bezier(0.22, 1, 0.36, 1), left 0.38s cubic-bezier(0.22, 1, 0.36, 1),
        width 0.38s cubic-bezier(0.22, 1, 0.36, 1), height 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    animation: mgt-pulse 2.4s ease-in-out infinite;
}

.mgt--center .mgt-spot {
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.62);
    animation: none;
}

@keyframes mgt-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 3px rgba(220, 55, 81, 0.55),
            0 0 0 9999px rgba(15, 23, 42, 0.62);
    }
    50% {
        box-shadow:
            0 0 0 3px rgba(99, 102, 241, 0.55),
            0 0 0 9px rgba(99, 102, 241, 0.18),
            0 0 0 9999px rgba(15, 23, 42, 0.62);
    }
}

.mgt-card {
    position: fixed;
    width: min(380px, calc(100vw - 32px));
    padding: 22px 22px 18px;
    border-radius: 20px;
    background: var(--mgt-surface);
    color: var(--mgt-ink);
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.45), 0 0 0 1px var(--mgt-line);
    transition: top 0.38s cubic-bezier(0.22, 1, 0.36, 1), left 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    outline: none;
    overflow: hidden;
    pointer-events: auto;
}

.mgt-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #dc3751, #b4246f, #6366f1);
}

.mgt-content {
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.mgt-card.is-swapping .mgt-content {
    opacity: 0;
    transform: translateY(4px);
}

.mgt-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--mgt-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.mgt-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: var(--mgt-ink);
}

.mgt-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    padding-right: 32px;
}

.mgt-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    color: #fff;
    background: var(--mgt-primary);
    box-shadow: 0 10px 20px -8px var(--mgt-tone-shadow, rgba(220, 55, 81, 0.6));
}

.mgt-icon.mgt-icon--xl {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    font-size: 1.8rem;
    margin: 6px auto 16px;
    background: linear-gradient(135deg, #dc3751, #b4246f 55%, #6366f1);
}

.mgt-tone--primary { background: linear-gradient(135deg, #f0506b, #dc3751); --mgt-tone-shadow: rgba(220, 55, 81, 0.6); }
.mgt-tone--indigo { background: linear-gradient(135deg, #818cf8, #6366f1); --mgt-tone-shadow: rgba(99, 102, 241, 0.6); }
.mgt-tone--emerald { background: linear-gradient(135deg, #34d399, #10b981); --mgt-tone-shadow: rgba(16, 185, 129, 0.55); }
.mgt-tone--amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); --mgt-tone-shadow: rgba(245, 158, 11, 0.55); }

.mgt-count {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mgt-muted);
}

.mgt-title {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--mgt-ink);
}

.mgt-body {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--mgt-muted);
}

.mgt-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.mgt-dots {
    display: flex;
    gap: 6px;
}

.mgt-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.14);
    transition: width 0.25s ease, background 0.25s ease;
}

.mgt-dot.is-past {
    background: rgba(220, 55, 81, 0.45);
}

.mgt-dot.is-active {
    width: 22px;
    background: linear-gradient(90deg, #dc3751, #6366f1);
}

.mgt-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mgt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.mgt-btn--primary {
    color: #fff;
    background: linear-gradient(135deg, #dc3751, #b4246f);
    box-shadow: 0 10px 20px -10px rgba(220, 55, 81, 0.9);
}

.mgt-btn--primary:hover,
.mgt-btn--primary:focus-visible {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 14px 24px -10px rgba(220, 55, 81, 0.95);
}

.mgt-btn--primary i {
    font-size: 0.8rem;
}

.mgt-btn--ghost {
    color: var(--mgt-ink);
    background: rgba(15, 23, 42, 0.05);
}

.mgt-btn--ghost:hover {
    background: rgba(15, 23, 42, 0.09);
}

.mgt-btn--link {
    color: var(--mgt-muted);
    background: transparent;
    padding: 0 10px;
    font-weight: 600;
}

.mgt-btn--link:hover {
    color: var(--mgt-ink);
}

.mgt-btn:focus-visible {
    outline: 2px solid var(--mgt-indigo);
    outline-offset: 2px;
}

/* Tarjeta final, centrada */

.mgt--center .mgt-card {
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 32px));
    padding: 32px 28px 26px;
    text-align: center;
    animation: mgt-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes mgt-pop {
    from { transform: translate(-50%, -46%) scale(0.96); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.mgt-finish .mgt-title {
    font-size: 1.35rem;
}

.mgt-finish-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 22px;
}

.mgt-finish-actions .mgt-btn {
    width: 100%;
    min-height: 44px;
}

/* Móvil: tarjeta anclada abajo */

.mgt--mobile:not(.mgt--center) .mgt-card {
    top: auto !important;
    left: 12px !important;
    right: 12px;
    bottom: 12px;
    width: auto;
}

@media (prefers-reduced-motion: reduce) {
    .mgt,
    .mgt-spot,
    .mgt-card,
    .mgt-content,
    .mgt-dot {
        transition: none;
        animation: none;
    }
}

/* Oscuro */

[data-theme="dark"] .mgt {
    --mgt-ink: var(--mg-grey, #f1f5f9);
    --mgt-muted: var(--mg-grey-100, #94a3b8);
    --mgt-surface: var(--mg-white-100, #1e2433);
    --mgt-line: rgba(244, 244, 245, 0.10);
}

[data-theme="dark"] .mgt-spot {
    box-shadow:
        0 0 0 3px rgba(220, 55, 81, 0.55),
        0 0 0 9999px rgba(2, 6, 23, 0.72);
    animation: none;
}

[data-theme="dark"] .mgt--center .mgt-spot {
    box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.72);
}

[data-theme="dark"] .mgt-dot {
    background: rgba(244, 244, 245, 0.18);
}

[data-theme="dark"] .mgt-btn--ghost {
    background: rgba(244, 244, 245, 0.08);
}

[data-theme="dark"] .mgt-btn--ghost:hover {
    background: rgba(244, 244, 245, 0.14);
}

[data-theme="dark"] .mgt-close:hover {
    background: rgba(244, 244, 245, 0.08);
}

/* Botón «Ver tour» en Configuración → CRM */

.settings-tour-launch {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.settings-tour-launch .btn i {
    margin-right: 6px;
}
