/**
 * Contact Form Styles - Theme Agnostic
 * Inherits styling from active WordPress theme
 *
 * @since 3.0.0
 */

/* CSS Variables - themes can override these */
:root {
    --dpemail-form-spacing: 1.5rem;
    --dpemail-field-spacing: 1rem;
}

/* Contact Form Wrapper - minimal styling, inherits from theme */
.dpemail-contact-form-wrapper {
    padding: 0;
}

/* Title inherits theme heading styles */
.dpemail-contact-form-wrapper h2,
.dpemail-contact-form-wrapper h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.dpemail-contact-form-wrapper p.form-description {
    margin-bottom: var(--dpemail-form-spacing);
}

/* Form Fields - inherit theme input styles */
.dpemail-contact-form {
    display: flex;
    flex-direction: column;
    gap: var(--dpemail-field-spacing);
}

.dpemail-field-group {
    display: flex;
    flex-direction: column;
}

.dpemail-field-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.dpemail-field-label .required {
    color: #d00;
    margin-left: 2px;
}

/* Input fields - inherit theme styles */
.dpemail-field-input,
.dpemail-field-textarea,
.dpemail-field-select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    font-family: inherit;
    border: 1px solid;
    border-color: inherit;
    border-radius: inherit;
    background-color: inherit;
    color: inherit;
}

/* Use browser default focus styles or theme's focus styles */
.dpemail-field-input:focus,
.dpemail-field-textarea:focus,
.dpemail-field-select:focus {
    outline-offset: 2px;
}

.dpemail-field-input.error,
.dpemail-field-textarea.error,
.dpemail-field-select.error {
    border-color: #d00;
}

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

.dpemail-field-error {
    display: none;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #d00;
}

.dpemail-field-error.show {
    display: block;
}

/* Two-column layout for name fields */
.dpemail-name-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--dpemail-field-spacing);
}

@media (max-width: 600px) {
    .dpemail-name-row {
        grid-template-columns: 1fr;
    }
}

/* Phone field with country code */
.dpemail-phone-row {
    display: flex;
    gap: 0.5rem;
}

.dpemail-phone-country {
    width: auto;
    min-width: 120px;
    flex-shrink: 0;
}

.dpemail-phone-input {
    flex: 1;
}

@media (max-width: 600px) {
    .dpemail-phone-row {
        flex-direction: column;
    }

    .dpemail-phone-country {
        width: 100%;
    }
}

/* Checkbox field */
.dpemail-checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.dpemail-checkbox-input {
    margin-top: 0.25rem;
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
}

.dpemail-checkbox-label {
    font-size: 0.875rem;
    cursor: pointer;
    line-height: 1.5;
}

/* Turnstile container */
.dpemail-turnstile-container {
    margin: var(--dpemail-field-spacing) 0;
}

/* Submit button - visual styling comes from wp-block-button__link (Gutenberg theme styles) */
/* dpemail-submit-btn is a JS hook only; no visual properties set here */

.dpemail-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.dpemail-submit-btn .btn-text,
.dpemail-submit-btn .dpemail-btn-text {
    display: inline-block;
}

.dpemail-submit-btn .btn-loading,
.dpemail-submit-btn .dpemail-btn-loading {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.dpemail-submit-btn.loading .btn-text,
.dpemail-submit-btn.loading .dpemail-btn-text {
    display: none;
}

.dpemail-submit-btn.loading .btn-loading,
.dpemail-submit-btn.loading .dpemail-btn-loading {
    display: inline-flex;
}

/* Loading spinner */
.dpemail-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: dpemail-spin 0.6s linear infinite;
}

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

/* Messages */
.dpemail-form-messages {
    margin-top: var(--dpemail-form-spacing);
}

.dpemail-message {
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.9375rem;
    line-height: 1.5;
    display: none;
    border-left: 4px solid;
}

.dpemail-message.show {
    display: block;
    animation: dpemail-slideDown 0.3s ease;
}

@keyframes dpemail-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dpemail-message.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.dpemail-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.dpemail-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-color: #17a2b8;
}

/* Privacy notice */
.dpemail-privacy-notice {
    margin-top: var(--dpemail-field-spacing);
    padding: 1rem;
    font-size: 0.8125rem;
    opacity: 0.8;
    border-radius: 4px;
}

.dpemail-privacy-notice a {
    text-decoration: underline;
}

/* Responsive styles */
@media (max-width: 768px) {
    .dpemail-contact-form-wrapper {
        margin: 1rem auto;
    }

    .dpemail-field-input,
    .dpemail-field-textarea,
    .dpemail-field-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }

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

/* Accessibility improvements */
.dpemail-field-input:focus-visible,
.dpemail-field-textarea:focus-visible,
.dpemail-field-select:focus-visible,
.dpemail-submit-btn:focus-visible {
    outline: 2px solid;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dpemail-field-input,
    .dpemail-field-textarea,
    .dpemail-field-select {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .dpemail-message {
        animation: none;
        transition: none;
    }

    .dpemail-spinner {
        animation: none;
    }
}

/* Print styles */
@media print {
    .dpemail-submit-btn,
    .dpemail-turnstile-container {
        display: none;
    }
}
