/* ========================================
   APEX Onboarding Tour & Contextual Help
   Zero-dependency guided tour and tooltip system
   ======================================== */


/* ========================================
   1. TOUR OVERLAY & SPOTLIGHT
   ======================================== */

.apex-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.apex-tour-overlay.active {
    pointer-events: auto;
}

.apex-tour-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 10000;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.apex-tour-backdrop.active {
    opacity: 1;
}

/* Spotlight cutout around target element */
.apex-tour-spotlight {
    position: absolute;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.6);
    z-index: 10001;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.apex-tour-spotlight::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid #1b17ff;
    border-radius: 12px;
    animation: tourPulse 2s ease-in-out infinite;
}

@keyframes tourPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(27, 23, 255, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(27, 23, 255, 0); }
}


/* ========================================
   2. TOUR TOOLTIP / STEP CARD
   ======================================== */

.apex-tour-card {
    position: absolute;
    z-index: 10002;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: white;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    animation: tourCardIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes tourCardIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.apex-tour-card-header {
    padding: 20px 20px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.apex-tour-step-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #1b17ff;
    background: rgba(27, 23, 255, 0.08);
    padding: 3px 10px;
    border-radius: 99px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.apex-tour-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #94A3B8;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.apex-tour-close:hover {
    background: #F1F5F9;
    color: #1E293B;
}

.apex-tour-card-body {
    padding: 12px 20px 20px;
}

.apex-tour-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: #1E293B;
    margin: 8px 0 6px;
    line-height: 1.3;
}

.apex-tour-description {
    font-size: 0.875rem;
    color: #64748B;
    line-height: 1.55;
    margin: 0;
}

.apex-tour-card-footer {
    padding: 12px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Progress dots */
.apex-tour-dots {
    display: flex;
    gap: 6px;
}

.apex-tour-dot {
    width: 7px;
    height: 7px;
    border-radius: 99px;
    background: #E2E8F0;
    transition: background 0.2s, width 0.2s;
}

.apex-tour-dot.active {
    background: #1b17ff;
    width: 18px;
}

.apex-tour-dot.completed {
    background: #ff2674;
}

/* Navigation buttons */
.apex-tour-nav {
    display: flex;
    gap: 8px;
}

.apex-tour-btn {
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    font-family: inherit;
}

.apex-tour-btn-secondary {
    background: #F1F5F9;
    color: #475569;
}

.apex-tour-btn-secondary:hover {
    background: #E2E8F0;
}

.apex-tour-btn-primary {
    background: #1b17ff;
    color: white;
}

.apex-tour-btn-primary:hover {
    background: #1512d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27, 23, 255, 0.3);
}

/* Arrow pointer */
.apex-tour-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.04);
}

.apex-tour-card[data-position="bottom"] .apex-tour-arrow {
    top: -6px;
    left: 24px;
}

.apex-tour-card[data-position="top"] .apex-tour-arrow {
    bottom: -6px;
    left: 24px;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

.apex-tour-card[data-position="left"] .apex-tour-arrow {
    right: -6px;
    top: 24px;
    box-shadow: 2px -2px 4px rgba(0, 0, 0, 0.04);
}

.apex-tour-card[data-position="right"] .apex-tour-arrow {
    left: -6px;
    top: 24px;
}


/* ========================================
   3. WELCOME MODAL (First-time users)
   ======================================== */

.apex-welcome-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.apex-welcome-card {
    width: 480px;
    max-width: calc(100vw - 32px);
    background: white;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: welcomeIn 0.35s ease-out;
}

@keyframes welcomeIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.apex-welcome-header {
    background: linear-gradient(135deg, #1b17ff 0%, #4F46E5 100%);
    padding: 32px 32px 28px;
    text-align: center;
    color: white;
}

.apex-welcome-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
}

.apex-welcome-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 6px;
}

.apex-welcome-header p {
    font-size: 0.875rem;
    opacity: 0.85;
    margin: 0;
}

