/**
 * ThemeBuilder Contact Form Styles
 * Version: 2.0.0
 */

.tbcf-contact-form-wrapper {
    /* Styling (background, padding, shadow) handled by theme's .contact-form-wrapper */
}

.tbcf-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

.tbcf-form fieldset {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tbcf-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.tbcf-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tbcf-form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.tbcf-form-group label .required {
    color: #dc3545;
}

.tbcf-form-group input[type="text"],
.tbcf-form-group input[type="email"],
.tbcf-form-group textarea {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    background: #f8f9fa;
}

.tbcf-form-group input:focus,
.tbcf-form-group textarea:focus {
    border-color: #22baa0;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(34, 186, 160, 0.1);
}

.tbcf-form-group input:focus-visible,
.tbcf-form-group textarea:focus-visible {
    outline: 2px solid #22baa0;
    outline-offset: 2px;
}

.tbcf-form-group textarea {
    resize: vertical;
    min-height: 150px;
}

/* Field validation states */
.tbcf-form-group.tbcf-field-error input,
.tbcf-form-group.tbcf-field-error textarea {
    border-color: #dc3545;
    background: #fff;
}

.tbcf-form-group.tbcf-field-error input:focus,
.tbcf-form-group.tbcf-field-error textarea:focus {
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.1);
}

.tbcf-form-group.tbcf-field-valid input,
.tbcf-form-group.tbcf-field-valid textarea {
    border-color: #28a745;
    background: #fff;
}

.tbcf-form-group.tbcf-field-valid input:focus,
.tbcf-form-group.tbcf-field-valid textarea:focus {
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.1);
}

/* Inline field error messages */
.tbcf-field-error-msg {
    font-size: 0.85rem;
    color: #dc3545;
    min-height: 0;
    line-height: 1.3;
}

.tbcf-field-error-msg:empty {
    display: none;
}

/* Field meta row (error + counter side by side) */
.tbcf-field-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

/* Character counter */
.tbcf-char-counter {
    font-size: 0.8rem;
    color: #999;
    white-space: nowrap;
    margin-left: auto;
}

.tbcf-char-counter--warn {
    color: #dc3545;
    font-weight: 600;
}

/* Submit button */
.tbcf-submit-btn {
    background: #22baa0;
    color: #ffffff;
    border: none;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-start;
    position: relative;
}

.tbcf-submit-btn:hover {
    background: #1a9580;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 186, 160, 0.3);
}

.tbcf-submit-btn:active {
    transform: translateY(0);
}

.tbcf-submit-btn:focus-visible {
    outline: 2px solid #22baa0;
    outline-offset: 2px;
}

.tbcf-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Response messages */
.tbcf-response-message {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.tbcf-response-message.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Animated checkmark */
.tbcf-checkmark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.tbcf-checkmark__circle {
    stroke: #28a745;
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: tbcf-circle 0.6s ease-in-out forwards;
}

.tbcf-checkmark__check {
    stroke: #28a745;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: tbcf-check 0.3s 0.4s ease-in-out forwards;
}

@keyframes tbcf-circle {
    to { stroke-dashoffset: 0; }
}

@keyframes tbcf-check {
    to { stroke-dashoffset: 0; }
}

.tbcf-response-message.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.tbcf-response-message:focus {
    outline: none;
}

.tbcf-response-message.tbcf-fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Loading spinner */
.tbcf-btn-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tbcf-spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Loading overlay on form during submission */
.tbcf-form.tbcf-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    z-index: 10;
    pointer-events: none;
}

/* Noscript fallback notice */
.tbcf-noscript-notice {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #664d03;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.tbcf-noscript-notice a {
    color: #664d03;
    font-weight: 600;
}

/* Screen reader text utility (used for honeypot and legends) */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tbcf-contact-form-wrapper {
        padding: 30px 20px;
    }

    .tbcf-form-row {
        grid-template-columns: 1fr;
    }

    .tbcf-submit-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .tbcf-contact-form-wrapper {
        padding: 25px 15px;
    }

    .tbcf-form-group input,
    .tbcf-form-group textarea {
        padding: 14px 16px;
        font-size: 0.95rem;
    }
}
