/**
 * Contact Form 7 Fixes and Enhancements
 * Fixes validation messages and form display issues
 */

/* ====================================================
   FORM STRUCTURE & LAYOUT
   ==================================================== */

/* Ensure proper form field layout */
.wpcf7-form .form-field {
    margin-bottom: 1.5rem;
    position: relative;
}

.wpcf7-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="tel"],
.wpcf7-form input[type="url"],
.wpcf7-form select,
.wpcf7-form textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fff;
}

/* Focus states */
.wpcf7-form input:focus,
.wpcf7-form select:focus,
.wpcf7-form textarea:focus {
    outline: none;
    border-color: #00b4d9;
    box-shadow: 0 0 0 3px rgba(0, 180, 217, 0.1);
}

/* Select dropdown specific styling */
.wpcf7-form select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 45px;
    cursor: pointer;
}

/* Required field indicator */
.wpcf7-form .wpcf7-validates-as-required {
    position: relative;
}

.wpcf7-form label abbr[title="required"] {
    color: #e74c3c;
    text-decoration: none;
    font-weight: bold;
    margin-left: 2px;
}

/* ====================================================
   VALIDATION MESSAGES
   ==================================================== */

/* Hide the default validation tip initially */
.wpcf7-form .wpcf7-not-valid-tip {
    display: block;
    color: #dc3545;
    font-size: 14px;
    margin-top: 5px;
    padding: 5px 10px;
    background-color: rgba(220, 53, 69, 0.1);
    border-left: 3px solid #dc3545;
    border-radius: 3px;
}

/* Invalid field styling */
.wpcf7-form .wpcf7-not-valid {
    border-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.05);
}

/* Response output messages */
.wpcf7-response-output {
    margin: 20px 0;
    padding: 15px 20px;
    border-radius: 4px;
    font-size: 16px;
    text-align: center;
    display: none;
}

/* Validation error message */
.wpcf7-validation-errors,
.wpcf7-form.invalid .wpcf7-response-output {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    display: block;
}

/* Success message */
.wpcf7-mail-sent-ok,
.wpcf7-form.sent .wpcf7-response-output {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    display: block;
}

/* Failed message */
.wpcf7-mail-sent-ng,
.wpcf7-form.failed .wpcf7-response-output {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    display: block;
}

/* Spam blocked message */
.wpcf7-spam-blocked {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    display: block;
}

/* ====================================================
   LOADING STATES
   ==================================================== */

/* Loading state for form */
.wpcf7-form.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.wpcf7-form.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 180, 217, 0.3);
    border-top-color: #00b4d9;
    border-radius: 50%;
    animation: cf7-spin 1s linear infinite;
}

@keyframes cf7-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Submit button loading state */
.wpcf7-form.loading .wpcf7-submit {
    position: relative;
    color: transparent;
}

.wpcf7-form.loading .wpcf7-submit::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: cf7-button-spin 0.8s linear infinite;
}

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

/* ====================================================
   SUBMIT BUTTON STYLING
   ==================================================== */

.wpcf7-form .wpcf7-submit {
    background-color: #00b4d9;
    color: white;
    border: none;
    padding: 14px 35px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    min-width: 150px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpcf7-form .wpcf7-submit:hover {
    background-color: #0099bd;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 180, 217, 0.3);
}

.wpcf7-form .wpcf7-submit:active {
    transform: translateY(0);
}

.wpcf7-form .wpcf7-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ====================================================
   CHECKBOX AND RADIO STYLING
   ==================================================== */

.wpcf7-form .wpcf7-checkbox,
.wpcf7-form .wpcf7-radio {
    margin: 10px 0;
}

.wpcf7-form .wpcf7-list-item {
    margin: 0 20px 10px 0;
    display: inline-block;
}

.wpcf7-form .wpcf7-list-item label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
}

.wpcf7-form .wpcf7-list-item input[type="checkbox"],
.wpcf7-form .wpcf7-list-item input[type="radio"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ====================================================
   ACCEPTANCE CHECKBOX
   ==================================================== */

.wpcf7-form .wpcf7-acceptance {
    margin: 20px 0;
}

.wpcf7-form .wpcf7-acceptance label {
    display: flex;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.5;
}

.wpcf7-form .wpcf7-acceptance input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* ====================================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ==================================================== */

@media (max-width: 768px) {
    .wpcf7-form input[type="text"],
    .wpcf7-form input[type="email"],
    .wpcf7-form input[type="tel"],
    .wpcf7-form input[type="url"],
    .wpcf7-form select,
    .wpcf7-form textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 15px;
    }
    
    .wpcf7-form .wpcf7-submit {
        width: 100%;
        padding: 16px;
        font-size: 18px;
    }
    
    .wpcf7-response-output {
        font-size: 14px;
        padding: 12px 15px;
    }
}

/* ====================================================
   ACCESSIBILITY ENHANCEMENTS
   ==================================================== */

/* Focus visible for keyboard navigation */
.wpcf7-form *:focus-visible {
    outline: 3px solid #00b4d9;
    outline-offset: 2px;
}

/* Screen reader only text */
.wpcf7-form .screen-reader-text {
    position: absolute;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0;
    border: 0;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wpcf7-form input,
    .wpcf7-form select,
    .wpcf7-form textarea {
        border-width: 2px;
    }
    
    .wpcf7-form .wpcf7-not-valid {
        border-width: 2px;
        border-style: solid;
    }
}

/* ====================================================
   QUICK QUOTE FORM SPECIFIC STYLING
   ==================================================== */

.quick-quote-form .wpcf7-form {
    background: rgba(255, 255, 255, 0.98);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.quick-quote-form .form-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.quick-quote-form .form-subtitle {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin-bottom: 25px;
}

/* Security notice */
.quick-quote-form .security-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.quick-quote-form .security-notice::before {
    content: "🔒";
    font-size: 16px;
}