/**
 * EmbedPress Onboarding Wizard Styles
 */

@import "../Shared/styles/variables.scss";

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap");

$ep-brand: #5b4e96;
$ep-brand-dark: #474559;
$ep-brand-light: #f5f6fc;
$ep-brand-lighter: #f1f3fb;
$ep-text-primary: #24272b;
$ep-text-secondary: #6a758c;
$ep-border: #eaebf3;
$ep-green: #4ad750;
$ep-coral: #ff7369;

.embedpress-onboarding-wrapper {
    margin: 0;
    padding: 0;
    background: #f5f7fd;
    min-height: 100vh;
    margin-left: -20px;
}

.ep-ob {
    font-family:
        "DM Sans",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    max-width: 960px;
    margin: 0 auto;
    color: $ep-text-primary;

    &__header {
        display: flex;
        justify-content: center;
        padding: 16px 24px 0;
    }

    &__body {
        background: #fff;
        border-radius: 20px;
        border: 1px solid $ep-border;
        margin: 32px 24px;
    }

    &__body-inner {
        padding: 32px 48px;
    }

    &__footer {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 12px;
        padding: 0 24px 16px;
    }
}

// ---------- Tab-style stepper ----------
.ep-ob-stepper {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid $ep-border;
    border-radius: 10px;
    padding: 6px 8px;
    gap: 4px;

    &__tab {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 20px;
        border-radius: 8px;
        cursor: default;
        transition: all 0.2s ease;

        &--active {
            background: $ep-brand-light;

            .ep-ob-stepper__label {
                color: $ep-brand;
                font-weight: 600;
            }
        }

        &--completed .ep-ob-stepper__label {
            color: $ep-text-primary;
            font-weight: 500;
        }

        &--upcoming .ep-ob-stepper__label {
            color: $ep-text-secondary;
        }
    }

    &__icon {
        display: flex;
        align-items: center;
        flex-shrink: 0;

        svg {
            display: block;
        }
    }

    &__label {
        font-size: 14px;
        color: $ep-text-secondary;
        white-space: nowrap;
    }
}

// ---------- Step headings ----------
.ep-ob-step {
    &__heading {
        font-size: 20px;
        font-weight: 700;
        color: $ep-text-primary;
        margin: 0 0 10px;
        text-align: center;
    }

    &__subheading {
        font-size: 14px;
        color: $ep-text-secondary;
        margin: 0 0 28px;
        line-height: 1.5;
        text-align: center;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

// ---------- Buttons ----------
.ep-ob-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    line-height: 1.4;

    &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    &--primary {
        background: $ep-brand;
        color: #fff;

        &:hover:not(:disabled) {
            background: darken($ep-brand, 8%);
        }
    }

    &--secondary {
        background: #fff;
        color: $ep-text-primary;
        border: 1.5px solid $ep-border;

        &:hover:not(:disabled) {
            background: $ep-brand-light;
            border-color: $ep-brand;
        }
    }

    &--text {
        background: transparent;
        color: $ep-text-secondary;
        padding: 10px 16px;
        font-weight: 500;

        &:hover {
            color: $ep-brand;
        }
    }

    &--upgrade {
        background: $ep-coral;
        color: #fff;
        padding: 12px 24px;
        border-radius: 10px;

        &:hover {
            background: darken($ep-coral, 8%);
            color: #fff;
        }
    }

    &--outline {
        background: transparent;
        color: $ep-text-primary;
        padding: 10px 16px;
        font-weight: 500;

        &:hover {
            color: $ep-brand;
        }
    }
}

// ---------- Toggle cards ----------
.ep-ob-toggle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;

    @media (min-width: 640px) {
        grid-template-columns: repeat(2, 1fr);
    }
}

.ep-ob-toggle-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid $ep-border;
    border-radius: 8px;
    transition: all 0.2s ease;

    &.active {
        background: rgba($ep-brand, 0.02);
    }

    &__body {
        flex: 1;
        min-width: 0;
    }

    &__title {
        font-size: 14px;
        font-weight: 600;
        color: $ep-text-primary;
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 4px;
    }

    &__desc {
        font-size: 12px;
        color: $ep-text-secondary;
        line-height: 1.5;
    }
}

.ep-ob-pro-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    line-height: 1;
    font-weight: 700;
    color: #f5a623;

    svg {
        width: 14px;
        height: 14px;
    }
}

