/**
 * TPoll Frontend Styles
 *
 * @package TPoll
 */

/* CSS Variables */
:root {
    --tpoll-c1: #4F46E5;
    --tpoll-c2: #0E7490;
    --tpoll-c3: #C2410C;
    --tpoll-c4: #15803D;
    --tpoll-c5: #9D174D;
    --tpoll-c6: #A16207;
    --tpoll-c7: #6D28D9;
    --tpoll-c8: #334155;
    --tpoll-primary: #4F46E5;
    --tpoll-primary-hover: #4338CA;
    --tpoll-text: #1F2937;
    --tpoll-text-light: #6B7280;
    --tpoll-bg: #FFFFFF;
    --tpoll-border: #E5E7EB;
    --tpoll-success: #047857;
    --tpoll-error: #B91C1C;
    --tpoll-warning: #F59E0B;
    --tpoll-radius: 8px;
    --tpoll-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --tpoll-transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Dark Mode Auto */
@media (prefers-color-scheme: dark) {
    .tpoll-dark-auto {
        --tpoll-text: #F9FAFB;
        --tpoll-text-light: #9CA3AF;
        --tpoll-bg: #1F2937;
        --tpoll-border: #374151;
    }
}

/* Dark Mode Forced */
.tpoll-dark {
    --tpoll-text: #F9FAFB;
    --tpoll-text-light: #9CA3AF;
    --tpoll-bg: #1F2937;
    --tpoll-border: #374151;
}

/* Poll Container */
.tpoll-poll {
    background: var(--tpoll-bg);
    border: 1px solid var(--tpoll-border);
    border-radius: var(--tpoll-radius);
    padding: 24px;
    margin: 20px 0;
    font-family: inherit;
    color: var(--tpoll-text);
    box-shadow: var(--tpoll-shadow);
}

/* Question */
.tpoll-question {
    font-size: 1.25em;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
    color: var(--tpoll-text);
}

/* Answers Container */
.tpoll-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

/* Answer Option */
.tpoll-answer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--tpoll-bg);
    border: 2px solid var(--tpoll-border);
    border-radius: var(--tpoll-radius);
    cursor: pointer;
    transition: var(--tpoll-transition);
    position: relative;
}

.tpoll-answer:hover {
    border-color: var(--tpoll-primary);
    background: rgba(79, 70, 229, 0.05);
}

.tpoll-answer input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom Checkmark */
.tpoll-checkmark {
    position: relative;
    height: 20px;
    width: 20px;
    min-width: 20px;
    background: var(--tpoll-bg);
    border: 2px solid var(--tpoll-border);
    border-radius: 50%;
    margin-right: 12px;
    transition: var(--tpoll-transition);
}

.tpoll-checkbox .tpoll-checkmark {
    border-radius: 4px;
}

.tpoll-answer:hover .tpoll-checkmark {
    border-color: var(--tpoll-primary);
}

.tpoll-answer input:checked ~ .tpoll-checkmark {
    background: var(--tpoll-primary);
    border-color: var(--tpoll-primary);
}

.tpoll-checkmark::after {
    content: "";
    position: absolute;
    display: none;
}

.tpoll-answer input:checked ~ .tpoll-checkmark::after {
    display: block;
}

.tpoll-radio .tpoll-checkmark::after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.tpoll-checkbox .tpoll-checkmark::after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Answer Text */
.tpoll-answer-text {
    flex: 1;
    font-size: 1em;
    line-height: 1.4;
    color: var(--tpoll-text);
}

/* Submit Button */
.tpoll-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    background: var(--tpoll-primary);
    color: white;
    border: none;
    border-radius: var(--tpoll-radius);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tpoll-transition);
    min-width: 120px;
}

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

.tpoll-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tpoll-submit.tpoll-loading {
    position: relative;
    color: transparent;
}

.tpoll-submit.tpoll-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: tpoll-spin 0.8s linear infinite;
}

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

/* Messages */
.tpoll-message {
    padding: 12px 16px;
    border-radius: var(--tpoll-radius);
    margin-top: 16px;
    font-size: 0.95em;
}

