/**
 * Frontend styles for Secure Survey Professional
 */

/* Container */
.ssp-survey-container {
    max-width: 800px;
    margin: 30px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ssp-survey-description {
    margin-bottom: 30px;
    padding: 20px;
    background: #f7f7f7;
    border-left: 4px solid #007cba;
    border-radius: 4px;
}

/* Form sections */
.ssp-form-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #e0e0e0;
}

.ssp-form-section:last-child {
    border-bottom: none;
}

.ssp-form-section h3 {
    color: #333;
    font-size: 1.4em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #007cba;
}

/* Form groups */
.ssp-form-group {
    margin-bottom: 20px;
}

.ssp-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.ssp-form-group label .required {
    color: #d63638;
    margin-left: 4px;
}

/* Form controls */
.ssp-form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.ssp-form-control:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0,124,186,0.1);
}

textarea.ssp-form-control {
    resize: vertical;
    min-height: 100px;
}

/* Questions */
.ssp-question {
    margin-bottom: 25px;
    padding: 20px;
    background: #fafafa;
    border-radius: 6px;
}

.ssp-question label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    color: #333;
    font-size: 1.05em;
}

/* Radio and checkbox options */
.ssp-radio-option,
.ssp-checkbox-option {
    margin-bottom: 10px;
}

.ssp-radio-option label,
.ssp-checkbox-option label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ssp-radio-option label:hover,
.ssp-checkbox-option label:hover {
    background: #f0f0f0;
}

.ssp-radio-option input,
.ssp-checkbox-option input {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Rating field */
.ssp-rating-field {
    display: flex;
    gap: 10px;
}

.ssp-rating-star {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.ssp-rating-star input {
    position: absolute;
    opacity: 0;
}

.ssp-rating-star span {
    font-size: 30px;
    color: #ddd;
    transition: color 0.2s;
}

.ssp-rating-star:hover span,
.ssp-rating-star input:checked ~ span {
    color: #ffb600;
}

.ssp-rating-field:hover .ssp-rating-star span {
    color: #ffb600;
}

.ssp-rating-star:hover ~ .ssp-rating-star span {
    color: #ddd !important;
}

/* CAPTCHA sections */
.ssp-captcha-section {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.ssp-captcha-section + .ssp-captcha-section {
    margin-top: 10px;
}

/* GDPR notice */
.ssp-gdpr-notice {
    margin: 30px 0;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
}

.ssp-gdpr-notice label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
}

.ssp-gdpr-notice input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 3px;
    flex-shrink: 0;
}

/* Submit button */
.ssp-form-submit {
    margin-top: 30px;
    text-align: center;
}

.ssp-submit-btn {
    background: #007cba;
    color: white;
    padding: 14px 40px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
}

.ssp-submit-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
}

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

.ssp-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Loading state */
.ssp-loading {
    text-align: center;
    padding: 40px;
}

.ssp-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: ssp-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes ssp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.ssp-messages {
    margin-top: 20px;
}

.ssp-message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    animation: ssp-slide-in 0.3s ease-out;
}

@keyframes ssp-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ssp-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.ssp-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.ssp-message.warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

/* Success page */
.ssp-success-message {
    text-align: center;
    padding: 40px;
    background: #d4edda;
    border-radius: 8px;
}

.ssp-success-message h3 {
    color: #155724;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.ssp-success-message p {
    color: #155724;
    font-size: 1.1em;
    line-height: 1.6;
}

/* Already responded */
.ssp-already-responded {
    padding: 30px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    text-align: center;
}

/* Survey results */
.ssp-survey-results {
    margin-top: 30px;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 8px;
}

.ssp-survey-results h3 {
    margin-bottom: 20px;
    color: #333;
}

