/*
 * Receiteria Surveys — Frontend Styles
 * Inherits design tokens from the Receiteria theme.
 */

/* ------------------------------------------------------------------ */
/* Tokens                                                               */
/* ------------------------------------------------------------------ */
:root {
    --rcs-font:           'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --rcs-primary:        var(--cor-primaria,        #6C5CE7);
    --rcs-primary-hover:  var(--cor-primaria-hover,  #5A4BD1);
    --rcs-text:           var(--cor-texto-principal,  #2D2A45);
    --rcs-text-muted:     var(--cor-texto-claro,      #6B6880);
    --rcs-bg:             var(--cor-fundo-bege-claro, #FFFFFF);
    --rcs-border:         var(--cor-cinza,            #E6E3F5);
    --rcs-radius:         16px;
    --rcs-radius-sm:      8px;
    --rcs-shadow:         0 24px 64px rgba(83, 36, 12, 0.22);
    --rcs-overlay:        rgba(83, 36, 12, 0.55);
    --rcs-transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ------------------------------------------------------------------ */
/* Popup overlay                                                        */
/* ------------------------------------------------------------------ */
.rcs-popup {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: var(--rcs-font);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--rcs-transition);
}

.rcs-popup.rcs-popup--open {
    opacity: 1;
    pointer-events: all;
}

.rcs-popup__overlay {
    position: absolute;
    inset: 0;
    background: var(--rcs-overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Dialog                                                               */
/* ------------------------------------------------------------------ */
.rcs-popup__dialog {
    position: relative;
    z-index: 1;
    background: var(--rcs-bg);
    border-radius: var(--rcs-radius);
    box-shadow: var(--rcs-shadow);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(20px) scale(0.97);
    transition: transform var(--rcs-transition);
    overscroll-behavior: contain;
}

.rcs-popup--open .rcs-popup__dialog {
    transform: translateY(0) scale(1);
}

/* ------------------------------------------------------------------ */
/* Close button                                                         */
/* ------------------------------------------------------------------ */
.rcs-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(83, 36, 12, 0.08);
    border: none;
    border-radius: 50%;
    color: var(--rcs-text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--rcs-transition), color var(--rcs-transition);
    padding: 0;
}

.rcs-close:hover {
    background: var(--rcs-primary);
    color: #fff;
}

/* ------------------------------------------------------------------ */
/* Form                                                                 */
/* ------------------------------------------------------------------ */
.rcs-form {
    background: var(--rcs-bg);
    /* padding-top: 52px reserva linha pro botao .rcs-close (32px @ top:12 = ate y:44).
       Funciona pra qualquer primeiro elemento (titulo, descricao, progress, pergunta) */
    padding: 52px 24px 24px;
    font-family: var(--rcs-font);
}

.rcs-form__title {
    font-family: var(--rcs-font);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--rcs-text);
    margin: 0 0 4px;
}

.rcs-form__desc {
    font-size: 14px;
    color: var(--rcs-text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Progress bar                                                         */
/* ------------------------------------------------------------------ */
.rcs-progress {
    width: 100%;
    height: 4px;
    background: var(--rcs-border);
    border-radius: 2px;
    margin-bottom: 20px;
    overflow: hidden;
}

.rcs-progress__bar {
    height: 100%;
    background: var(--rcs-primary);
    border-radius: 2px;
    width: 0%;
    transition: width var(--rcs-transition);
}

/* ------------------------------------------------------------------ */
/* Question                                                             */
/* ------------------------------------------------------------------ */
.rcs-question {
    margin-bottom: 20px;
}

.rcs-question__text {
    font-size: 16px;
    font-weight: 600;
    color: var(--rcs-text);
    margin: 0 0 12px;
    line-height: 1.4;
}

.rcs-question__required {
    color: var(--rcs-primary);
    margin-left: 2px;
}

/* ------------------------------------------------------------------ */
/* Options (single / multiple choice cards)                             */
/* ------------------------------------------------------------------ */
.rcs-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rcs-option {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--rcs-border);
    border-radius: var(--rcs-radius-sm);
    padding: 12px 16px;
    cursor: pointer;
    background: transparent;
    transition: border-color var(--rcs-transition), background var(--rcs-transition);
    font-family: var(--rcs-font);
    font-size: 14px;
    color: var(--rcs-text);
    width: 100%;
    text-align: left;
}

.rcs-option:hover {
    border-color: var(--rcs-primary);
    background: rgba(245, 62, 40, 0.04);
}

.rcs-option.rcs-option--selected {
    border-color: var(--rcs-primary);
    background: rgba(245, 62, 40, 0.08);
}

.rcs-option__indicator {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--rcs-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--rcs-transition), background var(--rcs-transition);
}

.rcs-option--multiple .rcs-option__indicator {
    border-radius: 4px;
}

.rcs-option--selected .rcs-option__indicator {
    border-color: var(--rcs-primary);
    background: var(--rcs-primary);
}

.rcs-option__indicator::after {
    content: '';
    display: none;
}

.rcs-option--selected .rcs-option__indicator::after {
    display: block;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.rcs-option__label {
    flex: 1;
    line-height: 1.4;
}

/* ------------------------------------------------------------------ */
/* Scale (1–5)                                                          */
/* ------------------------------------------------------------------ */
.rcs-scale {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.rcs-scale__item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--rcs-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--rcs-font);
    font-size: 16px;
    font-weight: 600;
    color: var(--rcs-text);
    background: transparent;
    transition: border-color var(--rcs-transition), background var(--rcs-transition), color var(--rcs-transition);
    padding: 0;
}

.rcs-scale__item:hover {
    border-color: var(--rcs-primary);
    background: rgba(245, 62, 40, 0.06);
}

.rcs-scale__item.rcs-scale__item--selected {
    border-color: var(--rcs-primary);
    background: var(--rcs-primary);
    color: #fff;
}

/* ------------------------------------------------------------------ */
/* Yes / No                                                             */
/* ------------------------------------------------------------------ */
.rcs-yesno {
    display: flex;
    gap: 12px;
}

.rcs-yesno__btn {
    flex: 1;
    padding: 16px;
    border: 2px solid var(--rcs-border);
    border-radius: var(--rcs-radius-sm);
    background: transparent;
    cursor: pointer;
    font-family: var(--rcs-font);
    font-size: 16px;
    font-weight: 600;
    color: var(--rcs-text);
    text-align: center;
    transition: border-color var(--rcs-transition), background var(--rcs-transition), color var(--rcs-transition);
}

.rcs-yesno__btn:hover {
    border-color: var(--rcs-primary);
    background: rgba(245, 62, 40, 0.04);
}

.rcs-yesno__btn.rcs-yesno__btn--selected {
    border-color: var(--rcs-primary);
    background: var(--rcs-primary);
    color: #fff;
}

/* ------------------------------------------------------------------ */
/* Text input                                                           */
/* ------------------------------------------------------------------ */
.rcs-text-input {
    width: 100%;
    padding: 12px 14px;
    font-family: var(--rcs-font);
    font-size: 14px;
    color: var(--rcs-text);
    background: #fff;
    border: 1.5px solid var(--rcs-border);
    border-radius: var(--rcs-radius-sm);
    outline: none;
    transition: border-color var(--rcs-transition), box-shadow var(--rcs-transition);
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
}

.rcs-text-input:focus {
    border-color: var(--rcs-primary);
    box-shadow: 0 0 0 3px rgba(245, 62, 40, 0.12);
}

/* ------------------------------------------------------------------ */
/* NPS (0–10)                                                           */
/* ------------------------------------------------------------------ */
.rcs-nps {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 4px;
    width: 100%;
}

.rcs-nps__item {
    aspect-ratio: 1 / 1;
    min-height: 36px;
    border-radius: var(--rcs-radius-sm);
    border: 1.5px solid var(--rcs-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--rcs-font);
    font-size: 13px;
    font-weight: 600;
    color: var(--rcs-text);
    background: transparent;
    transition: border-color var(--rcs-transition), background var(--rcs-transition), color var(--rcs-transition);
    padding: 0;
}

/* Default state: bucket border colors (Detractor 0-6 red, Passive 7-8 amber, Promoter 9-10 green) */
.rcs-nps__item[data-value="0"],
.rcs-nps__item[data-value="1"],
.rcs-nps__item[data-value="2"],
.rcs-nps__item[data-value="3"],
.rcs-nps__item[data-value="4"],
.rcs-nps__item[data-value="5"],
.rcs-nps__item[data-value="6"] {
    border-color: #e74c3c;
    color: #c0392b;
}

.rcs-nps__item[data-value="7"],
.rcs-nps__item[data-value="8"] {
    border-color: #f5a623;
    color: #b88018;
}

.rcs-nps__item[data-value="9"],
.rcs-nps__item[data-value="10"] {
    border-color: #27ae60;
    color: #1e8449;
}

.rcs-nps__item:hover {
    filter: brightness(0.95);
}

.rcs-nps__item.rcs-nps__item--selected {
    color: #fff;
}

/* Detractor 0-6: red tint */
.rcs-nps__item[data-value="0"].rcs-nps__item--selected,
.rcs-nps__item[data-value="1"].rcs-nps__item--selected,
.rcs-nps__item[data-value="2"].rcs-nps__item--selected,
.rcs-nps__item[data-value="3"].rcs-nps__item--selected,
.rcs-nps__item[data-value="4"].rcs-nps__item--selected,
.rcs-nps__item[data-value="5"].rcs-nps__item--selected,
.rcs-nps__item[data-value="6"].rcs-nps__item--selected {
    background: #e74c3c;
    border-color: #e74c3c;
}

/* Passive 7-8: yellow */
.rcs-nps__item[data-value="7"].rcs-nps__item--selected,
.rcs-nps__item[data-value="8"].rcs-nps__item--selected {
    background: #f5a623;
    border-color: #f5a623;
}

/* Promoter 9-10: green */
.rcs-nps__item[data-value="9"].rcs-nps__item--selected,
.rcs-nps__item[data-value="10"].rcs-nps__item--selected {
    background: #27ae60;
    border-color: #27ae60;
}

.rcs-nps__labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 4px;
    font-size: 11px;
    color: var(--rcs-text-muted);
}

/* ------------------------------------------------------------------ */
/* Submit / Nav buttons                                                 */
/* ------------------------------------------------------------------ */
.rcs-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.rcs-btn {
    padding: 12px 24px;
    font-family: var(--rcs-font);
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--rcs-radius-sm);
    cursor: pointer;
    transition: background var(--rcs-transition), transform var(--rcs-transition);
    text-align: center;
}

.rcs-submit {
    background: var(--rcs-primary);
    color: #fff;
    flex: 1;
}

.rcs-submit:hover {
    background: var(--rcs-primary-hover);
    transform: translateY(-1px);
}

.rcs-submit:active {
    transform: translateY(0);
}

.rcs-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.rcs-btn--back {
    background: transparent;
    color: var(--rcs-text-muted);
    border: 1.5px solid var(--rcs-border);
}

.rcs-btn--back:hover {
    color: var(--rcs-text);
    border-color: var(--rcs-text-muted);
}

/* ------------------------------------------------------------------ */
/* Poll results                                                         */
/* ------------------------------------------------------------------ */
.rcs-poll-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.rcs-poll-results__row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rcs-poll-results__header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--rcs-text);
}

.rcs-poll-results__pct {
    font-weight: 700;
    color: var(--rcs-primary);
}

.rcs-poll-results__bar-bg {
    width: 100%;
    height: 8px;
    background: var(--rcs-border);
    border-radius: 4px;
    overflow: hidden;
}

.rcs-poll-results__bar-fill {
    height: 100%;
    background: var(--rcs-primary);
    border-radius: 4px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.rcs-poll-results__total {
    font-size: 12px;
    color: var(--rcs-text-muted);
    text-align: center;
    margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* Thank-you screen                                                     */
/* ------------------------------------------------------------------ */
.rcs-thankyou {
    text-align: center;
    padding: 32px 24px;
}

.rcs-thankyou__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(39, 174, 96, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: #27ae60;
}

.rcs-thankyou__title {
    font-family: var(--rcs-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--rcs-text);
    margin: 0 0 8px;
}

.rcs-thankyou__text {
    font-size: 14px;
    color: var(--rcs-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Error state                                                          */
/* ------------------------------------------------------------------ */
.rcs-error {
    text-align: center;
    padding: 24px;
    color: #dc2626;
    font-size: 14px;
}

.rcs-error__retry {
    margin-top: 12px;
    padding: 8px 20px;
    background: var(--rcs-primary);
    color: #fff;
    border: none;
    border-radius: var(--rcs-radius-sm);
    cursor: pointer;
    font-family: var(--rcs-font);
    font-size: 14px;
    font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Loading spinner                                                      */
/* ------------------------------------------------------------------ */
.rcs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.rcs-loading__spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--rcs-border);
    border-top-color: var(--rcs-primary);
    border-radius: 50%;
    animation: rcs-spin 0.7s linear infinite;
}

@keyframes rcs-spin {
    to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------ */
/* Accessibility: focus-visible ring                                    */
/* ------------------------------------------------------------------ */
.rcs-submit:focus-visible,
.rcs-btn:focus-visible,
.rcs-close:focus-visible,
.rcs-option:focus-visible,
.rcs-scale__item:focus-visible,
.rcs-yesno__btn:focus-visible,
.rcs-nps__item:focus-visible,
.rcs-text-input:focus-visible {
    outline: 3px solid var(--rcs-primary);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Reduced motion                                                       */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .rcs-popup,
    .rcs-popup__dialog,
    .rcs-progress__bar,
    .rcs-poll-results__bar-fill,
    .rcs-option,
    .rcs-scale__item,
    .rcs-yesno__btn,
    .rcs-nps__item,
    .rcs-submit,
    .rcs-btn,
    .rcs-close {
        transition: none;
    }

    .rcs-loading__spinner {
        animation-duration: 1.5s;
    }
}

/* ------------------------------------------------------------------ */
/* Mobile (≤ 600px) — bottom sheet for popup, stacked layout            */
/* ------------------------------------------------------------------ */
@media (max-width: 600px) {
    .rcs-popup {
        padding: 0;
        align-items: flex-end;
    }

    .rcs-popup__dialog {
        max-width: 100%;
        width: 100%;
        max-height: 88vh;
        border-radius: var(--rcs-radius) var(--rcs-radius) 0 0;
        transform: translateY(100%);
    }

    .rcs-popup--open .rcs-popup__dialog {
        transform: translateY(0);
    }

    .rcs-form {
        padding: 52px 16px 20px;
    }

    .rcs-form__title {
        font-size: 18px;
    }

    .rcs-submit {
        width: 100%;
    }

    .rcs-actions {
        flex-direction: column;
    }

    .rcs-actions .rcs-btn--back {
        order: 1;
    }

    .rcs-actions .rcs-submit {
        order: 0;
    }

    .rcs-nps {
        gap: 3px;
    }

    .rcs-nps__item {
        min-height: 28px;
        font-size: 12px;
        border-width: 1.5px;
    }

    .rcs-scale__item {
        width: 40px;
        height: 40px;
    }
}