.tpoll-message-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--tpoll-success);
    border: 1px solid var(--tpoll-success);
}

.tpoll-message-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--tpoll-error);
    border: 1px solid var(--tpoll-error);
}

.tpoll-voted,
.tpoll-closed {
    padding: 12px 16px;
    background: rgba(107, 114, 128, 0.1);
    border-radius: var(--tpoll-radius);
    color: var(--tpoll-text-light);
    margin-bottom: 16px;
    text-align: center;
}

/* Results */
.tpoll-results {
    margin-top: 20px;
}

.tpoll-result-item {
    margin-bottom: 16px;
}

.tpoll-result-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.tpoll-result-answer {
    font-weight: 500;
    color: var(--tpoll-text);
}

.tpoll-result-percent {
    font-weight: 600;
    color: var(--tpoll-text);
}

.tpoll-result-bar-wrap {
    height: 10px;
    background: var(--tpoll-bar-bg, var(--tpoll-border));
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 4px;
}

.tpoll-result-bar {
    height: 100%;
    background: var(--tpoll-bar, var(--tpoll-primary));
    border-radius: 5px;
    transform-origin: left center;
    animation: tpoll-grow 0.8s ease-out;
}

@keyframes tpoll-grow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.tpoll-no-animation .tpoll-result-bar {
    animation: none;
}

@media (prefers-reduced-motion: reduce) {
    .tpoll-result-bar {
        animation: none;
    }
}

.tpoll-result-votes {
    font-size: 0.85em;
    color: var(--tpoll-text-light);
}

.tpoll-total-voters,
.tpoll-average-rating {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--tpoll-border);
    font-size: 0.9em;
    color: var(--tpoll-text-light);
    text-align: center;
}

/* Rating (Stars) */
.tpoll-rating {
    text-align: center;
    padding: 20px 0;
}

.tpoll-stars {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tpoll-star {
    cursor: pointer;
    color: var(--tpoll-border);
    transition: var(--tpoll-transition);
    background: none;
    border: 0;
    padding: 2px;
    margin: 0;
    line-height: 0;
    border-radius: 4px;
}

.tpoll-star:focus-visible {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
}

.tpoll-star:hover,
.tpoll-star-active {
    color: #FBBF24;
    transform: scale(1.1);
}

.tpoll-star svg {
    display: block;
}

.tpoll-rating-text {
    display: block;
    font-size: 0.9em;
    color: var(--tpoll-text-light);
}

/* Voting (Thumbs) */
.tpoll-voting {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 20px 0;
}

.tpoll-vote-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--tpoll-bg);
    border: 2px solid var(--tpoll-border);
    border-radius: var(--tpoll-radius);
    cursor: pointer;
    transition: var(--tpoll-transition);
    color: var(--tpoll-text);
}

.tpoll-vote-btn:hover {
    border-color: var(--tpoll-primary);
    transform: translateY(-2px);
}

.tpoll-vote-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tpoll-vote-up:hover {
    color: var(--tpoll-success);
    border-color: var(--tpoll-success);
}

.tpoll-vote-down:hover {
    color: var(--tpoll-error);
    border-color: var(--tpoll-error);
}

.tpoll-count {
    font-weight: 600;
    font-size: 1.1em;
}

/* Link Button */
.tpoll-btn-link {
    background: none;
    border: none;
    color: var(--tpoll-primary);
    cursor: pointer;
    font-size: 0.95em;
    padding: 8px 0;
    text-decoration: underline;
}

.tpoll-btn-link:hover {
    color: var(--tpoll-primary-hover);
}

/* Hint Text */
.tpoll-hint {
    font-size: 0.85em;
    color: var(--tpoll-text-light);
    margin-bottom: 12px;
}