/* Responsive design */
@media (max-width: 768px) {
    .ssp-survey-container {
        margin: 20px;
        padding: 20px;
    }
    
    .ssp-form-section h3 {
        font-size: 1.2em;
    }
    
    .ssp-submit-btn {
        width: 100%;
    }
    
    .ssp-rating-field {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .ssp-survey-container {
        margin: 10px;
        padding: 15px;
    }
    
    .ssp-question {
        padding: 15px;
    }
}

/* Validation styles */
.ssp-form-control.error {
    border-color: #d63638;
}

.ssp-form-control.error:focus {
    box-shadow: 0 0 0 3px rgba(214,54,56,0.1);
}

.ssp-error-message {
    color: #d63638;
    font-size: 14px;
    margin-top: 5px;
    display: block;
}

/* Print styles */
@media print {
    .ssp-submit-btn,
    .ssp-loading {
        display: none;
    }
    
    .ssp-survey-container {
        box-shadow: none;
        padding: 0;
    }
}

/* Results Display Styles */
.ssp-results-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ssp-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.ssp-stat-card {
    background: #f7f7f7;
    padding: 20px;
    border-radius: 6px;
    text-align: center;
    border-left: 4px solid #007cba;
}

.ssp-stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #007cba;
}

.ssp-stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.ssp-question-result-item {
    margin: 30px 0;
    padding: 20px;
    background: #fafafa;
    border-radius: 6px;
}

.ssp-question-result-item h4 {
    margin-bottom: 15px;
    color: #333;
}

.ssp-answer-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px;
    background: white;
    border-radius: 4px;
}

.ssp-answer-label {
    flex: 0 0 200px;
    margin-right: 15px;
    font-weight: 500;
}

.ssp-answer-bar-container {
    flex: 1;
    background: #e0e0e0;
    border-radius: 4px;
    height: 30px;
    position: relative;
    overflow: hidden;
}

.ssp-answer-bar {
    background: linear-gradient(90deg, #007cba, #005a87);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    transition: width 0.5s ease;
    border-radius: 4px;
    min-width: fit-content;
}

.ssp-answer-percentage {
    color: white;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Show percentage outside bar if bar is too small */
.ssp-answer-bar[style*="width: 0%"] .ssp-answer-percentage,
.ssp-answer-bar[style*="width: 1%"] .ssp-answer-percentage,
.ssp-answer-bar[style*="width: 2%"] .ssp-answer-percentage,
.ssp-answer-bar[style*="width: 3%"] .ssp-answer-percentage,
.ssp-answer-bar[style*="width: 4%"] .ssp-answer-percentage,
.ssp-answer-bar[style*="width: 5%"] .ssp-answer-percentage {
    position: absolute;
    left: 5px;
    color: #333;
}

.ssp-answer-count {
    margin-left: 10px;
    min-width: 100px;
    text-align: right;
    color: #666;
    font-size: 0.9em;
}

.ssp-question-results h3 {
    margin-top: 40px;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.ssp-no-responses {
    color: #999;
    font-style: italic;
}

.ssp-response-chart {
    margin-top: 40px;
    padding: 20px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ssp-response-chart canvas {
    max-height: 300px;
}

/* Results in success message */
.ssp-question-result {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.ssp-question-result h5 {
    margin-bottom: 10px;
    color: #333;
}

.ssp-answer-item {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.ssp-answer-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.ssp-answer-bar-wrapper {
    margin: 10px 0;
}

.ssp-answer-bar {
    background: #e0e0e0;
    height: 30px;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.ssp-answer-progress {
    background: linear-gradient(90deg, #007cba, #005a87);
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
}

.ssp-answer-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9em;
    color: #666;
}

.ssp-answer-percentage {
    font-weight: bold;
    color: #007cba;
}

.ssp-answer-breakdown {
    padding: 10px;
    background: #fafafa;
    border-radius: 4px;
}

/* Simple results display for shortcode */
.ssp-answer-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 0;
}

.ssp-answer-percentage-display {
    min-width: 50px;
    font-weight: bold;
    color: #007cba;
    margin-right: 15px;
    font-size: 1.1em;
}

.ssp-answer-text {
    flex: 1;
    color: #333;
}

.ssp-answer-visual {
    width: 200px;
    height: 20px;
    background: #f0f0f0;
    border-radius: 3px;
    margin-left: 15px;
    overflow: hidden;
}

.ssp-answer-bar-mini {
    height: 100%;
    transition: width 0.5s ease;
    background: #007cba;
}

.ssp-answers-breakdown {
    padding: 15px;
    background: #fafafa;
    border-radius: 4px;
    margin-top: 10px;
}