/* ---------- Site Performance card ---------- */
.ep-ob-perf-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-right: 2px;
    border-radius: 5px;
    background: rgba($ep-brand, 0.1);
    color: $ep-brand;
    flex-shrink: 0;

    svg {
        width: 14px;
        height: 14px;
    }
}

.ep-ob-expt-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba($ep-brand, 0.12);
    color: $ep-brand;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ep-ob-perf-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: #15803d;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;

    &::before {
        content: '';
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: currentColor;
        flex-shrink: 0;
    }
}

.ep-ob-perf-error {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 6px;
    background: rgba(#dc2626, 0.08);
    color: #b91c1c;
    font-size: 12px;
    line-height: 1.5;
}

.ep-ob-pro-popup__icon {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;

    svg {
        width: 48px;
        height: 48px;
    }
}

.ep-ob-modal--pro {
    text-align: center;
    max-width: 400px;

    .ep-ob-btn--upgrade {
        margin-top: 16px;
    }
}

// ---------- Toggle switch ----------
.ep-ob-toggle {
    position: relative;
    flex-shrink: 0;

    input {
        opacity: 0;
        width: 0;
        height: 0;
        position: absolute;
    }

    &__slider {
        display: block;
        width: 40px;
        height: 22px;
        background: $ep-border;
        border-radius: 11px;
        cursor: pointer;
        transition: background 0.2s ease;
        position: relative;

        &::after {
            content: "";
            position: absolute;
            top: 3px;
            left: 3px;
            width: 16px;
            height: 16px;
            background: #fff;
            border-radius: 50%;
            transition: transform 0.2s ease;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
        }
    }

    input:checked + &__slider {
        background: $ep-brand;

        &::after {
            transform: translateX(18px);
        }
    }
}

// ---------- Step 1: Welcome ----------
.ep-ob-step--welcome {
    text-align: center;
}

.ep-ob-welcome-illustration {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
}

.ep-ob-platforms-grid {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    gap: 8px;
    justify-content: center;
    transform: rotate(45deg);
    margin: 10px auto 20px;
    margin-top: 20px;
}

.ep-ob-platform-icon {
    width: 44px;
    height: 44px;
    background: #fff;
    border: 1px solid $ep-border;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-45deg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;

    &:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }

    img {
        display: block;
        object-fit: contain;
    }
}

.ep-ob-platforms-img {
    max-width: 340px;
    width: 100%;
    height: auto;
}

.ep-ob-welcome-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.ep-ob-consent-row {
    font-size: 12px;
    color: $ep-text-secondary;
    text-align: center;
    line-height: 1.5;
}

.ep-ob-consent-link {
    background: none;
    border: none;
    color: $ep-brand;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;

    &:hover {
        color: darken($ep-brand, 10%);
    }
}

// ---------- Settings Summary (Final Step) ----------
.ep-ob-settings-summary {
    background: $ep-brand-light;
    border: 1px solid $ep-border;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;

    &__title {
        font-size: 14px;
        font-weight: 600;
        color: $ep-text-primary;
        margin: 0 0 12px;
    }

    &__grid {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 16px;
    }

    &__item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 13px;
        padding: 4px 10px;
        border-radius: 6px;
        background: #fff;
        border: 1px solid $ep-border;

        &--on {
            border-color: rgba($ep-green, 0.3);
        }

        &--off {
            opacity: 0.6;
        }
    }

    &__indicator {
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    &__label {
        font-weight: 500;
        color: $ep-text-primary;
        white-space: nowrap;
    }
}

// ---------- Step 3: Features (upsell) ----------
.ep-ob-step--features {
    // No extra centering needed
}

.ep-ob-features-split {
    display: flex;
    gap: 40px;
    align-items: center;

    @media (max-width: 720px) {
        flex-direction: column;
    }
}

.ep-ob-features-left {
    flex: 1;
    min-width: 0;
}

.ep-ob-features__heading {
    font-size: 22px;
    font-weight: 700;
    color: $ep-text-primary;
    margin: 0 0 8px;
    line-height: 1.3;
}

.ep-ob-features__subheading {
    font-size: 13px;
    color: $ep-text-secondary;
    line-height: 1.6;
    margin: 0 0 20px;
}

.ep-ob-features-checklist {
    margin-bottom: 24px;

    &__row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 24px;
        margin-bottom: 8px;
    }

    &__item {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 13px;
        color: $ep-text-primary;
        font-weight: 500;

        svg {
            flex-shrink: 0;
        }
    }
}

