/**
 * Smart Onboarding v2026 - Styles
 * Design Premium SaaS, Glassmorphism, Mobile First
 * 
 * ⚠️ UTILISE les design tokens (--dt-*) depuis design-tokens.css
 * Dark mode géré automatiquement via data-theme="dark"
 */

/* =====================================================
   TOUR ACTIVE STATE — Map z-index reset + scroll lock
===================================================== */
body.tour-active .leaflet-container,
body.tour-active #map,
body.tour-active .map-container {
    z-index: 1 !important;
}


/* =====================================================
   OVERLAY CLIQUE-THROUGH (Le site reste utilisable)
===================================================== */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 999992;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--tour-anim-duration, 0.3s) ease;
}

.tour-overlay.visible {
    opacity: 1;
}

.tour-backdrop {
    display: none;
}

/* =====================================================
   HIGHLIGHT ELEMENT (Spotlight Effect)
===================================================== */
.tour-highlight {
    position: relative;
    z-index: 999993 !important;
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.5),
        0 0 0 8px rgba(59, 130, 246, 0.1),
        0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3)) !important;
    border-radius: var(--dt-radius-md, 8px);
    transition: all var(--tour-anim-duration, 0.3s) ease;
    animation: tour-pulse 2s infinite;
}

.tour-highlight-fixed {
    position: fixed !important;
    z-index: 999993 !important;
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.5),
        0 0 0 8px rgba(59, 130, 246, 0.1),
        0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3)) !important;
    border-radius: var(--dt-radius-md, 8px);
    animation: tour-pulse 2s infinite;
}

@keyframes tour-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6), 0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0), 0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0), 0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
    }
}

