/* WPC Smart Quiz - Frontend Styles */

/* === Theme Variables (defaults) === */
:root {
    --wpcsq-primary: #6366f1;
    --wpcsq-primary-dark: #8b5cf6;
    --wpcsq-primary-bg: #eef2ff;
    --wpcsq-primary-border: #a5b4fc;
    --wpcsq-primary-light: #f5f3ff
}

/* === Quiz Wrapper === */
.wpcsq-quiz-wrapper {
    position: relative;
    max-width: 720px;
    min-height: 200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --wpcsq-primary: #6366f1;
    --wpcsq-primary-dark: #8b5cf6;
    --wpcsq-primary-bg: #eef2ff;
    --wpcsq-primary-border: #a5b4fc;
    --wpcsq-primary-light: #f5f3ff
}

/* === Progress Bar === */
.wpcsq-progress {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin-bottom: 32px;
    position: relative
}

.wpcsq-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--wpcsq-primary), var(--wpcsq-primary-dark));
    border-radius: 3px;
    transition: width .4s cubic-bezier(.4, 0, .2, 1)
}

.wpcsq-progress-text {
    position: absolute;
    right: 0;
    top: -22px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 600
}

/* === Step === */
.wpcsq-step {
    animation: wpcsqFadeIn .35s ease;
    will-change: transform, opacity
}

/* Slide transition — direction-aware */
[data-transition="slide"][data-direction="next"] .wpcsq-step[data-visible="true"],
[data-transition="slide"]:not([data-direction]) .wpcsq-step[data-visible="true"] {
    animation: wpcsqSlideInRight .35s ease
}

[data-transition="slide"][data-direction="prev"] .wpcsq-step[data-visible="true"] {
    animation: wpcsqSlideInLeft .35s ease
}

/* Fade transition */
[data-transition="fade"] .wpcsq-step[data-visible="true"] {
    animation: wpcsqFadeOnly .35s ease
}

/* No transition */
[data-transition="none"] .wpcsq-step {
    animation: none
}

.wpcsq-step[data-visible="false"] {
    display: none
}

.wpcsq-step-question {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.3
}

/* === Answer Options === */
.wpcsq-answers {
    display: grid;
    gap: 12px
}

.wpcsq-answers--single,
.wpcsq-answers--multi {
    grid-template-columns: 1fr
}

.wpcsq-answers--image {
    grid-template-columns: repeat(2, 1fr)
}

.wpcsq-answer {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s ease;
    background: #fff
}

.wpcsq-answer:hover {
    border-color: var(--wpcsq-primary-border);
    background: var(--wpcsq-primary-light)
}

.wpcsq-answer.selected {
    border-color: var(--wpcsq-primary);
    background: var(--wpcsq-primary-bg);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wpcsq-primary) 15%, transparent)
}

.wpcsq-answer input {
    display: none
}

.wpcsq-answer-check {
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s
}

.wpcsq-answers--multi .wpcsq-answer-check,
input[type="checkbox"]+.wpcsq-answer-check {
    border-radius: 4px
}

.wpcsq-answer.selected .wpcsq-answer-check {
    background: var(--wpcsq-primary);
    border-color: var(--wpcsq-primary)
}

.wpcsq-answer.selected .wpcsq-answer-check::after {
    content: "✓";
    color: #fff;
    font-size: 13px;
    font-weight: 700
}

.wpcsq-answer-label {
    font-size: 15px;
    color: #374151;
    font-weight: 500
}

/* Image choice */
.wpcsq-answer--image {
    flex-direction: column;
    text-align: center;
    padding: 16px;
    gap: 10px
}

.wpcsq-answer--image .wpcsq-answer-check {
    position: absolute;
    top: 10px;
    right: 10px
}

.wpcsq-answer-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background: #f3f4f6
}

.wpcsq-answer--image .wpcsq-answer-label {
    font-size: 14px
}

/* Slider */
.wpcsq-slider-wrap {
    padding: 20px 0
}

.wpcsq-slider-wrap input[type="range"] {
    width: 100%;
    accent-color: var(--wpcsq-primary)
}

