/* =========================================================
   PRM ENCUESTAS PLUGIN · FRONTEND CSS
   Diseñado para funcionar con CUALQUIER tema de WordPress.
   Todos los estilos están encapsulados dentro de .prm-poll
   ========================================================= */

.prm-poll {
    /* Variables locales — no afectan al tema del usuario */
    --prm-party: #0066B3;
    --prm-party-dark: #004C87;
    --prm-accent: #E89923;
    --prm-ink: #0A0E1A;
    --prm-ink-soft: #3A3F4D;
    --prm-ink-muted: #6B7280;
    --prm-paper: #FFFFFF;
    --prm-bg-alt: #F4F4F0;
    --prm-line: #E5E2D8;
    --prm-radius: 4px;
    --prm-radius-lg: 12px;
    --prm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --prm-shadow: 0 4px 24px rgba(10, 14, 26, 0.06);

    background: var(--prm-paper);
    border-radius: var(--prm-radius-lg);
    padding: 40px;
    border: 1px solid var(--prm-line);
    box-shadow: var(--prm-shadow);
    max-width: 760px;
    margin: 24px auto;
    position: relative;
    overflow: hidden;
    font-family: var(--prm-font);
    color: var(--prm-ink);
    line-height: 1.5;
    box-sizing: border-box;
}

.prm-poll *,
.prm-poll *::before,
.prm-poll *::after {
    box-sizing: border-box;
}

.prm-poll::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--prm-party) 0%, var(--prm-accent) 100%);
}

.prm-poll-header { margin-bottom: 24px; }

.prm-poll-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(0, 102, 179, 0.08);
    color: var(--prm-party);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
    line-height: 1;
}
.prm-poll-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--prm-party);
}

.prm-poll-title {
    font-family: var(--prm-font);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--prm-ink);
    margin: 0 0 10px 0;
}

.prm-poll-description {
    color: var(--prm-ink-soft);
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
}

.prm-poll-closed-notice {
    background: var(--prm-bg-alt);
    border-left: 3px solid var(--prm-accent);
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--prm-ink-soft);
    margin-bottom: 24px;
    border-radius: 4px;
}

/* ============ FORMULARIO ============ */

.prm-poll-geo { margin-bottom: 20px; }
.prm-poll-geo label { display: block; }
.prm-poll-geo label span {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--prm-ink);
    margin-bottom: 8px;
}
.prm-poll-geo select {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--prm-line);
    border-radius: var(--prm-radius);
    font-family: var(--prm-font);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    color: var(--prm-ink);
    line-height: 1.4;
}
.prm-poll-geo select:focus {
    outline: none;
    border-color: var(--prm-party);
}

.prm-poll-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    list-style: none;
    padding: 0;
}

.prm-poll-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--prm-bg-alt);
    border: 1.5px solid var(--prm-line);
    border-radius: var(--prm-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin: 0;
}

.prm-poll-option input[type="radio"],
.prm-poll-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.prm-poll-option-marker {
    width: 22px;
    height: 22px;
    border: 2px solid var(--prm-line);
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.2s;
    background: white;
    position: relative;
    display: inline-block;
}

.prm-poll-option input[type="checkbox"] ~ .prm-poll-option-marker {
    border-radius: 4px;
}

.prm-poll-option:hover {
    background: white;
    border-color: var(--option-color, var(--prm-party));
}

.prm-poll-option:has(input:checked) {
    background: white;
    border-color: var(--option-color, var(--prm-party));
    box-shadow: 0 0 0 3px rgba(0, 102, 179, 0.1);
}

.prm-poll-option:has(input:checked) .prm-poll-option-marker {
    border-color: var(--option-color, var(--prm-party));
    background: var(--option-color, var(--prm-party));
}
.prm-poll-option:has(input:checked) .prm-poll-option-marker::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}
.prm-poll-option:has(input[type="checkbox"]:checked) .prm-poll-option-marker::after {
    width: 12px;
    height: 6px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    background: transparent;
    border-radius: 0;
    transform: translate(-50%, -75%) rotate(-45deg);
}

