/* WIT Form Builder - Frontend Styles */

/* Form Wrapper */
.wit-fb-form-wrapper {
    /* Center within the content column so the form lines up with the
       surrounding text blocks (themes constrain content width and center it). */
    margin: 20px auto;
    padding: 0;
    max-width: 100%;
}

.wit-fb-form-title {
    margin-bottom: 10px;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.wit-fb-form-description {
    margin-bottom: 20px;
    color: #666;
    line-height: 1.6;
}

/* Form Styles */
.wit-fb-form {
    background: #fff;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Field Wrapper */
.wit-fb-field-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.wit-fb-field-wrapper.wit-fb-field-hidden {
    display: none;
}

/* Field Label */
.wit-fb-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.wit-fb-required {
    color: #e74c3c;
    margin-left: 3px;
}

/* Input Fields. Radio and checkbox are excluded so they keep their natural
   small size instead of stretching to full width. */
.wit-fb-field:not(.wit-fb-radio):not(.wit-fb-checkbox),
.wit-fb-input,
.wit-fb-textarea,
.wit-fb-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #fff;
    box-sizing: border-box;
}

/* Radio / checkbox inputs: natural size, sit inline with their label text. */
.wit-fb-radio,
.wit-fb-checkbox {
    width: auto;
    padding: 0;
    border: none;
    box-shadow: none;
}

.wit-fb-field:focus,
.wit-fb-input:focus,
.wit-fb-textarea:focus,
.wit-fb-select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

/* Textarea */
.wit-fb-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select */
.wit-fb-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

/* Checkbox and Radio Groups */
.wit-fb-checkbox-group,
.wit-fb-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wit-fb-checkbox-label,
.wit-fb-radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.wit-fb-checkbox,
.wit-fb-radio {
    margin-right: 8px;
    cursor: pointer;
}

/* File Upload */
.wit-fb-file {
    padding: 8px 12px;
    cursor: pointer;
}

.wit-fb-file::-webkit-file-upload-button {
    padding: 6px 12px;
    background: #2271b1;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 10px;
}

.wit-fb-file::-webkit-file-upload-button:hover {
    background: #1a5490;
}

/* HTML Content */
.wit-fb-html-content {
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Error Messages */
.wit-fb-field-error {
    color: #e74c3c;
    font-size: 13px;
    margin-top: 5px;
    display: none;
}

.wit-fb-field-wrapper.has-error .wit-fb-field,
.wit-fb-field-wrapper.has-error .wit-fb-input,
.wit-fb-field-wrapper.has-error .wit-fb-textarea,
.wit-fb-field-wrapper.has-error .wit-fb-select {
    border-color: #e74c3c;
}

.wit-fb-field-wrapper.has-error .wit-fb-field-error {
    display: block;
}

/* Form Messages */
.wit-fb-form-messages {
    margin: 20px 0;
    padding: 15px;
    border-radius: 4px;
    display: none;
}

.wit-fb-form-messages.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.wit-fb-form-messages.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.wit-fb-form-messages.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

/* Submit Button */
.wit-fb-form-submit {
    margin-top: 25px;
}

.wit-fb-submit-button {
    background: #2271b1;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
    display: inline-block;
}

.wit-fb-submit-button:hover {
    background: #1a5490;
}

.wit-fb-submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.wit-fb-submit-button.loading {
    position: relative;
    color: transparent;
}

.wit-fb-submit-button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: wit-fb-spinner 0.6s linear infinite;
}

@keyframes wit-fb-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Honeypot Field (Hidden) */
.wit-fb-hp-field {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    visibility: hidden !important;
}

/* Conditional Logic Hidden Fields */
.wit-fb-field-wrapper[data-conditional-hidden="true"] {
    display: none !important;
}

/* Validation States */
.wit-fb-field.valid {
    border-color: #28a745;
}

.wit-fb-field.invalid {
    border-color: #e74c3c;
}

/* Placeholder Styles */
.wit-fb-field::placeholder,
.wit-fb-input::placeholder,
.wit-fb-textarea::placeholder {
    color: #999;
    opacity: 1;
}

/* Focus Styles */
.wit-fb-field:focus,
.wit-fb-input:focus,
.wit-fb-textarea:focus,
.wit-fb-select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

/* Responsive Design */
@media screen and (max-width: 600px) {
    .wit-fb-form {
        padding: 15px;
    }
    
    .wit-fb-field-wrapper {
        margin-bottom: 15px;
    }
    
    .wit-fb-submit-button {
        width: 100%;
        padding: 14px;
    }
    
    .wit-fb-checkbox-group,
    .wit-fb-radio-group {
        gap: 12px;
    }
}

/* Accessibility */
.wit-fb-field:focus-visible,
.wit-fb-input:focus-visible,
.wit-fb-textarea:focus-visible,
.wit-fb-select:focus-visible,
.wit-fb-checkbox:focus-visible,
.wit-fb-radio:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .wit-fb-form-submit {
        display: none;
    }
    
    .wit-fb-form {
        border: none;
        padding: 0;
    }
}

/* Custom Scrollbar for Textarea */
.wit-fb-textarea::-webkit-scrollbar {
    width: 8px;
}

.wit-fb-textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.wit-fb-textarea::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.wit-fb-textarea::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Success Animation */
@keyframes wit-fb-success {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.wit-fb-form-messages.success {
    animation: wit-fb-success 0.4s ease-out;
}

/* Field Required Indicator Animation */
.wit-fb-required {
    display: inline-block;
    animation: wit-fb-pulse 2s infinite;
}

@keyframes wit-fb-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