/* =====================================================
   POPOVER CARD (Desktop)
===================================================== */
.tour-popover {
    position: absolute;
    z-index: 999998;
    width: 380px;
    max-width: 90vw;

    background: var(--dt-tour-tooltip-bg, rgba(255, 255, 255, 0.95));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid var(--dt-border-subtle, rgba(255, 255, 255, 0.2));
    border-radius: var(--dt-radius-lg, 12px);
    box-shadow: var(--dt-tour-tooltip-shadow, 0 20px 25px -5px rgba(0, 0, 0, 0.1));

    opacity: 0;
    transform: scale(0.95) translateY(10px);
    visibility: hidden;
    transition:
        opacity var(--tour-anim-duration, 0.3s) cubic-bezier(0.16, 1, 0.3, 1),
        transform var(--tour-anim-duration, 0.3s) cubic-bezier(0.16, 1, 0.3, 1),
        visibility var(--tour-anim-duration, 0.3s);

    font-family: var(--dt-font-family, 'Inter', system-ui, sans-serif);
    color: var(--dt-tour-tooltip-text, var(--dt-text-primary, #1e293b));
}

.tour-popover.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
}

/* =====================================================
   POPOVER INTERNAL LAYOUT
===================================================== */
.tour-header {
    padding: var(--dt-space-4) var(--dt-space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--dt-border-subtle, rgba(0, 0, 0, 0.05));
}

.tour-step-badge {
    background: linear-gradient(135deg, var(--dt-info, #3b82f6), var(--dt-accent, #8b5cf6));
    color: white;
    font-size: var(--dt-text-xs, 11px);
    font-weight: var(--dt-font-bold, 700);
    padding: var(--dt-space-1) var(--dt-space-3);
    border-radius: var(--dt-radius-pill, 20px);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.tour-body {
    padding: var(--dt-space-5);
    line-height: var(--dt-leading-relaxed, 1.6);
    font-size: var(--dt-text-base, 15px);
}

.tour-title {
    font-weight: var(--dt-font-bold, 700);
    font-size: var(--dt-text-lg, 18px);
    margin-bottom: var(--dt-space-2);
    display: flex;
    align-items: center;
    gap: var(--dt-space-2);
    color: var(--dt-text-title, #1e293b);
}

.tour-content {
    color: var(--dt-text-secondary, #64748b);
}

.tour-footer {
    padding: var(--dt-space-3) var(--dt-space-5) var(--dt-space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* =====================================================
   CONTROLS & BUTTONS
===================================================== */
.tour-btn {
    border: none;
    font-weight: var(--dt-font-semibold, 600);
    font-size: var(--dt-text-sm, 14px);
    padding: var(--dt-space-3) var(--dt-space-5);
    border-radius: var(--dt-radius-md, 8px);
    cursor: pointer;
    transition: all var(--dt-transition-base, 0.2s ease);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tour-btn-primary {
    background: linear-gradient(135deg, var(--dt-info, #3b82f6) 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.tour-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4);
}

.tour-btn-secondary {
    background: transparent;
    color: var(--dt-text-secondary, #64748b);
}

.tour-btn-secondary:hover {
    background: var(--dt-bg-inset, rgba(0, 0, 0, 0.05));
    color: var(--dt-text-title, #1e293b);
}

.tour-btn-skip {
    font-size: var(--dt-text-xs, 12px);
    color: var(--dt-text-tertiary, #94a3b8);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: var(--dt-transition-fast, 0.2s);
}

.tour-btn-skip:hover {
    color: var(--dt-text-secondary, #64748b);
    text-decoration-color: currentColor;
}

/* =====================================================
   ARROWS
===================================================== */
.tour-arrow {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--dt-tour-tooltip-bg, rgba(255, 255, 255, 0.95));
    transform: rotate(45deg);
    z-index: -1;
}

.tour-popover[data-placement="top"] .tour-arrow {
    bottom: -8px;
    left: 50%;
    margin-left: -8px;
}

.tour-popover[data-placement="bottom"] .tour-arrow {
    top: -8px;
    left: 50%;
    margin-left: -8px;
}

.tour-popover[data-placement="left"] .tour-arrow {
    right: -8px;
    top: 50%;
    margin-top: -8px;
}

.tour-popover[data-placement="right"] .tour-arrow {
    left: -8px;
    top: 50%;
    margin-top: -8px;
}

/* =====================================================
   PROGRESS BAR
===================================================== */
.tour-progress {
    height: 4px;
    background: var(--dt-border, #e2e8f0);
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    border-radius: 0 0 var(--dt-radius-lg, 12px) var(--dt-radius-lg, 12px);
    overflow: hidden;
}

.tour-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--dt-info, #3b82f6), var(--dt-accent, #8b5cf6));
    transition: width var(--tour-anim-duration, 0.3s) ease;
}

/* =====================================================
   MOBILE SPECIFIC: COMPACT POPUP (pas de bottom sheet)
   Le popover reste un petit popup flottant en mobile,
   positionné au-dessus de la bottom nav.
===================================================== */
@media (max-width: 768px) {
    .tour-popover.mobile-sheet {
        position: fixed !important;
        top: auto !important;
        left: 5vw !important;
        right: 5vw !important;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
        width: 90vw !important;
        max-width: 90vw !important;
        transform: scale(0.95) translateY(10px);
        border-radius: 16px;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15), 0 4px 20px rgba(0, 0, 0, 0.1);
        margin: 0;
    }

    .tour-popover.mobile-sheet.visible {
        transform: scale(1) translateY(0);
    }

    .tour-popover.mobile-sheet .tour-arrow {
        display: none;
    }

    /* Pas de handle de bottom sheet */
    .tour-popover.mobile-sheet::before {
        display: none;
    }

    .tour-body {
        padding: 10px 16px;
        font-size: 13px;
    }

    .tour-title {
        font-size: 15px;
    }

    .tour-header {
        padding: 8px 16px 0;
        border-bottom: none;
    }

    .tour-footer {
        padding: 8px 16px 12px;
    }

    .tour-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* =====================================================
   HIGHLIGHT EFFECT VARIANTS
   Applied as modifier classes on .tour-highlight :
   - .tour-highlight--pulse  → strong rhythmic expanding ring
   - .tour-highlight--neon   → glowing neon border animation
===================================================== */

/* ── Pulse Highlight ─────────────────────────────── */
.tour-highlight--pulse {
    animation: tour-pulse-highlight 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
}

@keyframes tour-pulse-highlight {

    0%,
    100% {
        box-shadow:
            0 0 0 0 rgba(16, 185, 129, 0.7),
            0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
    }

    50% {
        box-shadow:
            0 0 0 16px rgba(16, 185, 129, 0),
            0 0 20px 2px rgba(16, 185, 129, 0.15),
            0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
    }
}

/* ── Neon Border ──────────────────────────────────── */
.tour-highlight--neon {
    animation: tour-neon-glow 2.5s ease-in-out infinite alternate !important;
    border: 2px solid rgba(6, 182, 212, 0.8) !important;
    border-radius: var(--dt-radius-md, 8px) !important;
}

@keyframes tour-neon-glow {
    0% {
        box-shadow:
            0 0 6px rgba(6, 182, 212, 0.6),
            0 0 14px rgba(6, 182, 212, 0.3),
            0 0 30px rgba(6, 182, 212, 0.15),
            inset 0 0 8px rgba(6, 182, 212, 0.08),
            0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
        border-color: rgba(6, 182, 212, 0.8);
    }

    100% {
        box-shadow:
            0 0 10px rgba(168, 85, 247, 0.6),
            0 0 22px rgba(168, 85, 247, 0.3),
            0 0 45px rgba(168, 85, 247, 0.12),
            inset 0 0 12px rgba(168, 85, 247, 0.06),
            0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3));
        border-color: rgba(168, 85, 247, 0.7);
    }
}

/* ── No Animation (static highlight) ─────────────── */
.tour-highlight--static {
    animation: none !important;
    box-shadow:
        0 0 0 4px rgba(59, 130, 246, 0.5),
        0 0 0 8px rgba(59, 130, 246, 0.1),
        0 0 0 100vmax var(--dt-tour-overlay, rgba(0, 0, 0, 0.3)) !important;
}

/* =====================================================
   RESTART BUTTON (Bouton visite guidée sur la carte)
===================================================== */
.tour-restart-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000 !important;
    width: 34px;
    height: 34px;
    background: white;
    background-color: var(--dt-bg-surface, #ffffff);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    margin-bottom: 5px;
}

.tour-restart-btn .lc-icon {
    color: #6d28d9;
    font-size: 14px;
}

.tour-restart-btn:hover {
    background: #f5f3ff !important;
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(109, 40, 217, 0.25);
}

.tour-restart-btn:hover .lc-icon {
    color: #5b21b6;
}

.tour-restart-btn:active {
    transform: scale(0.95);
}

/* Specific override when inside Leaflet control container */
.leaflet-bar .tour-restart-btn {
    border: none;
    border-bottom: 1px solid #ccc;
    box-shadow: none;
    border-radius: 0;
}

.leaflet-bar .tour-restart-btn:last-child {
    border-bottom: none;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

/* Caché quand aucune étape disponible */
.tour-restart-btn.hidden {
    display: none !important;
}

/* =====================================================
   PULSE ATTENTION — Bouton restart
===================================================== */
/* v6.5.6 PERF : animation 100% composée (transform + opacity, pas box-shadow) */
@keyframes tour-pulse-attention {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    70% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

.tour-restart-btn.pulse-attention {
    animation: tour-pulse-attention 2s infinite;
    border-color: #10b981 !important;
    color: #10b981 !important;
}

/* =====================================================
   DARK MODE — Restart Button
===================================================== */
[data-theme="dark"] .tour-restart-btn {
    background-color: var(--dt-bg-surface, #1e293b);
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .tour-restart-btn:hover {
    background: rgba(109, 40, 217, 0.15) !important;
}

[data-theme="dark"] .leaflet-bar .tour-restart-btn {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   DARK MODE — Handled automatically by design-tokens.css
   No separate .tour-theme-dark overrides needed!
   All vars inherit from data-theme="dark" tokens.
===================================================== */

/* =====================================================
   PREFERS REDUCED MOTION (WCAG AA)
===================================================== */
@media (prefers-reduced-motion: reduce) {

    .tour-highlight,
    .tour-highlight--pulse,
    .tour-highlight--neon,
    .tour-highlight--static,
    .tour-restart-btn.pulse-attention {
        animation: none !important;
    }

    .tour-popover,
    .tour-overlay {
        transition-duration: 0s !important;
    }
}