.wpcsq-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6b7280;
    margin-top: 8px
}

.wpcsq-slider-value {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--wpcsq-primary);
    margin-bottom: 12px
}

/* === Navigation === */
.wpcsq-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    gap: 12px
}

.wpcsq-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s
}

.wpcsq-btn-primary {
    background: linear-gradient(135deg, var(--wpcsq-primary), var(--wpcsq-primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--wpcsq-primary) 30%, transparent)
}

.wpcsq-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--wpcsq-primary) 40%, transparent)
}

.wpcsq-btn-outline {
    background: transparent;
    border: 2px solid #d1d5db;
    color: #374151
}

.wpcsq-btn-outline:hover {
    border-color: var(--wpcsq-primary);
    color: var(--wpcsq-primary)
}

.wpcsq-btn-text {
    background: transparent;
    color: #6b7280;
    border: none;
    text-decoration: underline
}

.wpcsq-btn-prev {
    background: #f3f4f6;
    color: #374151
}

.wpcsq-btn-next,
.wpcsq-btn-submit {
    margin-left: auto
}

/* === Loading === */
.wpcsq-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px
}

.wpcsq-loading .wpcsq-spinner {
    width: 40px !important;
    height: 40px !important;
    border: 3px solid #e5e7eb !important;
    border-top-color: var(--wpcsq-primary) !important;
    border-radius: 50% !important;
    animation: wpcsqSpin .8s linear infinite;
    box-sizing: border-box
}

.wpcsq-loading p {
    margin-top: 16px;
    color: #6b7280;
    font-weight: 500
}

/* === Results === */
.wpcsq-results-header {
    text-align: center;
    margin-bottom: 32px
}

.wpcsq-results-icon {
    font-size: 48px;
    margin-bottom: 12px
}

.wpcsq-results-heading {
    font-size: 26px;
    font-weight: 800;
    color: #1f2937;
    margin: 0 0 8px
}

.wpcsq-results-desc {
    color: #6b7280;
    font-size: 15px;
    margin: 0
}

/* Sort dropdown */
.wpcsq-results-sort {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 20px
}

.wpcsq-results-sort label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap
}

.wpcsq-results-sort .wpcsq-sort-select {
    padding: 7px 32px 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    background: #fff;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color .2s
}

.wpcsq-results-sort .wpcsq-sort-select:hover {
    border-color: var(--wpcsq-primary-border)
}

.wpcsq-results-sort .wpcsq-sort-select:focus {
    border-color: var(--wpcsq-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wpcsq-primary) 10%, transparent)
}

.wpcsq-results-products {
    display: grid;
    gap: 20px
}

.wpcsq-layout-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))
}

.wpcsq-layout-list {
    grid-template-columns: 1fr
}

/* Product Card */
.wpcsq-product-card {
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all .2s ease
}

.wpcsq-product-card:hover {
    border-color: var(--wpcsq-primary-border);
    background: var(--wpcsq-primary-light)
}

.wpcsq-product-image {
    position: relative;
    overflow: hidden
}

.wpcsq-product-image img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 !important;
    transition: transform .3s
}

.wpcsq-product-card:hover .wpcsq-product-image img {
    transform: scale(1.05)
}

.wpcsq-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase
}

.wpcsq-badge-sale {
    background: #ef4444;
    color: #fff
}

.wpcsq-product-info {
    padding: 16px
}

.wpcsq-product-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600
}

.wpcsq-product-title a {
    color: #1f2937;
    text-decoration: none
}

.wpcsq-product-title a:hover {
    color: var(--wpcsq-primary)
}

.wpcsq-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--wpcsq-primary);
    margin-bottom: 8px
}

.wpcsq-product-price del {
    color: #9ca3af;
    font-weight: 400;
    font-size: 14px
}

.wpcsq-product-price ins {
    text-decoration: none
}

.wpcsq-product-rating {
    margin-bottom: 10px
}

.wpcsq-product-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px
}

/* Grid layout */
.wpcsq-layout-grid .wpcsq-product-info {
    text-align: center
}

.wpcsq-layout-grid .wpcsq-product-rating {
    display: flex;
    justify-content: center
}