.ep-ob-features-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.ep-ob-features-right {
    flex-shrink: 0;
    width: 280px;

    @media (max-width: 720px) {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

.ep-ob-features-img-wrapper {
    position: relative;
    display: inline-block;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    outline: none;

    &:focus-visible {
        box-shadow: 0 0 0 3px rgba($ep-brand, 0.35);
    }
}

.ep-ob-features-img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.ep-ob-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    display: flex;
    pointer-events: none;
    transition: transform 0.2s ease;
    margin-top: 12px;
}

.ep-ob-features-img-wrapper:hover .ep-ob-play-icon {
    transform: translate(-50%, -50%) scale(1.08);
}

// ---------- Video Popup ----------
.ep-ob-video-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ep-ob-video-popup {
    position: relative;
    width: min(900px, 100%);
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);

    iframe {
        width: 100%;
        height: 100%;
        border: 0;
        display: block;
    }
}

.ep-ob-video-close {
    position: absolute;
    top: -44px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    display: flex;

    &:hover {
        opacity: 0.8;
    }
}

// ---------- Modals ----------
.ep-ob-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;

    &--dark {
        background: rgba(30, 30, 60, 0.7);
    }
}

.ep-ob-modal {
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    max-width: 480px;
    width: 100%;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);

    &__close {
        position: absolute;
        top: 12px;
        right: 12px;
        background: none;
        border: none;
        cursor: pointer;
        color: $ep-text-secondary;
        padding: 4px;

        &:hover {
            color: $ep-text-primary;
        }
    }

    &__title {
        font-size: 20px;
        font-weight: 700;
        color: $ep-text-primary;
        margin: 0 0 12px;
    }

    &__text {
        font-size: 14px;
        color: $ep-text-secondary;
        line-height: 1.6;
        margin: 0;
    }

    &--finish {
        text-align: center;
        max-width: 420px;
    }
}

.ep-ob-finish-illustration {
    margin-bottom: 16px;

    img {
        max-width: 230px;
        height: auto;
    }
}

// ---------- Rocket launch animation ----------
.ep-ob-finish--launching {
    .ep-ob-rocket-orbit {
        animation: ep-orbit-spin 4s linear infinite;
        transform-origin: 90px 90px;
    }

    .ep-ob-rocket-body {
        animation: ep-rocket-launch 1.5s ease-in forwards;
    }

    .ep-ob-rocket-flame {
        animation: ep-flame-flicker 0.15s ease-in-out infinite alternate;
        transform-origin: 90px 106px;
    }

    .ep-ob-sparkle {
        // static, no animation
    }
}

@keyframes ep-rocket-launch {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    60% {
        transform: translateY(-10px);
        opacity: 1;
    }
    100% {
        transform: translateY(-120px);
        opacity: 0;
    }
}

@keyframes ep-flame-flicker {
    0% {
        transform: scaleX(0.85) scaleY(0.9);
    }
    100% {
        transform: scaleX(1.15) scaleY(1.1);
    }
}

@keyframes ep-orbit-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes ep-sparkle-pulse {
    0% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1.2);
    }
}

// ---------- Green checkmark animation ----------
.ep-ob-finish--done {
    .ep-ob-checkmark-svg {
        animation: ep-check-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    .ep-ob-check-circle-inner {
        animation: ep-circle-grow 0.35s ease-out forwards;
    }

    .ep-ob-check-path {
        stroke-dasharray: 80;
        stroke-dashoffset: 80;
        animation: ep-check-draw 0.5s 0.25s ease-out forwards;
    }
}

@keyframes ep-check-pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ep-circle-grow {
    0% {
        r: 0;
    }
    100% {
        r: 50;
    }
}

@keyframes ep-check-draw {
    to {
        stroke-dashoffset: 0;
    }
}

// ---------- Re-run wizard link ----------
.embedpress-rerun-wizard-link {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    color: $ep-brand;
    text-decoration: none;

    &:hover {
        text-decoration: underline;
    }
}

// ---------- Responsive ----------
@media (max-width: 560px) {
    .ep-ob__body {
        margin: 12px;
    }

    .ep-ob__body-inner {
        padding: 24px 20px;
    }

    .ep-ob-stepper {
        width: 100%;
        justify-content: center;
    }

    .ep-ob-stepper__tab {
        padding: 6px 12px;
    }

    .ep-ob-features-checklist__row {
        grid-template-columns: 1fr;
    }
}
