/**
 * PulsePoll™ Frontend Styles
 * Mobile-first, responsive design with enhanced interactivity
 */

/* Reset and base styles */
.pulsepoll-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main widget container */
.pulsepoll-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 340px;
    max-width: calc(100vw - 40px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.5s ease-out;
}

.pulsepoll-widget.show {
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.pulsepoll-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pulsepoll-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.pulsepoll-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.pulsepoll-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: rotate(90deg);
}

/* Content area */
.pulsepoll-content {
    padding: 22px;
}

.pulsepoll-question {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Voting form */
.pulsepoll-form {
    margin-bottom: 0;
}

.pulsepoll-options {
    margin-bottom: 20px;
}

.pulsepoll-option {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 2px solid #f3f4f6;
    border-radius: 10px;
    transition: all 0.3s ease;
    position: relative;
    background: #fafbfc;
}

.pulsepoll-option:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pulsepoll-option:has(.pulsepoll-input:checked) {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.pulsepoll-input {
    margin-right: 14px;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    cursor: pointer;
    flex-shrink: 0;
}

.pulsepoll-input[type="radio"] {
    appearance: none;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background: white;
    position: relative;
    transition: all 0.2s ease;
}

.pulsepoll-input[type="radio"]:checked {
    border-color: #667eea;
    background: #667eea;
}

.pulsepoll-input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

.pulsepoll-input[type="checkbox"] {
    appearance: none;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: white;
    position: relative;
    transition: all 0.2s ease;
}

.pulsepoll-input[type="checkbox"]:checked {
    border-color: #667eea;
    background: #667eea;
}

.pulsepoll-input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.pulsepoll-option-text {
    flex: 1;
    color: #374151;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}

.pulsepoll-checkmark {
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.pulsepoll-option:has(.pulsepoll-input:checked) .pulsepoll-checkmark {
    opacity: 1;
}

.pulsepoll-checkmark::after {
    content: '✓';
    color: #667eea;
    font-weight: bold;
    font-size: 16px;
}

/* Actions */
.pulsepoll-actions {
    text-align: center;
}

.pulsepoll-vote-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.pulsepoll-vote-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.pulsepoll-vote-btn:hover:not(:disabled)::before {
    left: 100%;
}

.pulsepoll-vote-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.pulsepoll-vote-btn:active:not(:disabled) {
    transform: translateY(0);
}

.pulsepoll-vote-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    background: #9ca3af;
}

.pulsepoll-vote-btn.pulsepoll-btn-ready {
    opacity: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
}

.pulsepoll-type-hint {
    margin-top: 10px;
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

/* Voted message */
.pulsepoll-voted-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
    border-radius: 8px;
    color: #065f46;
    font-weight: 500;
}

/* Results */
.pulsepoll-results h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 18px;
    text-align: center;
}

.pulsepoll-result-item {
    margin-bottom: 16px;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 8px;
}

.pulsepoll-result-item.pulsepoll-result-updated {
    background-color: #f0f9ff;
    border: 1px solid #bfdbfe;
}

.pulsepoll-result-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.pulsepoll-option-name {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.pulsepoll-result-stats {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.pulsepoll-result-bar {
    background-color: #f3f4f6;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.pulsepoll-result-fill {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    width: 0%;
    transition: width 1s ease-out;
    border-radius: 5px;
    position: relative;
}

.pulsepoll-result-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.pulsepoll-total-votes {
    margin-top: 18px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
    font-weight: 500;
}

/* Messages */
.pulsepoll-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    animation: slideInDown 0.3s ease-out;
}

@keyframes slideInDown {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.pulsepoll-message-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.pulsepoll-message-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
    color: #991b1b;
    border: 1px solid #f87171;
}

.pulsepoll-message-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* Footer */
.pulsepoll-footer {
    padding: 14px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.pulsepoll-powered {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.pulsepoll-powered a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.pulsepoll-powered a:hover {
    color: #5b6ef3;
    text-decoration: underline;
}

/* Loading states */
.pulsepoll-btn-loading {
    display: inline-flex;
    align-items: center;
}

.pulsepoll-btn-loading::after {
    content: "";
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .pulsepoll-widget {
        width: 320px;
        bottom: 15px;
        right: 15px;
        max-width: calc(100vw - 30px);
    }
    
    .pulsepoll-header {
        padding: 16px 18px;
    }
    
    .pulsepoll-content {
        padding: 18px;
    }
    
    .pulsepoll-title {
        font-size: 16px;
    }
    
    .pulsepoll-question {
        font-size: 15px;
    }
    
    .pulsepoll-option {
        padding: 12px 14px;
    }
    
    .pulsepoll-option-text {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .pulsepoll-widget {
        width: 300px;
        bottom: 10px;
        right: 10px;
        max-width: calc(100vw - 20px);
    }
    
    .pulsepoll-option {
        padding: 10px 12px;
    }
    
    .pulsepoll-vote-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Admin styles */
.pulsepoll-admin-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.pulsepoll-status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.pulsepoll-status-badge.active {
    background-color: #d1fae5;
    color: #065f46;
}

.pulsepoll-status-badge.inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

.pulsepoll-admin-form .form-table th {
    width: 200px;
}

.poll-option {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.poll-option input[type="text"] {
    flex: 1;
}

.remove-option {
    flex-shrink: 0;
}

/* Focus states for accessibility */
.pulsepoll-input:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.pulsepoll-option:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.pulsepoll-vote-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .pulsepoll-widget {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .pulsepoll-question {
        color: #f9fafb;
    }
    
    .pulsepoll-option {
        background: #374151;
        border-color: #4b5563;
    }
    
    .pulsepoll-option:hover {
        background: #4b5563;
        border-color: #6b7280;
    }
    
    .pulsepoll-option-text {
        color: #e5e7eb;
    }
    
    .pulsepoll-result-bar {
        background-color: #374151;
    }
    
    .pulsepoll-footer {
        background: #374151;
        border-color: #4b5563;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .pulsepoll-option {
        border-width: 3px;
    }
    
    .pulsepoll-input {
        border-width: 3px;
    }
    
    .pulsepoll-vote-btn {
        border: 2px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .pulsepoll-widget {
        transition: none;
    }
    
    .pulsepoll-option {
        transition: none;
    }
    
    .pulsepoll-result-fill {
        transition: none;
    }
    
    .pulsepoll-vote-btn {
        transition: none;
    }
}