/*
 * Product tour styles — theme-only layer over driver.js defaults.
 *
 * Rule: do not fight driver.js layout. Driver.js 1.3.x uses `all:unset` on its
 * popover and buttons, then styles everything explicitly. We only override
 * color, font, border-radius — never flex, display, or positioning of footer
 * buttons, otherwise we risk hiding them.
 */

:root {
    --tour-accent: 99, 102, 241;
    --tour-popover-bg: #ffffff;
    --tour-popover-fg: #1f2937;
    --tour-popover-muted: #6b7280;
    --tour-popover-border: rgba(0, 0, 0, 0.08);
}

/* Dark mode: the app uses pure #000000 as --background (modern.css), so the
   popover surface must be distinctly lighter with a clearly visible border
   and a soft accent-tinted glow — otherwise it vanishes into the background. */
[data-theme="dark"] {
    --tour-popover-bg: #1e293b;
    --tour-popover-fg: #f8fafc;
    --tour-popover-muted: #cbd5e1;
    --tour-popover-border: rgba(148, 163, 184, 0.32);
}

/* ---- Popover theme ----
 * DO NOT add `position`, `overflow`, `transform`, or anything that affects
 * layout/positioning here. Driver.js uses `position: fixed` with computed
 * `top`/`left` — any override will detach the popover from its target and
 * the popover will appear at the bottom of the page. Theme only: colors,
 * typography, radius, shadow, border.
 */
.driver-popover.enne-tour-popover {
    background-color: var(--tour-popover-bg) !important;
    color: var(--tour-popover-fg) !important;
    border-radius: 16px !important;
    padding: 18px 20px 16px !important;
    max-width: min(360px, calc(100vw - 32px)) !important;
    border: 1px solid var(--tour-popover-border) !important;
    box-shadow:
        0 24px 64px -20px rgba(17, 24, 39, 0.28),
        0 12px 28px -14px rgba(17, 24, 39, 0.16) !important;
}

[data-theme="dark"] .driver-popover.enne-tour-popover {
    background-color: var(--tour-popover-bg) !important;
    /* Against pure-black bg, dark shadows don't render — we use an accent-tinted
       glow plus an inner ring so the popover edge reads clearly. */
    box-shadow:
        0 0 0 1px rgba(var(--tour-accent), 0.35),
        0 24px 48px -12px rgba(var(--tour-accent), 0.22),
        0 16px 32px -16px rgba(0, 0, 0, 0.6) !important;
}

.driver-popover.enne-tour-popover .driver-popover-title {
    color: var(--tour-popover-fg) !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 650 !important;
    line-height: 1.35 !important;
    letter-spacing: -0.01em !important;
    margin-bottom: 6px !important;
}

.driver-popover.enne-tour-popover .driver-popover-description {
    color: var(--tour-popover-muted) !important;
    font-family: inherit !important;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
}

.enne-tour-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.enne-tour-badge,
.enne-tour-progress-inline {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 9px;
}

.enne-tour-badge {
    background: rgba(var(--tour-accent), 0.14);
    color: rgb(var(--tour-accent));
    box-shadow: inset 0 0 0 1px rgba(var(--tour-accent), 0.12);
}

.enne-tour-progress-inline {
    background: rgba(148, 163, 184, 0.12);
    color: var(--tour-popover-muted);
}

.enne-tour-description-copy {
    color: var(--tour-popover-fg);
}

.enne-tour-step-hint {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(var(--tour-accent), 0.07);
    border: 1px solid rgba(var(--tour-accent), 0.12);
    color: var(--tour-popover-fg);
    font-size: 12.5px;
    line-height: 1.5;
}

.driver-popover.enne-tour-popover .driver-popover-close-btn {
    color: var(--tour-popover-muted) !important;
    font-size: 22px !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    transition: background-color 0.15s, color 0.15s !important;
}

.driver-popover.enne-tour-popover .driver-popover-close-btn:hover,
.driver-popover.enne-tour-popover .driver-popover-close-btn:focus {
    color: var(--tour-popover-fg) !important;
}

.driver-popover.enne-tour-popover .driver-popover-progress-text {
    color: var(--tour-popover-muted) !important;
    font-family: inherit !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}

/* Button colors only — leave padding/display/margins to driver.js defaults */
.driver-popover.enne-tour-popover .driver-popover-footer button {
    font-family: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    text-shadow: none !important;
    background-color: transparent !important;
    color: var(--tour-popover-muted) !important;
    border: 1px solid var(--tour-popover-border) !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}

.driver-popover.enne-tour-popover .driver-popover-footer button:hover,
.driver-popover.enne-tour-popover .driver-popover-footer button:focus {
    background-color: rgba(var(--tour-popover-fg-rgb, 31, 41, 55), 0.04) !important;
    color: var(--tour-popover-fg) !important;
}