.apex-welcome-body {
    padding: 24px 32px;
}

.apex-welcome-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.apex-welcome-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.apex-welcome-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(27, 23, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1b17ff;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.apex-welcome-feature-text strong {
    display: block;
    font-size: 0.875rem;
    color: #1E293B;
    margin-bottom: 2px;
}

.apex-welcome-feature-text span {
    font-size: 0.8125rem;
    color: #64748B;
    line-height: 1.4;
}

.apex-welcome-footer {
    padding: 16px 32px 24px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.apex-welcome-skip {
    padding: 10px 20px;
    background: none;
    border: none;
    color: #64748B;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px;
    font-family: inherit;
}

.apex-welcome-skip:hover {
    background: #F1F5F9;
}

.apex-welcome-start {
    padding: 10px 24px;
    background: #1b17ff;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.apex-welcome-start:hover {
    background: #1512d9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(27, 23, 255, 0.3);
}


/* ========================================
   4. CONTEXTUAL HELP TOOLTIPS
   ======================================== */

.apex-help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 99px;
    background: rgba(27, 23, 255, 0.08);
    color: #1b17ff;
    font-size: 0.625rem;
    font-weight: 700;
    cursor: help;
    border: none;
    vertical-align: middle;
    margin-left: 4px;
    transition: background 0.15s;
    font-family: inherit;
}

.apex-help-trigger:hover {
    background: rgba(27, 23, 255, 0.15);
}

.apex-help-tooltip {
    position: absolute;
    z-index: 9999;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 16px;
    animation: helpIn 0.2s ease-out;
    pointer-events: auto;
}

@keyframes helpIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.apex-help-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.apex-help-tooltip-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1E293B;
}

.apex-help-tooltip-close {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: #94A3B8;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apex-help-tooltip-close:hover {
    background: #F1F5F9;
    color: #1E293B;
}

.apex-help-tooltip-body {
    font-size: 0.8125rem;
    color: #475569;
    line-height: 1.55;
}

.apex-help-tooltip-body a {
    color: #1b17ff;
    text-decoration: none;
    font-weight: 500;
}

.apex-help-tooltip-body a:hover {
    text-decoration: underline;
}

.apex-help-tooltip-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #F1F5F9;
    font-size: 0.75rem;
    color: #94A3B8;
}

/* Help tooltip arrow */
.apex-help-tooltip[data-position="bottom"]::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 16px;
    width: 10px;
    height: 10px;
    background: white;
    border-top: 1px solid #E2E8F0;
    border-left: 1px solid #E2E8F0;
    transform: rotate(45deg);
}


/* ========================================
   5. DARK MODE
   ======================================== */

[data-theme="dark"] .apex-tour-card,
[data-theme="dark"] .apex-help-tooltip {
    background: #1E293B;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .apex-tour-title,
[data-theme="dark"] .apex-help-tooltip-title {
    color: #F1F5F9;
}

[data-theme="dark"] .apex-tour-description,
[data-theme="dark"] .apex-help-tooltip-body {
    color: #94A3B8;
}

[data-theme="dark"] .apex-tour-close:hover,
[data-theme="dark"] .apex-help-tooltip-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .apex-tour-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #94A3B8;
}

[data-theme="dark"] .apex-tour-arrow,
[data-theme="dark"] .apex-help-tooltip[data-position="bottom"]::before {
    background: #1E293B;
}

[data-theme="dark"] .apex-welcome-card {
    background: #1E293B;
}

[data-theme="dark"] .apex-tour-dot {
    background: #334155;
}


/* ========================================
   6. RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    .apex-tour-card {
        width: calc(100vw - 24px);
        position: fixed;
        bottom: 16px;
        left: 12px;
        right: 12px;
    }

    .apex-tour-arrow { display: none; }

    .apex-welcome-card {
        margin: 16px;
        border-radius: 14px;
    }

    .apex-welcome-header,
    .apex-welcome-body,
    .apex-welcome-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
}
