/**
 * CPR Contact Form Frontend Styles
 *
 * Styles for public-facing contact forms.
 *
 * @package CPR_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   Form Container
   ========================================================================== */

.cpr-contact-form-wrapper {
    max-width: 100%;
}

.cpr-contact-form {
    position: relative;
}

/* Honeypot field - visually hidden but accessible for screen readers */
.cpr-contact-form .cpr-hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* ==========================================================================
   Form Fields
   ========================================================================== */

.cpr-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.cpr-form-field {
    box-sizing: border-box;
}

/* Field widths */
.cpr-form-field.cpr-field-width-100 {
    width: 100%;
}

.cpr-form-field.cpr-field-width-50 {
    width: calc(50% - 7.5px);
}

.cpr-form-field.cpr-field-width-33 {
    width: calc(33.333% - 10px);
}

/* Labels */
.cpr-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
}

.cpr-form-field .cpr-required {
    color: #cc0000;
    margin-left: 2px;
}

/* Inputs */
.cpr-form-field input[type="text"],
.cpr-form-field input[type="email"],
.cpr-form-field input[type="tel"],
.cpr-form-field textarea,
.cpr-form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.cpr-form-field input:focus,
.cpr-form-field textarea:focus,
.cpr-form-field select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.cpr-form-field textarea {
    resize: vertical;
    min-height: 120px;
}

.cpr-form-field select {
    cursor: pointer;
    background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23333'%3E%3Cpath d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 35px;
}

/* Checkbox */
.cpr-form-field.cpr-field-checkbox {
    display: flex;
    align-items: flex-start;
}

.cpr-checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-weight: normal !important;
}

.cpr-checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    margin-top: 3px;
}

.cpr-checkbox-label span {
    line-height: 1.4;
}

/* Field errors */
.cpr-form-field.has-error input,
.cpr-form-field.has-error textarea,
.cpr-form-field.has-error select {
    border-color: #dc3232;
}

.cpr-field-error {
    display: none;
    color: #dc3232;
    font-size: 12px;
    margin-top: 5px;
}

.cpr-form-field.has-error .cpr-field-error {
    display: block;
}

/* ==========================================================================
   Submit Button
   ========================================================================== */

.cpr-form-submit {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cpr-submit-button {
    display: inline-block;
    padding: 12px 30px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.cpr-submit-button:hover {
    opacity: 0.9;
}

.cpr-submit-button:active {
    transform: translateY(1px);
}

.cpr-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Spinner */
.cpr-form-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: cpr-spin 0.8s linear infinite;
}

.cpr-form-submit.is-loading .cpr-form-spinner {
    display: block;
}

.cpr-form-submit.is-loading .cpr-submit-button {
    opacity: 0.6;
    pointer-events: none;
}

@keyframes cpr-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Messages
   ========================================================================== */

.cpr-form-messages {
    margin-top: 20px;
}

.cpr-form-success,
.cpr-form-error {
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 14px;
}

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

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 600px) {
    .cpr-form-field.cpr-field-width-50,
    .cpr-form-field.cpr-field-width-33 {
        width: 100%;
    }

    .cpr-submit-button {
        width: 100%;
    }

    .cpr-form-submit {
        flex-direction: column;
        align-items: stretch;
    }

    .cpr-form-spinner {
        align-self: center;
    }
}

/* ==========================================================================
   Dark Mode Support (if theme uses dark mode)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .cpr-contact-form {
        /* Colors can be overridden by inline styles from form builder */
    }
}
