/* ============================================================
   Axiom Matrix – Interactive Guided Tour
   Self-contained, responsive, RTL-aware, theme-aware
   ============================================================ */

/* --- Overlay + spotlight ------------------------------------- */
.axm-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s ease;
    /* The overlay itself is a full-screen box-shadow trick around the spotlight */
}
.axm-tour-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.axm-tour-spotlight {
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 0;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(6, 10, 24, 0.72);
    transition: all .35s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
    outline: 2px solid rgba(var(--primary-rgb, 113, 163, 205), 0.9);
    outline-offset: 2px;
}
body.light .axm-tour-spotlight {
    box-shadow: 0 0 0 9999px rgba(20, 30, 60, 0.55);
}
.axm-tour-spotlight.no-target {
    /* Fallback when the tour has no element to anchor to */
    top: 50%; left: 50%;
    width: 0; height: 0;
    transform: translate(-50%, -50%);
    outline: none;
    box-shadow: 0 0 0 9999px rgba(6, 10, 24, 0.80);
}

/* --- Popover card -------------------------------------------- */
.axm-tour-popover {
    position: absolute;
    z-index: 99991;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a202c);
    border-radius: 14px;
    box-shadow:
        0 24px 60px rgba(0,0,0,.28),
        0 4px 14px rgba(0,0,0,.12);
    border: 1px solid var(--border-primary, rgba(0,0,0,0.08));
    padding: 0;
    opacity: 0;
    transform: translateY(6px) scale(.98);
    transition: opacity .22s ease, transform .22s ease, top .35s cubic-bezier(.4,0,.2,1), left .35s cubic-bezier(.4,0,.2,1);
    font-family: inherit;
    overflow: hidden;
}
body.dark .axm-tour-popover {
    background: var(--bg-secondary, #15192a);
    color: var(--text-primary, #f5f7ff);
    border-color: rgba(255,255,255,.08);
}
.axm-tour-popover.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Arrow */
.axm-tour-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: inherit;
    border: inherit;
    transform: rotate(45deg);
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-primary, rgba(0,0,0,0.08));
    z-index: -1;
}
body.dark .axm-tour-arrow {
    background: var(--bg-secondary, #15192a);
    border-color: rgba(255,255,255,.08);
}
.axm-tour-popover[data-placement="right"] .axm-tour-arrow { left: -7px; top: 24px; border-right: none; border-top: none; }
.axm-tour-popover[data-placement="left"]  .axm-tour-arrow { right: -7px; top: 24px; border-left: none; border-bottom: none; }
.axm-tour-popover[data-placement="top"]   .axm-tour-arrow { bottom: -7px; left: 24px; border-top: none; border-left: none; }
.axm-tour-popover[data-placement="bottom"] .axm-tour-arrow { top: -7px; left: 24px; border-bottom: none; border-right: none; }
.axm-tour-popover[data-placement="center"] .axm-tour-arrow { display: none; }

/* Header */
.axm-tour-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px 0;
}
.axm-tour-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
        rgba(var(--primary-rgb, 113,163,205), 0.18),
        rgba(var(--primary-rgb, 113,163,205), 0.06));
    color: var(--primary, #71a3cd);
    font-size: 16px;
    flex-shrink: 0;
}
.axm-tour-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .01em;
    line-height: 1.3;
    margin: 0;
    flex: 1;
    min-width: 0;
}
.axm-tour-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary, #8892b0);
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background .2s, color .2s;
    flex-shrink: 0;
}
.axm-tour-close:hover {
    background: rgba(0,0,0,.06);
    color: var(--text-primary, #1a202c);
}
body.dark .axm-tour-close:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Body */
.axm-tour-body {
    padding: 10px 18px 4px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary, #4a5568);
}
body.dark .axm-tour-body { color: var(--text-secondary, #cbd3e3); }
.axm-tour-body p { margin: 0 0 8px; }
.axm-tour-body p:last-child { margin-bottom: 0; }
.axm-tour-body kbd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(var(--primary-rgb, 113,163,205), 0.1);
    color: var(--primary, #71a3cd);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    border: 1px solid rgba(var(--primary-rgb, 113,163,205), 0.2);
}

/* Footer */
.axm-tour-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px 16px;
    margin-top: 6px;
    border-top: 1px solid var(--border-primary, rgba(0,0,0,0.06));
    flex-wrap: nowrap;
}
body.dark .axm-tour-footer { border-top-color: rgba(255,255,255,.06); }

.axm-tour-progress {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary, #8892b0);
    white-space: nowrap;
    flex-shrink: 0;
}
.axm-tour-progress #axm-tour-step-counter { white-space: nowrap; }
.axm-tour-dots {
    display: inline-flex;
    gap: 5px;
    margin-inline-start: 4px;
    flex-wrap: nowrap;
    max-width: 110px;
    overflow: hidden;
}
.axm-tour-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-primary, rgba(0,0,0,.15));
    transition: all .25s ease;
}
.axm-tour-dot.active {
    background: var(--primary, #71a3cd);
    transform: scale(1.35);
}
.axm-tour-dot.done { background: rgba(var(--primary-rgb, 113,163,205), 0.45); }

.axm-tour-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}
.axm-tour-btn {
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s ease;
    font-family: inherit;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.axm-tour-btn-ghost {
    background: transparent;
    color: var(--text-tertiary, #8892b0);
    border-color: transparent;
}
.axm-tour-btn-ghost:hover { color: var(--text-primary, #1a202c); background: rgba(0,0,0,.04); }
body.dark .axm-tour-btn-ghost:hover { color: #fff; background: rgba(255,255,255,.06); }

.axm-tour-btn-secondary {
    background: rgba(var(--primary-rgb, 113,163,205), 0.08);
    color: var(--primary, #71a3cd);
    border-color: rgba(var(--primary-rgb, 113,163,205), 0.2);
}
.axm-tour-btn-secondary:hover {
    background: rgba(var(--primary-rgb, 113,163,205), 0.15);
    border-color: rgba(var(--primary-rgb, 113,163,205), 0.35);
}
.axm-tour-btn-primary {
    background: var(--gradient-btn, linear-gradient(135deg, #71a3cd, #5082b5));
    color: #fff;
    border-color: transparent;
}
.axm-tour-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(var(--primary-rgb, 113,163,205), 0.35);
}
.axm-tour-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* "New feature" pulsing badge on the tour trigger */
.axm-tour-new-badge {
    position: absolute;
    top: -2px;
    inset-inline-end: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, .6);
    animation: axm-tour-pulse 2s infinite;
}
@keyframes axm-tour-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); }
    70%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Hide new-badge once tour is seen */
body.axm-tour-seen .axm-tour-new-badge { display: none; }

/* Tour trigger in menus */
.axm-tour-trigger {
    position: relative;
}

/* --- RTL ------------------------------------------------------ */
html[dir="rtl"] .axm-tour-popover[data-placement="right"] .axm-tour-arrow { left: auto; right: -7px; border: inherit; border-left: none; border-bottom: none; }
html[dir="rtl"] .axm-tour-popover[data-placement="left"]  .axm-tour-arrow { right: auto; left: -7px; border: inherit; border-right: none; border-top: none; }
html[dir="rtl"] .axm-tour-popover[data-placement="top"]   .axm-tour-arrow { left: auto; right: 24px; }
html[dir="rtl"] .axm-tour-popover[data-placement="bottom"] .axm-tour-arrow { left: auto; right: 24px; }
html[dir="rtl"] .axm-tour-header,
html[dir="rtl"] .axm-tour-footer { direction: rtl; }

/* --- Responsive ---------------------------------------------- */
@media (max-width: 768px) {
    .axm-tour-popover {
        width: calc(100vw - 24px);
        max-width: 420px;
        left: 12px !important;
        right: 12px;
        /* Force mobile popover to dock near bottom for reachability */
    }
    .axm-tour-popover.mobile-dock {
        position: fixed;
        left: 12px !important;
        right: 12px;
        bottom: 12px;
        top: auto !important;
    }
    .axm-tour-popover.mobile-dock .axm-tour-arrow { display: none; }
    .axm-tour-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .axm-tour-actions { flex: 1; justify-content: flex-end; }
    .axm-tour-btn { padding: 9px 14px; font-size: 13px; }
}

@media (max-width: 380px) {
    .axm-tour-title { font-size: 14px; }
    .axm-tour-body { font-size: 13px; padding: 8px 14px 2px; }
    .axm-tour-header { padding: 14px 14px 0; }
    .axm-tour-footer { padding: 12px 14px 14px; }
    .axm-tour-btn { padding: 8px 10px; font-size: 12px; }
    .axm-tour-icon { width: 30px; height: 30px; font-size: 14px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .axm-tour-overlay,
    .axm-tour-spotlight,
    .axm-tour-popover { transition: opacity .15s ease; }
}
