/**
 * WP Dynamic Survey Frontend CSS
 *
 * @package WP_Dynamic_Survey
 */

/* Reset and Base Styles */
.wp-dynamic-survey-container {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

.wp-dynamic-survey-container *,
.wp-dynamic-survey-container *::before,
.wp-dynamic-survey-container *::after {
    box-sizing: inherit;
}

/* Container and Layout */
.wp-dynamic-survey-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    padding: 0;
}

.survey-step {
    width: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.survey-step.active {
    display: block;
    opacity: 1;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 12px;
    backdrop-filter: blur(2px);
}

.loading-content {
    text-align: center;
    padding: 30px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    color: #6b7280;
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

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

/* Form Controls */
.form-control {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.5;
    background: #ffffff;
    transition: all 0.2s ease;
    font-family: inherit;
    color: #1f2937;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #ffffff;
}

.form-control::placeholder {
    color: #9ca3af;
}

.form-control.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.form-control.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form Groups and Labels */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 14px;
    letter-spacing: 0.025em;
}

.required {
    color: #ef4444;
    font-weight: bold;
    margin-left: 2px;
}

.optional {
    color: #6b7280;
    font-weight: normal;
    font-style: italic;
    font-size: 13px;
}

/* Error Messages */
.error-message {
    color: #ef4444;
    font-size: 13px;
    margin-top: 6px;
    min-height: 18px;
    font-weight: 500;
}

.form-error-container {
    margin: 20px 0;
}

.error-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 14px 18px;
    border-radius: 8px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.error-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 50px;
    position: relative;
    font-family: inherit;
    letter-spacing: 0.025em;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #6b7280;
    color: white;
    box-shadow: 0 2px 4px rgba(107, 114, 128, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.btn-loading {
    display: none;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

/* Progress Bar */
.survey-progress {
    margin-bottom: 40px;
    padding: 0 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-text {
    font-size: 16px;
    color: #6b7280;
    font-weight: 500;
}

.current-question,
.total-questions {
    font-weight: 700;
    color: #1f2937;
}

.progress-percentage {
    font-size: 14px;
    color: #2563eb;
    font-weight: 700;
    background: #eff6ff;
    padding: 4px 8px;
    border-radius: 6px;
}

.progress-bar {
    height: 8px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 35%, rgba(255, 255, 255, 0.2) 50%, transparent 65%);
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Question Interface */
.wp-dynamic-survey-question-interface {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
}

.question-content {
    background: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.question-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
}

.question-header {
    margin-bottom: 32px;
    text-align: center;
}

.question-title {
    font-size: 28px;
    color: #1f2937;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 16px;
    letter-spacing: -0.025em;
}

.question-description {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.required-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #fef2f2 0%, #fdf2f8 100%);
    color: #dc2626;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #fecaca;
}

.required-star {
    font-weight: bold;
    font-size: 14px;
}

/* Answer Options */
.answer-options {
    margin-bottom: 32px;
}

/* Multiple Choice & Boolean */
.multiple-choice-options,
.boolean-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.answer-option {
    position: relative;
}

.answer-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.answer-label {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

.answer-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.05), transparent);
    transition: left 0.5s ease;
}

.answer-label:hover {
    border-color: #2563eb;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.answer-label:hover::before {
    left: 100%;
}

.answer-input:checked + .answer-label {
    border-color: #2563eb;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.answer-radio {
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: #ffffff;
}

.answer-input:checked + .answer-label .answer-radio {
    border-color: #2563eb;
    background: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.answer-input:checked + .answer-label .answer-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: radio-check 0.2s ease-out;
}

@keyframes radio-check {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.answer-text {
    font-size: 16px;
    color: #1f2937;
    line-height: 1.5;
    font-weight: 500;
}

/* Boolean Specific */
.boolean-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.boolean-label {
    justify-content: center;
    text-align: center;
    min-height: 70px;
    font-weight: 700;
    font-size: 18px;
}

/* Rating Scale */
.rating-options {
    text-align: center;
}

.rating-scale {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.rating-item {
    position: relative;
}

.rating-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rating-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: 3px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

.rating-label::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.rating-label:hover {
    border-color: #2563eb;
    background: #f8fafc;
    transform: scale(1.05);
}

.rating-input:checked + .rating-label {
    border-color: #2563eb;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.rating-number {
    font-size: 20px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.rating-labels {
    display: flex;
    justify-content: space-between;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    margin-top: 16px;
    padding: 0 30px;
}

/* Text Inputs */
.text-input-container,
.textarea-container {
    width: 100%;
}

.text-input,
.textarea-input {
    width: 100%;
    padding: 18px 22px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.5;
    background: #ffffff;
    transition: all 0.2s ease;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

.text-input:focus,
.textarea-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background: #ffffff;
}

.character-count {
    text-align: right;
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.current-count {
    font-weight: 700;
    color: #1f2937;
}

/* Text input hints */
.text-submit-hint {
    text-align: center;
    margin-top: 12px;
    padding: 8px 16px;
    background: #f0f9ff;
    border: 1px solid #e0f2fe;
    border-radius: 6px;
}

.hint-text {
    font-size: 13px;
    color: #0369a1;
    font-weight: 500;
}

/* Auto-progression loading states */
.answer-loading,
.rating-loading {
    display: none;
    margin-left: auto;
}

.spinner-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(37, 99, 235, 0.3);
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 1s ease-in-out infinite;
}

.answer-label.loading,
.rating-label.loading {
    background: #f8fafc;
    border-color: #2563eb;
    opacity: 0.8;
    pointer-events: none;
}

.answer-label.loading .answer-text,
.rating-label.loading .rating-number {
    opacity: 0.6;
}

/* Question loading overlay */
.question-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 16px;
    backdrop-filter: blur(2px);
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin: 0 auto 20px;
}

/* Clickable cursor for auto-submit elements */
.clickable {
    cursor: pointer;
    user-select: none;
}

.auto-submit:disabled + .clickable {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Hover effects for auto-submit answers */
.answer-label.clickable:hover:not(.loading) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
}

.rating-label.clickable:hover:not(.loading) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

/* Redirect message styles */
.redirect-message {
    text-align: center;
    padding: 60px 40px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.redirect-content h3 {
    color: #1f2937;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
}

.redirect-content p {
    color: #6b7280;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 15px;
}

.redirect-url {
    background: #f3f4f6;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #1f2937;
    word-break: break-all;
    border: 1px solid #e5e7eb;
}

.redirect-continue {
    font-weight: 600;
    color: #2563eb;
}

/* Enhanced focus states for accessibility */
.auto-submit:focus + .answer-label,
.auto-submit:focus + .rating-label {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
    border-color: #2563eb;
}

/* Selection animations */
.answer-input:checked + .answer-label {
    animation: answer-select 0.3s ease-out;
}

.rating-input:checked + .rating-label {
    animation: rating-select 0.3s ease-out;
}

@keyframes answer-select {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes rating-select {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1.1);
    }
}

/* Question Actions - Only for text/textarea questions */
.textarea-actions {
    text-align: center;
    margin-top: 20px;
}

.btn-submit-text {
    min-width: 180px;
    font-size: 16px;
    padding: 14px 28px;
    letter-spacing: 0.025em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wp-dynamic-survey-question-interface {
        padding: 20px 15px;
    }

    .question-content {
        padding: 30px 24px;
        border-radius: 12px;
    }

    .question-title {
        font-size: 24px;
    }

    .question-description {
        font-size: 15px;
    }

    .boolean-options {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .boolean-label {
        min-height: 60px;
        font-size: 16px;
    }

    .rating-scale {
        gap: 12px;
    }

    .rating-label {
        width: 50px;
        height: 50px;
    }

    .rating-number {
        font-size: 18px;
    }

    .btn-next {
        width: 100%;
        min-width: auto;
    }

    .progress-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .survey-progress {
        padding: 0 15px;
    }
}

@media (max-width: 480px) {
    .question-content {
        padding: 15px 13px;
    }

    .question-title {
        font-size: 20px;
    }

    .answer-label {
        padding: 16px 20px;
        gap: 12px;
    }

    .rating-scale {
        gap: 8px;
    }

    .rating-label {
        width: 45px;
        height: 45px;
    }

    .rating-number {
        font-size: 16px;
    }

    .rating-labels {
        padding: 0 15px;
        font-size: 13px;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus Styles for Accessibility */
.wp-dynamic-survey-container *:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.answer-label:focus-within {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .answer-label {
        border-width: 3px;
    }

    .form-control {
        border-width: 3px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .progress-fill::after {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .wp-dynamic-survey-container {
        box-shadow: none;
        border: 1px solid #000;
    }

    .btn {
        display: none;
    }

    .loading-overlay {
        display: none;
    }
}