/* Fallback para navegadores sin :has() */
.prm-poll-option input:checked + .prm-poll-option-marker {
    border-color: var(--option-color, var(--prm-party));
    background: var(--option-color, var(--prm-party));
}

.prm-poll-option-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--prm-ink);
    flex: 1;
}

/* ============ ACCIONES ============ */

.prm-poll-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.prm-poll-submit {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--prm-party);
    color: white !important;
    border: 0;
    border-radius: var(--prm-radius);
    font-family: var(--prm-font);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 102, 179, 0.25);
    text-decoration: none;
    line-height: 1;
}
.prm-poll-submit:hover {
    background: var(--prm-party-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 102, 179, 0.35);
    color: white !important;
}
.prm-poll-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.prm-poll-show-results {
    color: var(--prm-ink-muted) !important;
    font-size: 0.9rem;
    text-decoration: none !important;
    transition: color 0.2s;
}
.prm-poll-show-results:hover {
    color: var(--prm-party) !important;
}

.prm-poll-message {
    width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--prm-radius);
    font-size: 0.9rem;
    display: none;
}
.prm-poll-message.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
    border-left: 3px solid #22c55e;
}
.prm-poll-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
    border-left: 3px solid #ef4444;
}

/* ============ RESULTADOS ============ */

.prm-poll-results { padding-top: 8px; }

.prm-poll-results-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--prm-line);
}

.prm-poll-total-votes {
    font-size: 1rem;
    color: var(--prm-ink);
}
.prm-poll-total-votes strong {
    font-size: 1.4rem;
    color: var(--prm-party);
    margin-right: 4px;
    font-weight: 700;
}

.prm-poll-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: prm-pulse 1.5s infinite;
    margin-left: auto;
}
@keyframes prm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.prm-poll-live-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #166534;
}

.prm-poll-bars {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.prm-poll-result-row { position: relative; }

.prm-poll-result-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.prm-poll-result-text {
    font-weight: 500;
    color: var(--prm-ink);
}

.prm-poll-result-stats {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}
.prm-poll-result-votes {
    font-size: 0.85rem;
    color: var(--prm-ink-muted);
}
.prm-poll-result-pct {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--prm-ink);
    min-width: 56px;
    text-align: right;
}

.prm-poll-result-bar-track {
    height: 12px;
    background: var(--prm-bg-alt);
    border-radius: 100px;
    overflow: hidden;
    position: relative;
}

.prm-poll-result-bar-fill {
    height: 100%;
    background: var(--prm-party);
    border-radius: 100px;
    transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: hidden;
}
.prm-poll-result-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: prm-shimmer 2.5s infinite;
}
@keyframes prm-shimmer {
    100% { transform: translateX(100%); }
}

.prm-poll-footer-note {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--prm-line);
    font-size: 0.85rem;
    color: var(--prm-ink-muted);
    text-align: center;
}
.prm-poll-refresh {
    color: var(--prm-party) !important;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
}

.prm-poll-empty {
    background: var(--prm-bg-alt);
    padding: 24px;
    border-radius: var(--prm-radius-lg);
    text-align: center;
    color: var(--prm-ink-muted);
    font-family: var(--prm-font);
}

/* ============ Widget en sidebar (más compacto) ============ */
.prm-widget .prm-poll {
    padding: 24px;
    margin: 0;
}
.prm-widget .prm-poll-title { font-size: 1.15rem; }

/* ============ Responsive ============ */
@media (max-width: 640px) {
    .prm-poll { padding: 24px 20px; }
    .prm-poll-options { gap: 8px; }
    .prm-poll-option { padding: 14px 16px; gap: 12px; }
    .prm-poll-actions { flex-direction: column; align-items: stretch; }
    .prm-poll-submit { justify-content: center; }
    .prm-poll-show-results { text-align: center; }
}
