/**
 * Form Frontend Styles
 *
 * @package ReviewPro
 * @since 1.1.0
 */

/* Form Container */
.reviewpro-form {
    background: var(--wp--preset--color--white, #fff);
    border: 1px solid var(--wp--preset--color--gray-200, #e5e7eb);
    border-radius: var(--wp--custom--border-radius--lg, 8px);
    padding: var(--wp--preset--spacing--6, 24px);
    margin: var(--wp--preset--spacing--5, 20px) 0;
}

/* Title */
.reviewpro-form__title {
    margin: 0 0 var(--wp--preset--spacing--4, 16px);
    font-size: var(--wp--preset--font-size--large, 1.25rem);
    font-weight: 600;
    color: var(--wp--preset--color--contrast, #1f2937);
    line-height: 1.3;
}

/* Description */
.reviewpro-form__description {
    margin: 0 0 var(--wp--preset--spacing--5, 20px);
    color: var(--wp--preset--color--gray-600, #6b7280);
    font-size: var(--wp--preset--font-size--medium, 0.9375rem);
    line-height: 1.6;
}

.reviewpro-form__description p {
    margin: 0 0 var(--wp--preset--spacing--3, 12px);
}

.reviewpro-form__description p:last-child {
    margin-bottom: 0;
}

/* Form Fields */
.reviewpro-form__field {
    margin-bottom: var(--wp--preset--spacing--4, 16px);
}

.reviewpro-form__field label {
    display: block;
    margin-bottom: var(--wp--preset--spacing--2, 8px);
    font-weight: 500;
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    color: var(--wp--preset--color--contrast, #1f2937);
}

/* Input Styles */
.reviewpro-form__field input[type="text"],
.reviewpro-form__field input[type="email"],
.reviewpro-form__field input[type="tel"],
.reviewpro-form__field input[type="number"],
.reviewpro-form__field input[type="url"],
.reviewpro-form__field select,
.reviewpro-form__field textarea {
    width: 100%;
    padding: var(--wp--preset--spacing--3, 12px) var(--wp--preset--spacing--4, 16px);
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    font-family: inherit;
    line-height: 1.5;
    color: var(--wp--preset--color--contrast, #1f2937);
    background: var(--wp--preset--color--white, #fff);
    border: 1px solid var(--wp--preset--color--gray-300, #d1d5db);
    border-radius: var(--wp--custom--border-radius--md, 6px);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    box-sizing: border-box;
}

.reviewpro-form__field input[type="text"]:focus,
.reviewpro-form__field input[type="email"]:focus,
.reviewpro-form__field input[type="tel"]:focus,
.reviewpro-form__field input[type="number"]:focus,
.reviewpro-form__field input[type="url"]:focus,
.reviewpro-form__field select:focus,
.reviewpro-form__field textarea:focus {
    outline: none;
    border-color: var(--wp--preset--color--primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.reviewpro-form__field input::placeholder,
.reviewpro-form__field textarea::placeholder {
    color: var(--wp--preset--color--gray-400, #9ca3af);
}

/* Textarea specific */
.reviewpro-form__field textarea {
    resize: vertical;
    min-height: 120px;
}

/* Select specific */
.reviewpro-form__field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
    padding-right: 40px;
    cursor: pointer;
}

/* Checkbox field */
.reviewpro-form__field--checkbox label {
    display: flex;
    align-items: flex-start;
    gap: var(--wp--preset--spacing--3, 12px);
    font-weight: normal;
    cursor: pointer;
    margin-bottom: 0;
}

.reviewpro-form__field--checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--wp--preset--color--primary, #6366f1);
    cursor: pointer;
}

/* Radio Group */
.reviewpro-form__radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--wp--preset--spacing--2, 8px);
}

.reviewpro-form__radio-group label {
    display: flex;
    align-items: center;
    gap: var(--wp--preset--spacing--3, 12px);
    font-weight: normal;
    cursor: pointer;
    padding: var(--wp--preset--spacing--2, 8px) var(--wp--preset--spacing--3, 12px);
    background: var(--wp--preset--color--gray-50, #f9fafb);
    border-radius: var(--wp--custom--border-radius--sm, 4px);
    border: 1px solid var(--wp--preset--color--gray-200, #e5e7eb);
    transition: background-color 0.15s, border-color 0.15s;
    margin-bottom: 0;
}

.reviewpro-form__radio-group label:hover {
    background: var(--wp--preset--color--gray-100, #f3f4f6);
}

.reviewpro-form__radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--wp--preset--color--primary, #6366f1);
    cursor: pointer;
}

/* Submit Button */
.reviewpro-form__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--wp--preset--spacing--2, 8px);
    padding: var(--wp--preset--spacing--3, 12px) var(--wp--preset--spacing--6, 24px);
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    color: var(--wp--preset--color--white, #fff);
    background: var(--wp--preset--color--primary, #6366f1);
    border: none;
    border-radius: var(--wp--custom--border-radius--md, 6px);
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    margin-top: var(--wp--preset--spacing--2, 8px);
}

.reviewpro-form__submit:hover {
    background: var(--wp--preset--color--primary-dark, #4f46e5);
    transform: translateY(-1px);
}

.reviewpro-form__submit:active {
    transform: translateY(0);
}

.reviewpro-form__submit:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

/* Loading State */
.reviewpro-form__form.is-loading .reviewpro-form__submit {
    opacity: 0.7;
    pointer-events: none;
    cursor: not-allowed;
}

.reviewpro-form__form.is-loading .reviewpro-form__submit::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: reviewpro-form-spinner 0.6s linear infinite;
}

@keyframes reviewpro-form-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Feedback Messages */
.reviewpro-form__feedback {
    margin-top: var(--wp--preset--spacing--4, 16px);
    padding: var(--wp--preset--spacing--3, 12px) var(--wp--preset--spacing--4, 16px);
    font-size: var(--wp--preset--font-size--small, 0.875rem);
    line-height: 1.5;
    border-radius: var(--wp--custom--border-radius--md, 6px);
    display: none;
}

.reviewpro-form__feedback--success,
.reviewpro-form__feedback--error {
    display: block;
}

.reviewpro-form__feedback--success {
    color: var(--wp--preset--color--success-dark, #166534);
    background: var(--wp--preset--color--success-light, #dcfce7);
    border: 1px solid var(--wp--preset--color--success, #22c55e);
}

.reviewpro-form__feedback--error {
    color: var(--wp--preset--color--error-dark, #991b1b);
    background: var(--wp--preset--color--error-light, #fef2f2);
    border: 1px solid var(--wp--preset--color--error, #ef4444);
}

/* Required Field Indicator */
.reviewpro-form__field label .required,
.reviewpro-form__field--checkbox label .required {
    color: var(--wp--preset--color--error, #ef4444);
    margin-left: 2px;
}

/* Validation States */
.reviewpro-form__field input:invalid:not(:placeholder-shown),
.reviewpro-form__field textarea:invalid:not(:placeholder-shown),
.reviewpro-form__field select:invalid:not(:placeholder-shown) {
    border-color: var(--wp--preset--color--error, #ef4444);
}

.reviewpro-form__field input:invalid:not(:placeholder-shown):focus,
.reviewpro-form__field textarea:invalid:not(:placeholder-shown):focus,
.reviewpro-form__field select:invalid:not(:placeholder-shown):focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Disabled State */
.reviewpro-form__field input:disabled,
.reviewpro-form__field textarea:disabled,
.reviewpro-form__field select:disabled {
    background: var(--wp--preset--color--gray-100, #f3f4f6);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Block Wrapper */
.wp-block-reviewpro-form {
    margin: var(--wp--preset--spacing--5, 20px) 0;
}

.wp-block-reviewpro-form .reviewpro-form {
    margin: 0;
}

/* Alignment */
.wp-block-reviewpro-form.alignwide,
.wp-block-reviewpro-form.alignfull {
    max-width: none;
}

.wp-block-reviewpro-form.alignwide .reviewpro-form {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.wp-block-reviewpro-form.alignfull .reviewpro-form {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive */
@media (max-width: 600px) {
    .reviewpro-form {
        padding: var(--wp--preset--spacing--5, 20px);
    }

    .reviewpro-form__title {
        font-size: var(--wp--preset--font-size--medium, 1.125rem);
    }

    .reviewpro-form__field input[type="text"],
    .reviewpro-form__field input[type="email"],
    .reviewpro-form__field input[type="tel"],
    .reviewpro-form__field input[type="number"],
    .reviewpro-form__field input[type="url"],
    .reviewpro-form__field select,
    .reviewpro-form__field textarea {
        padding: var(--wp--preset--spacing--3, 12px);
    }

    .reviewpro-form__submit {
        width: 100%;
    }

    .reviewpro-form__radio-group {
        gap: var(--wp--preset--spacing--2, 8px);
    }
}