.wpcsq-layout-grid .wpcsq-product-actions {
    justify-content: center
}

/* List layout */
.wpcsq-layout-list .wpcsq-product-card {
    display: flex;
    flex-direction: row
}

.wpcsq-layout-list .wpcsq-product-image {
    width: 160px;
    flex-shrink: 0
}

.wpcsq-layout-list .wpcsq-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center
}

/* Results Actions */
.wpcsq-results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb
}

/* === No Results === */
.wpcsq-no-results {
    text-align: center;
    padding: 48px 24px
}

.wpcsq-no-results-icon {
    font-size: 56px;
    margin-bottom: 16px
}

.wpcsq-no-results h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px
}

.wpcsq-no-results p {
    color: #6b7280;
    margin-bottom: 24px
}

/* === Coupon Incentive (in nav) === */
.wpcsq-coupon-incentive {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 8px 14px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center
}

/* === Coupon Reward (in results) === */
.wpcsq-coupon-reward {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 2px solid #fbbf24;
    border-radius: 12px;
    margin-bottom: 24px
}

.wpcsq-coupon-reward-icon {
    font-size: 32px;
    flex-shrink: 0
}

.wpcsq-coupon-reward-info {
    flex: 1
}

.wpcsq-coupon-reward-info strong {
    display: block;
    font-size: 15px;
    color: #92400e
}

.wpcsq-coupon-reward-hint {
    font-size: 12px;
    color: #b45309
}

.wpcsq-coupon-code {
    font-size: 18px;
    font-weight: 800;
    color: #d97706;
    background: #fff;
    border: 2px dashed #fbbf24;
    border-radius: 8px;
    padding: 8px 16px;
    letter-spacing: 2px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: all
}

/* === Share Results === */
.wpcsq-share-result {
    margin-top: 20px;
    padding: 20px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    animation: wpcsqFadeIn .3s ease
}

.wpcsq-share-result-inner label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #166534;
    margin-bottom: 8px
}

.wpcsq-share-input-wrap {
    display: flex;
    gap: 8px
}

.wpcsq-share-url {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #86efac;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    background: #fff;
    outline: none;
    transition: border-color .2s
}

.wpcsq-share-url:focus {
    border-color: #22c55e
}

.wpcsq-share-copy {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 13px
}

.wpcsq-share-empty {
    text-align: center;
    padding: 48px 24px;
    color: #6b7280
}

.wpcsq-share-empty p {
    font-size: 15px
}

.wpcsq-share-btn {
    position: relative
}

/* === Welcome Screen === */
.wpcsq-welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 48px 24px
}

.wpcsq-welcome-content {
    text-align: center;
    max-width: 480px
}

.wpcsq-welcome-icon {
    color: var(--wpcsq-primary);
    margin-bottom: 20px
}

.wpcsq-welcome-heading {
    font-size: 26px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 12px
}

.wpcsq-welcome-desc {
    color: #6b7280;
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 28px
}

.wpcsq-welcome-start {
    font-size: 16px;
    padding: 12px 36px;
    border-radius: 10px
}

/* === Email Gate === */
.wpcsq-email-gate {
    text-align: center;
    padding: 48px 24px;
    max-width: 420px;
    margin: 0 auto
}

.wpcsq-email-gate-icon {
    color: var(--wpcsq-primary);
    margin-bottom: 16px
}

.wpcsq-email-gate-title {
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px
}

.wpcsq-email-gate-desc {
    color: #6b7280;
    font-size: 15px;
    margin: 0 0 24px;
    line-height: 1.5
}

.wpcsq-email-gate-form {
    display: flex;
    gap: 8px;
    max-width: 360px;
    margin: 0 auto
}

input.wpcsq-email-gate-input {
    flex: 1;
    padding: 3px 20px;
    border: 2px solid #d1d5db;
    border-radius: 10px !important;
    font-size: 14px;
    outline: none;
    text-align: center;
    transition: border-color .2s
}

input.wpcsq-email-gate-input:focus {
    border-color: var(--wpcsq-primary)
}