/* Theme: Minimal */
.tpoll-theme-minimal {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.tpoll-theme-minimal .tpoll-answer {
    border: none;
    border-bottom: 1px solid var(--tpoll-border);
    border-radius: 0;
    padding: 12px 0;
}

/* Theme: Rounded */
.tpoll-theme-rounded {
    border-radius: 16px;
}

.tpoll-theme-rounded .tpoll-answer {
    border-radius: 12px;
}

.tpoll-theme-rounded .tpoll-submit {
    border-radius: 12px;
}

/* Theme: Square */
.tpoll-theme-square {
    border-radius: 0;
}

.tpoll-theme-square .tpoll-answer {
    border-radius: 0;
}

.tpoll-theme-square .tpoll-submit {
    border-radius: 0;
}

.tpoll-theme-square .tpoll-checkmark {
    border-radius: 0 !important;
}

/* Theme: Pill */
.tpoll-theme-pill {
    border-radius: 24px;
}

.tpoll-theme-pill .tpoll-answer {
    border-radius: 50px;
}

.tpoll-theme-pill .tpoll-submit {
    border-radius: 50px;
}

/* Responsive */
@media (max-width: 480px) {
    .tpoll-poll {
        padding: 16px;
        margin: 16px 0;
    }

    .tpoll-question {
        font-size: 1.1em;
    }

    .tpoll-answer {
        padding: 10px 12px;
    }

    .tpoll-submit {
        width: 100%;
        padding: 14px 24px;
    }

    .tpoll-voting {
        gap: 16px;
    }

    .tpoll-vote-btn {
        padding: 12px 20px;
    }
}

/* Utility */
.tpoll-hidden {
    display: none !important;
}

/* 1.0.4: keyboard focus, hidden state, notes */
.tpoll-poll [hidden] {
    display: none !important;
}

.tpoll-answer:focus-within {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
}

.tpoll-vote-btn:focus-visible,
.tpoll-submit:focus-visible {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
}

.tpoll-result-voting {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-weight: 600;
}

.tpoll-result-note,
.tpoll-noscript {
    font-size: 0.85em;
    color: var(--tpoll-text-light);
    margin: 8px 0 0;
}

.tpoll-login-required a {
    margin-left: 6px;
}

/* 1.0.6: hidden field against bots */
.tpoll-hp-wrap {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.tpoll-poll {
    position: relative;
}

.tpoll-poll .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 1.0.6: reactions */
.tpoll-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tpoll-reaction {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 52px;
    min-height: 48px;
    padding: 8px 14px;
    border: 2px solid var(--tpoll-border);
    border-radius: 999px;
    background: var(--tpoll-bg);
    color: var(--tpoll-text);
    font: inherit;
    cursor: pointer;
    transition: var(--tpoll-transition);
}

.tpoll-reaction:hover,
.tpoll-reaction[aria-pressed="true"] {
    border-color: var(--tpoll-primary);
    transform: translateY(-1px);
}

.tpoll-reaction:focus-visible {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
}

.tpoll-reaction-icon {
    font-size: 1.5em;
    line-height: 1;
}

.tpoll-reaction.is-result {
    cursor: default;
}

.tpoll-reaction.is-result .tpoll-count {
    font-weight: 600;
}

/* 1.0.6: donut chart */
.tpoll-donut {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.tpoll-donut-chart {
    width: 160px;
    height: 160px;
    flex: 0 0 auto;
}

.tpoll-donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 200px;
}

.tpoll-donut-legend li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    margin: 0 0 8px;
}

.tpoll-donut-key {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex: 0 0 auto;
    align-self: center;
}

/* 1.0.6: feedback below posts */
.tpoll-feedback {
    margin-top: 2em;
}

.tpoll-feedback .tpoll-poll {
    margin: 0;
}

/* 1.1.0: quiz question */
.tpoll-verdict-correct .tpoll-voted {
    background: rgba(16, 185, 129, 0.1);
    color: var(--tpoll-success);
    font-weight: 600;
}

.tpoll-verdict-wrong .tpoll-voted {
    background: rgba(239, 68, 68, 0.1);
    color: var(--tpoll-error);
    font-weight: 600;
}

.tpoll-quiz-share {
    margin: 0 0 16px;
    font-weight: 600;
}

.tpoll-quiz-results .tpoll-result-answer {
    margin-right: auto;
}

.tpoll-correct-label {
    margin: 0 10px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.8em;
    font-weight: 600;
    color: #FFFFFF;
    background: var(--tpoll-success);
}

.tpoll-result-correct .tpoll-result-answer {
    font-weight: 600;
}

.tpoll-result-correct .tpoll-result-bar {
    background: var(--tpoll-success);
}

.tpoll-quiz-explanation {
    margin: 4px 0 16px;
    padding: 12px 16px;
    border-left: 4px solid var(--tpoll-success);
    background: rgba(107, 114, 128, 0.08);
    border-radius: 0 var(--tpoll-radius) var(--tpoll-radius) 0;
    line-height: 1.5;
}

.tpoll-quiz-explanation a {
    color: inherit;
    text-decoration: underline;
}

.tpoll-dark.tpoll-verdict-correct .tpoll-voted,
.tpoll-dark.tpoll-verdict-wrong .tpoll-voted {
    color: var(--tpoll-text);
}

@media (prefers-color-scheme: dark) {
    .tpoll-dark-auto.tpoll-verdict-correct .tpoll-voted,
    .tpoll-dark-auto.tpoll-verdict-wrong .tpoll-voted {
        color: var(--tpoll-text);
    }
}


/* 1.1.0: questionnaire */
.tpoll-survey-progress {
    margin: 0 0 12px;
    font-size: 0.9em;
    color: var(--tpoll-text-light);
}

.tpoll-survey-step {
    border: 0;
    margin: 0 0 20px;
    padding: 0;
    min-width: 0;
}

.tpoll-survey-question {
    padding: 0;
    margin: 0 0 12px;
    font-weight: 600;
    font-size: 1.05em;
    color: var(--tpoll-text);
}

.tpoll-survey-step .tpoll-answers {
    margin-bottom: 0;
}

.tpoll-survey-js .tpoll-survey-step:not(.is-current) {
    display: none;
}

.tpoll-survey-nav {
    display: inline-flex;
    gap: 8px;
    margin-right: 8px;
    vertical-align: middle;
}

.tpoll-survey-nav [hidden],
.tpoll-type-survey .tpoll-submit[hidden] {
    display: none;
}

.tpoll-survey-back,
.tpoll-survey-next {
    padding: 12px 24px;
    border-radius: var(--tpoll-radius);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tpoll-transition);
}

