/* ==========================================================================
   YayReviews Survey — Frontend styles

   shadcn/ui design language (card shell, muted borders, ring focus, sm text)
   expressed through a local token layer. Every color token first defers to the
   active theme's palette (Brandy exposes `--wp--preset--color--brandy-*`) and
   only falls back to the shadcn default when the theme doesn't provide one —
   same approach as store-review-form.css.

   Selectors are scoped under `.yayrev-survey` so storefront themes that style
   bare inputs/buttons (Brandy, Storefront, Divi) lose the specificity fight.
   ========================================================================== */

.yayrev-survey {
    /* Surface */
    --yayrev-card: var(--yayrev-tone-surface, var(--wp--preset--color--white, #ffffff));
    --yayrev-foreground: var(--yayrev-tone-text, var(--wp--preset--color--brandy-foreground, #171719));
    --yayrev-muted: var(--yayrev-tone-surface-muted, var(--wp--preset--color--brandy-gray-3, #f4f4f5));
    --yayrev-muted-foreground: var(--yayrev-tone-text-muted, var(--wp--preset--color--brandy-muted-foreground, #7b7c80));
    --yayrev-accent: var(--yayrev-tone-surface-muted, var(--wp--preset--color--brandy-gray-2, #f4f4f5));
    --yayrev-border: var(--yayrev-tone-border, var(--wp--preset--color--brandy-gray-4, #e4e4e7));

    /* Action */
    --yayrev-primary: var(--yayrev-tone-primary, var(--wp--preset--color--brandy-primary, #171719));
    --yayrev-primary-foreground: var(--yayrev-tone-primary-text, var(--wp--preset--color--white, #ffffff));
    --yayrev-ring: var(--yayrev-primary);

    /* Semantic — intentionally not themed: these carry meaning, not brand. */
    --yayrev-destructive: #d50719;
    --yayrev-destructive-soft: #fee2e2;
    --yayrev-destructive-strong: #991b1b;
    --yayrev-success: #16a34a;
    --yayrev-success-soft: #dcfce7;
    --yayrev-star: var(--yayrev-tone-accent, #facc15);

    /* Geometry — mirrors shadcn's --radius scale. */
    --yayrev-radius: 0.625rem;
    --yayrev-radius-sm: calc(var(--yayrev-radius) - 4px);
    --yayrev-radius-md: calc(var(--yayrev-radius) - 2px);
    --yayrev-radius-lg: var(--yayrev-radius);
    --yayrev-radius-xl: calc(var(--yayrev-radius) + 6px);

    box-sizing: border-box;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-xl);
    background: var(--yayrev-card);
    color: var(--yayrev-foreground);
    font-size: 14px;
    line-height: 1.5;
}

.yayrev-survey *,
.yayrev-survey *::before,
.yayrev-survey *::after {
    box-sizing: inherit;
}

.yayrev-survey__loading,
.yayrev-survey__error {
    padding: 24px 0;
    text-align: center;
    color: var(--yayrev-muted-foreground);
}

/* ==========================================================================
   Header
   ========================================================================== */

.yayrev-survey__header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--yayrev-border);
}

.yayrev-survey .yayrev-survey-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: var(--yayrev-foreground);
}

/* ==========================================================================
   Progress (step mode)
   ========================================================================== */

.yayrev-survey-progress {
    margin-bottom: 20px;
}

.yayrev-survey-progress__bar {
    height: 6px;
    border-radius: 9999px;
    background: var(--yayrev-muted);
    overflow: hidden;
}

.yayrev-survey-progress__fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--yayrev-primary);
    transition: width 0.25s ease;
}

.yayrev-survey-progress__text {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--yayrev-muted-foreground);
}

/* ==========================================================================
   Guest fields
   ========================================================================== */

.yayrev-survey-guest-fields {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--yayrev-border);
}

@media (min-width: 560px) {
    .yayrev-survey-guest-fields {
        grid-template-columns: 1fr 1fr;
    }
}

.yayrev-survey-guest-fields .yayrev-survey-field {
    margin-bottom: 0;
}

/* Step mode's guest screen is guest fields + actions only — its own bottom rule
   already separates them, so the actions bar drops its top rule. */
.yayrev-survey-guest-fields + .yayrev-survey-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* ==========================================================================
   Fields / questions
   ========================================================================== */

.yayrev-survey-question-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.yayrev-survey-field {
    margin-bottom: 24px;
}

.yayrev-survey-question-list .yayrev-survey-field,
.yayrev-survey-question-mount .yayrev-survey-field {
    margin-bottom: 0;
}

.yayrev-survey .yayrev-survey-label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--yayrev-foreground);
}

.yayrev-survey .yayrev-survey-label .required {
    margin-left: 2px;
    color: var(--yayrev-destructive);
}

.yayrev-survey .yayrev-survey-input,
.yayrev-survey .yayrev-survey-textarea {
    display: block;
    width: 100%;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    background: transparent;
    color: var(--yayrev-foreground);
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, outline-color 0.15s ease;
}

.yayrev-survey .yayrev-survey-input::placeholder,
.yayrev-survey .yayrev-survey-textarea::placeholder {
    color: var(--yayrev-muted-foreground);
}

.yayrev-survey .yayrev-survey-input:focus,
.yayrev-survey .yayrev-survey-textarea:focus {
    border-color: var(--yayrev-ring);
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 1px;
}

.yayrev-survey .yayrev-survey-textarea {
    min-height: 72px;
    resize: vertical;
}

.yayrev-survey-error {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--yayrev-destructive);
}

/* ==========================================================================
   Star rating
   ========================================================================== */

.yayrev-survey-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.yayrev-survey .yayrev-survey-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: none;
    border-radius: var(--yayrev-radius-sm);
    background: none;
    color: var(--yayrev-muted-foreground);
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
}

.yayrev-survey .yayrev-survey-star:hover {
    background: none;
    transform: scale(1.08);
}

.yayrev-survey-star__icon {
    display: block;
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linejoin: round;
}

.yayrev-survey .yayrev-survey-star.is-active {
    color: var(--yayrev-star);
}

.yayrev-survey .yayrev-survey-star.is-active .yayrev-survey-star__icon {
    fill: currentColor;
}

.yayrev-survey .yayrev-survey-star:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

/* ==========================================================================
   Emoji
   ========================================================================== */

.yayrev-survey-emoji-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.yayrev-survey .yayrev-survey-emoji {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 68px;
    padding: 10px 12px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    background: transparent;
    color: var(--yayrev-foreground);
    font-size: 22px;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.yayrev-survey .yayrev-survey-emoji:hover {
    border-color: var(--yayrev-border);
    background: var(--yayrev-accent);
}

.yayrev-survey .yayrev-survey-emoji__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--yayrev-muted-foreground);
}

.yayrev-survey .yayrev-survey-emoji.is-selected {
    border-color: var(--yayrev-primary);
    background: var(--yayrev-accent);
}

.yayrev-survey .yayrev-survey-emoji.is-selected .yayrev-survey-emoji__label {
    color: var(--yayrev-foreground);
    font-weight: 600;
}

.yayrev-survey .yayrev-survey-emoji:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

/* ==========================================================================
   NPS — band colors are semantic (detractor → promoter), not brand colors.
   ========================================================================== */

.yayrev-survey-nps {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    padding: 4px 0;
}

/* Connecting track behind the nodes — samples the same red -> orange ->
   yellow -> green progression used to color each node by position. */
.yayrev-survey-nps::before {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    top: 50%;
    z-index: 0;
    height: 3px;
    transform: translateY(-50%);
    border-radius: 9999px;
    background: linear-gradient(to right,
        #ef4444 0%, #ef4444 15%,
        #f97316 30%, #f97316 40%,
        #eab308 50%, #eab308 60%,
        #22c55e 70%, #22c55e 100%);
}

.yayrev-survey .yayrev-survey-nps-btn {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid var(--nps-color, var(--yayrev-border));
    border-radius: 50%;
    background: var(--yayrev-card);
    color: transparent;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.yayrev-survey .yayrev-survey-nps-btn:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

/* Band color by position (1-10, fixed render order) along the scale. */
.yayrev-survey-nps-btn:nth-child(1),
.yayrev-survey-nps-btn:nth-child(2) {
    --nps-color: #ef4444;
}

.yayrev-survey-nps-btn:nth-child(3),
.yayrev-survey-nps-btn:nth-child(4) {
    --nps-color: #f97316;
}

.yayrev-survey-nps-btn:nth-child(5),
.yayrev-survey-nps-btn:nth-child(6) {
    --nps-color: #eab308;
}

.yayrev-survey-nps-btn:nth-child(7),
.yayrev-survey-nps-btn:nth-child(8),
.yayrev-survey-nps-btn:nth-child(9),
.yayrev-survey-nps-btn:nth-child(10) {
    --nps-color: #22c55e;
}

/* Selected node: solid fill in its own band color + bold white number. */
.yayrev-survey .yayrev-survey-nps-btn.is-selected {
    border-color: var(--nps-color, var(--yayrev-primary));
    background: var(--nps-color, var(--yayrev-primary));
    color: #fff;
}

.yayrev-survey-nps-scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--yayrev-muted-foreground);
}

/* ==========================================================================
   Thumbs / Yes-No
   ========================================================================== */

.yayrev-survey-choice-row {
    display: flex;
    gap: 8px;
}

.yayrev-survey .yayrev-survey-choice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 88px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    background: transparent;
    color: var(--yayrev-foreground);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.yayrev-survey .yayrev-survey-choice-btn:hover {
    border-color: var(--yayrev-border);
    background: var(--yayrev-accent);
    color: var(--yayrev-foreground);
}

.yayrev-survey .yayrev-survey-choice-btn.is-selected {
    border-color: var(--yayrev-primary);
    background: var(--yayrev-primary);
    color: var(--yayrev-primary-foreground);
}

.yayrev-survey .yayrev-survey-choice-btn:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

/* Thumbs buttons are icon-only (no text label) — square up the button. */
.yayrev-survey .yayrev-survey-choice-btn--icon-only {
    gap: 0;
    min-width: 0;
    width: 36px;
    padding: 0;
}

.yayrev-survey .yayrev-survey-choice-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ==========================================================================
   Single / multiple choice — native inputs kept for state, repainted as
   shadcn radio/checkbox indicators so themes can't restyle them.
   ========================================================================== */

.yayrev-survey-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.yayrev-survey .yayrev-survey-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    font-size: 14px;
    line-height: 1.4;
    color: var(--yayrev-foreground);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.yayrev-survey .yayrev-survey-option:hover {
    background: var(--yayrev-accent);
}

.yayrev-survey .yayrev-survey-option.is-selected {
    border-color: var(--yayrev-primary);
    background: var(--yayrev-accent);
}

.yayrev-survey .yayrev-survey-option input[type="radio"],
.yayrev-survey .yayrev-survey-option input[type="checkbox"] {
    position: relative;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    border: 1px solid var(--yayrev-border);
    background: var(--yayrev-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.yayrev-survey .yayrev-survey-option input[type="radio"] {
    border-radius: 50%;
}

.yayrev-survey .yayrev-survey-option input[type="checkbox"] {
    border-radius: 4px;
}

.yayrev-survey .yayrev-survey-option input:checked {
    border-color: var(--yayrev-primary);
    background: var(--yayrev-primary);
}

.yayrev-survey .yayrev-survey-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--yayrev-primary-foreground);
}

.yayrev-survey .yayrev-survey-option input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 45%;
    left: 50%;
    width: 4px;
    height: 8px;
    transform: translate(-50%, -50%) rotate(45deg);
    border: solid var(--yayrev-primary-foreground);
    border-width: 0 2px 2px 0;
    background: none;
}

.yayrev-survey .yayrev-survey-option input:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

/* ==========================================================================
   Media upload (photos + videos)
   ========================================================================== */

.yayrev-survey-upload {
    margin-top: 12px;
}

.yayrev-survey-upload__dropzone {
    padding: 16px;
    border: 1px dashed var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    background: var(--yayrev-muted);
    text-align: center;
    font-size: 13px;
    color: var(--yayrev-muted-foreground);
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.yayrev-survey-upload__dropzone:hover,
.yayrev-survey-upload__dropzone.dragging {
    border-color: var(--yayrev-primary);
    background: var(--yayrev-accent);
}

.yayrev-survey-upload__input {
    display: none;
}

.yayrev-survey-upload__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.yayrev-survey-upload__grid:empty {
    margin-top: 0;
}

.yayrev-survey-upload__item {
    position: relative;
    width: 88px;
    height: 88px;
}

.yayrev-survey-upload__thumb {
    display: block;
    width: 88px;
    height: 88px;
    border: 1px solid var(--yayrev-border);
    border-radius: var(--yayrev-radius-md);
    background: var(--yayrev-muted);
    object-fit: cover;
}

.yayrev-survey-upload__video-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.yayrev-survey .yayrev-survey-upload__remove {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--yayrev-destructive);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

/* ==========================================================================
   Actions / navigation
   ========================================================================== */

.yayrev-survey-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--yayrev-border);
}

.yayrev-survey .yayrev-survey-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--yayrev-radius-md);
    background: var(--yayrev-primary);
    color: var(--yayrev-primary-foreground);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.yayrev-survey .yayrev-survey-btn:hover {
    background: var(--yayrev-primary);
    color: var(--yayrev-primary-foreground);
    opacity: 0.9;
}

.yayrev-survey .yayrev-survey-btn:focus-visible {
    outline: 2px solid var(--yayrev-ring);
    outline-offset: 2px;
}

.yayrev-survey .yayrev-survey-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.yayrev-survey .yayrev-survey-btn--secondary {
    border-color: var(--yayrev-border);
    background: transparent;
    color: var(--yayrev-foreground);
}

.yayrev-survey .yayrev-survey-btn--secondary:hover {
    background: var(--yayrev-accent);
    color: var(--yayrev-foreground);
    opacity: 1;
}

.yayrev-survey .yayrev-survey-btn--retry {
    background: var(--yayrev-destructive);
    color: #fff;
}

.yayrev-survey .yayrev-survey-btn--retry:hover {
    background: var(--yayrev-destructive);
    color: #fff;
}

/* ==========================================================================
   States: success / already-responded / submit-error / login-required
   ========================================================================== */

.yayrev-survey-state {
    padding: 32px 8px;
    text-align: center;
}

.yayrev-survey-state__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--yayrev-success-soft);
    color: var(--yayrev-success);
}

.yayrev-survey-state__icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.yayrev-survey-state--error .yayrev-survey-state__icon {
    background: var(--yayrev-destructive-soft);
    color: var(--yayrev-destructive);
}

.yayrev-survey-state__content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--yayrev-muted-foreground);
}

.yayrev-survey-state .yayrev-survey-actions {
    justify-content: center;
    border-top: none;
}

.yayrev-survey-submit-error {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--yayrev-destructive-soft);
    border-radius: var(--yayrev-radius-md);
    background: var(--yayrev-destructive-soft);
    font-size: 13px;
    color: var(--yayrev-destructive-strong);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 480px) {
    .yayrev-survey {
        padding: 20px 16px;
    }

    .yayrev-survey .yayrev-survey-emoji {
        min-width: 60px;
        padding: 8px 10px;
        font-size: 20px;
    }

    .yayrev-survey-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .yayrev-survey .yayrev-survey-btn {
        width: 100%;
    }
}