/* The Next/Continue button is the primary action — solid accent, no gradient. */
.driver-popover.enne-tour-popover .driver-popover-next-btn {
    background-color: rgb(var(--tour-accent)) !important;
    color: #ffffff !important;
    border-color: rgb(var(--tour-accent)) !important;
    padding: 9px 18px !important;
    letter-spacing: 0.01em !important;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08), 0 4px 12px -6px rgba(var(--tour-accent), 0.5) !important;
}

.driver-popover.enne-tour-popover .driver-popover-next-btn:hover,
.driver-popover.enne-tour-popover .driver-popover-next-btn:focus {
    background-color: rgba(var(--tour-accent), 0.92) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(17, 24, 39, 0.1), 0 6px 16px -6px rgba(var(--tour-accent), 0.55) !important;
}

.driver-popover.enne-tour-popover .driver-popover-next-btn:active {
    background-color: rgba(var(--tour-accent), 0.85) !important;
}

.driver-popover.enne-tour-popover .driver-popover-footer button[disabled] {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* Arrow takes popover bg color */
.driver-popover.enne-tour-popover .driver-popover-arrow {
    border-color: var(--tour-popover-bg) !important;
}

/* Custom body action container rendered inside description (for "Try it") */
.enne-tour-body-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0 2px;
}

.enne-tour-body-actions button {
    all: unset;
    background: rgb(var(--tour-accent));
    color: #fff;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.enne-tour-body-actions button:hover { filter: brightness(1.08); }

/* ---- Card pulse animation ----
 * Outline is used for the animated outer ring (not box-shadow) because
 * outlines are NOT clipped by ancestor overflow: hidden — critical for
 * sidebar-anchored steps where .sidebar-minimal clips its descendants.
 */
@keyframes tour-pulse {
    0%, 100% { outline-width: 2px; outline-color: rgba(var(--tour-accent), 0.88); }
    50%      { outline-width: 4px; outline-color: rgba(var(--tour-accent), 0.35); }
}

.tour-target-pulse {
    animation: tour-pulse 1.6s ease-in-out infinite;
    border-radius: inherit;
    outline: 2px solid rgba(var(--tour-accent), 0.88);
    outline-offset: 4px;
    /* Inner glow only — no outer box-shadow ring (would be clipped). */
    box-shadow:
        inset 0 0 0 1px rgba(var(--tour-accent), 0.18),
        0 18px 42px -20px rgba(var(--tour-accent), 0.58);
}

/* Every active target gets a saturated accent outline so non-pulse steps are
   clearly visible inside driver.js's black stage dimmer. */
.driver-active-element {
    outline: 3px solid rgb(var(--tour-accent)) !important;
    outline-offset: 3px !important;
    border-radius: inherit;
}

[data-theme="dark"] .driver-active-element {
    outline-color: rgb(var(--tour-accent)) !important;
    box-shadow: 0 0 0 4px rgba(var(--tour-accent), 0.22) !important;
}

/* When the tour highlights something inside the collapsed sidebar, expand
   it and allow the pulse ring + label to overflow past the 64px edge.
   The transition is suppressed so driver.js measures the final 240px width
   on its very first positioning pass, not the mid-animation width. */
body.tour-sidebar-target .sidebar-minimal {
    width: 240px !important;
    overflow: visible !important;
    transition: none !important;
}
body.tour-sidebar-target .sidebar-minimal .nav-label {
    opacity: 1 !important;
    transition: none !important;
}

.tour-target-pulse[data-tour-action-label]::after {
    content: attr(data-tour-action-label);
    position: absolute;
    top: -12px;
    right: -8px;
    transform: translateY(-100%);
    padding: 6px 10px;
    border-radius: 9999px;
    background: rgb(var(--tour-accent));
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    box-shadow: 0 12px 26px -14px rgba(var(--tour-accent), 0.8);
    z-index: 30;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .tour-target-pulse {
        animation: none;
        outline: 3px solid rgb(var(--tour-accent));
        outline-offset: 4px;
    }

    .tour-target-pulse[data-tour-action-label]::after {
        box-shadow: none;
    }
}

/* ---- Coach mark pulse dots ---- */
.coach-mark-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 11px;
    height: 11px;
    border-radius: 9999px;
    background: rgb(var(--tour-accent));
    cursor: pointer;
    z-index: 40;
    animation: coach-mark-pulse 2s ease-in-out infinite;
    border: 2px solid var(--background, #fff);
}

.coach-mark-dot:focus-visible {
    outline: 2px solid rgb(var(--tour-accent));
    outline-offset: 2px;
}

@keyframes coach-mark-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--tour-accent), 0.55); }
    50%      { box-shadow: 0 0 0 7px rgba(var(--tour-accent), 0); }
}

@media (prefers-reduced-motion: reduce) {
    .coach-mark-dot { animation: none; }
}