input.wpcsq-email-gate-input.wpcsq-input-error {
    border-color: #ef4444;
    animation: wpcsq-shake .4s
}

.wpcsq-email-gate-submit {
    justify-content: center
}

.wpcsq-email-gate-skip {
    display: block;
    margin: 16px auto 0;
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline
}

.wpcsq-email-gate-skip:hover {
    color: #6b7280
}

@keyframes wpcsq-shake {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-6px)
    }

    75% {
        transform: translateX(6px)
    }
}

/* === Floating Button === */
.wpcsq-floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--wpcsq-primary), var(--wpcsq-primary-dark));
    color: #fff;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px color-mix(in srgb, var(--wpcsq-primary) 40%, transparent);
    transition: all .3s
}

.wpcsq-floating-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px color-mix(in srgb, var(--wpcsq-primary) 50%, transparent)
}

/* === Modal === */
.wpcsq-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px)
}

.wpcsq-modal {
    background: #fff;
    border-radius: 16px;
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: wpcsqSlideUp .3s ease;
    display: flex;
    flex-direction: column
}

.wpcsq-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 30px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0
}

.wpcsq-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1f2937
}

.wpcsq-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s
}

.wpcsq-modal-close:hover {
    background: #e5e7eb
}

.wpcsq-modal-body {
    padding: 50px 30px 30px 30px;
    overflow-y: auto;
    flex: 1
}

/* === Animations === */
@keyframes wpcsqFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

@keyframes wpcsqSpin {
    to {
        transform: rotate(360deg)
    }
}

@keyframes wpcsqSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes wpcsqSlideInRight {
    from {
        opacity: 0;
        transform: translateX(40px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

@keyframes wpcsqSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

@keyframes wpcsqFadeOnly {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

/* Answer selection micro-animation */
.wpcsq-answer.selected {
    animation: wpcsqPulse .25s ease
}

@keyframes wpcsqPulse {
    0% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.02)
    }

    100% {
        transform: scale(1)
    }
}

/* === Responsive === */
@media (max-width: 640px) {
    .wpcsq-step-question {
        font-size: 18px
    }

    .wpcsq-answers--image {
        grid-template-columns: repeat(2, 1fr)
    }

    .wpcsq-answer {
        padding: 12px 16px
    }

    .wpcsq-layout-grid {
        grid-template-columns: 1fr
    }

    .wpcsq-layout-grid .wpcsq-product-info,
    .wpcsq-layout-list .wpcsq-product-info {
        text-align: center
    }

    .wpcsq-layout-grid .wpcsq-product-rating,
    .wpcsq-layout-list .wpcsq-product-rating {
        display: flex;
        justify-content: center
    }

    .wpcsq-layout-grid .wpcsq-product-actions,
    .wpcsq-layout-list .wpcsq-product-actions {
        justify-content: center
    }

    .wpcsq-layout-list .wpcsq-product-card {
        flex-direction: column
    }

    .wpcsq-layout-list .wpcsq-product-image {
        width: 100%
    }

    .wpcsq-modal-body {
        padding: 40px 20px 20px 20px
    }

    .wpcsq-results-heading {
        font-size: 20px
    }

    .wpcsq-nav {
        flex-wrap: wrap
    }

    .wpcsq-btn-prev {
        flex: 1
    }

    .wpcsq-btn-next,
    .wpcsq-btn-submit {
        flex: 1;
        margin-left: 0;
        justify-content: flex-end
    }

    .wpcsq-coupon-incentive {
        order: 3;
        width: 100%;
        flex: 0 0 100%;
    }

    .wpcsq-coupon-reward {
        flex-direction: column;
        align-items: center;
        text-align: center
    }

    .wpcsq-coupon-reward-info {
        text-align: center
    }

    .wpcsq-results-sort {
        justify-content: center
    }

    .wpcsq-email-form {
        flex-direction: column
    }

    .wpcsq-email-gate-form {
        flex-direction: column
    }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {

    .wpcsq-step,
    .wpcsq-modal,
    .wpcsq-product-card,
    .wpcsq-floating-btn,
    .wpcsq-progress-bar {
        animation: none !important;
        transition: none !important
    }
}