.tpoll-survey-next {
    background: var(--tpoll-primary);
    color: #FFFFFF;
    border: 1px solid var(--tpoll-primary);
}

.tpoll-survey-next:hover {
    background: var(--tpoll-primary-hover);
}

.tpoll-survey-back {
    background: transparent;
    color: var(--tpoll-text);
    border: 1px solid var(--tpoll-border);
}

.tpoll-survey-back:hover {
    border-color: var(--tpoll-text-light);
}

.tpoll-survey-back:focus-visible,
.tpoll-survey-next:focus-visible {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
}

/* Stars without script: radio buttons, highlighted up to the checked one. */
.tpoll-survey-stars {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
}

.tpoll-survey-stars input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.tpoll-survey-stars label {
    color: var(--tpoll-border);
    cursor: pointer;
    line-height: 0;
    transition: var(--tpoll-transition);
}

.tpoll-survey-stars input:checked ~ label,
.tpoll-survey-stars label:hover,
.tpoll-survey-stars label:hover ~ label {
    color: var(--tpoll-warning);
}

.tpoll-survey-stars input:focus-visible + label {
    outline: 2px solid var(--tpoll-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.tpoll-survey-score {
    margin: 0 0 16px;
    font-size: 1.2em;
    font-weight: 700;
}

.tpoll-survey-result {
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--tpoll-border);
}

.tpoll-survey-result:first-of-type {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.tpoll-survey-result .tpoll-survey-question {
    margin-bottom: 8px;
}

.tpoll-survey-result .tpoll-results {
    margin-top: 0;
}

@media (max-width: 480px) {
    .tpoll-survey-nav {
        display: flex;
        margin: 0 0 8px;
    }

    .tpoll-survey-nav button,
    .tpoll-type-survey .tpoll-submit {
        flex: 1;
        width: 100%;
    }
}