.coach-mark-tooltip {
    position: absolute;
    background: var(--tour-popover-bg);
    color: var(--tour-popover-fg);
    border: 1px solid var(--tour-popover-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    line-height: 1.45;
    max-width: 220px;
    box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.35);
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s;
    top: 18px;
    right: 0;
}

.coach-mark-dot:hover + .coach-mark-tooltip,
.coach-mark-dot:focus + .coach-mark-tooltip {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Hints button in sidebar bottom ---- */
.tour-hints-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--foreground-secondary, #6b7280);
    font-size: 13px;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
}

.tour-hints-trigger:hover {
    background: rgba(var(--tour-accent), 0.08);
    color: var(--tour-popover-fg);
}

.tour-hints-trigger .hints-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.tour-hints-menu {
    position: absolute;
    bottom: 56px;
    left: 12px;
    right: 12px;
    background: var(--tour-popover-bg);
    color: var(--tour-popover-fg);
    border: 1px solid var(--tour-popover-border);
    border-radius: 12px;
    box-shadow: 0 18px 32px -12px rgba(0, 0, 0, 0.35);
    padding: 6px;
    z-index: 60;
}

.tour-hints-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    border: none;
    color: var(--tour-popover-fg);
    font-size: 13px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.tour-hints-menu button:hover {
    background: rgba(var(--tour-accent), 0.1);
}

.tour-hints-menu .menu-toggle {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 9999px;
    background: rgba(var(--tour-accent), 0.15);
    color: rgb(var(--tour-accent));
    font-weight: 600;
    text-transform: uppercase;
}

/* ---- Help dropdown (shared partial) ---- */
.tour-help-dropdown {
    position: relative;
    display: inline-flex;
}

.tour-help-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--foreground-secondary, #6b7280);
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.15s;
}

.tour-help-dropdown-trigger:hover {
    background: rgba(var(--tour-accent), 0.08);
    color: var(--tour-popover-fg);
}

.tour-help-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 230px;
    background: var(--tour-popover-bg);
    color: var(--tour-popover-fg);
    border: 1px solid var(--tour-popover-border);
    border-radius: 12px;
    box-shadow: 0 18px 32px -12px rgba(0, 0, 0, 0.35);
    padding: 6px;
    z-index: 60;
}

.tour-help-dropdown-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 12px;
    background: transparent;
    border: none;
    color: var(--tour-popover-fg);
    font-size: 13px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    gap: 10px;
    font-family: inherit;
}

.tour-help-dropdown-menu button:hover:not(:disabled) {
    background: rgba(var(--tour-accent), 0.1);
}

.tour-help-dropdown-menu button:disabled {
    opacity: 0.55;
    cursor: default;
}

.tour-help-dropdown-menu .soon-badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(var(--tour-accent), 0.12);
    color: rgb(var(--tour-accent));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Assistant starter chips ---- */
#assistant-starter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 16px 8px;
    transition: opacity 0.3s ease;
}

#assistant-starter-chips.hidden-chips {
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

.assistant-starter-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--foreground-secondary);
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.assistant-starter-chip:hover {
    background: var(--secondary);
    border-color: var(--input-border);
    color: var(--foreground);
}

.assistant-starter-chip svg {
    opacity: 0.6;
    transition: opacity 0.14s ease;
}

.assistant-starter-chip:hover svg {
    opacity: 0.85;
}

/* During the main tour, pulse the chips to signal the user should click one.
   Only active when the main tour is running AND the chips are visible. */
body.tour-main-active #assistant-starter-chips:not(.hidden-chips) .assistant-starter-chip {
    animation: starter-chip-pulse 1.8s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(var(--tour-accent), 0.5);
}

body.tour-main-active #assistant-starter-chips:not(.hidden-chips) .assistant-starter-chip:nth-child(2) {
    animation-delay: 0.4s;
}

@keyframes starter-chip-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--tour-accent), 0.45);
        transform: translateY(0);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(var(--tour-accent), 0);
        transform: translateY(-1px);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.tour-main-active #assistant-starter-chips:not(.hidden-chips) .assistant-starter-chip {
        animation: none;
        outline: 2px solid rgba(var(--tour-accent), 0.5);
        outline-offset: 3px;
    }
}

/* ---- Resume tour toast ---- */
.tour-resume-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--tour-popover-bg);
    color: var(--tour-popover-fg);
    border: 1px solid var(--tour-popover-border);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow: 0 20px 42px -14px rgba(0, 0, 0, 0.4);
    max-width: 320px;
    font-size: 13px;
    z-index: 9500;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tour-resume-toast .toast-title {
    font-weight: 600;
    font-size: 13.5px;
}

.tour-resume-toast .toast-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.tour-resume-toast button {
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--tour-popover-border);
    background: transparent;
    color: var(--tour-popover-fg);
    font-family: inherit;
}

.tour-resume-toast button.primary {
    background: rgb(var(--tour-accent));
    color: #fff;
    border-color: rgb(var(--tour-accent));
}
