/* ===== Contact / Newsletter Form plugin =====
   All selectors scoped under [data-cb-type="contact-form"] so nothing leaks.
   Colors run through CSS variables so dark mode is just a variable override
   (auto-applied when a `.dark` ancestor is present, e.g. body.dark). */
[data-cb-type="contact-form"] {
    position: relative;
    width: 100%;
    --cf-accent: #3b82f6;
    --cf-accent-soft: color-mix(in srgb, var(--cf-accent) 12%, transparent);
    --cf-surface: #fff;          /* input/textarea background */
    --cf-border: #d1d5db;
    --cf-text: #1f2937;
    --cf-muted: #6b7280;
    --cf-placeholder: #9ca3af;
    --cf-success: #15803d;
    --cf-error: #b91c1c;
}

/* ── Dark mode (opt-in — commented out) ───────────────────────────────────
   Dark mode for a rendered block is the SITE's responsibility, not the plugin's.
   Every color above is a CSS variable, so to enable dark mode you only need to
   redefine the palette below under whatever trigger your site uses — a class,
   [data-theme="dark"], @media (prefers-color-scheme: dark), etc. Uncomment and
   change the selector to match your site's theme system.
   NOTE: `.dark` is also the ContentBuilder editor's own UI theme, so on a page
   that runs the editor, prefer a different class here to avoid the editor
   repainting your content while you edit.

.dark [data-cb-type="contact-form"] {
    --cf-surface: #1e1e1e;
    --cf-border: #3a3a3a;
    --cf-text: #f3f4f6;
    --cf-muted: #9ca3af;
    --cf-placeholder: #6b7280;
    --cf-success: #4ade80;
    --cf-error: #f87171;
}
*/

[data-cb-type="contact-form"] .cf-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 560px;
}

[data-cb-type="contact-form"] .cf-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* A field = label text stacked above its control */
[data-cb-type="contact-form"] .cf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

[data-cb-type="contact-form"] .cf-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--cf-text);
}

[data-cb-type="contact-form"] .cf-req {
    color: var(--cf-accent);
}

[data-cb-type="contact-form"] .cf-field input,
[data-cb-type="contact-form"] .cf-field textarea {
    width: 100%;
    font: inherit;
    font-size: 15px;
    color: var(--cf-text);
    padding: 11px 13px;
    background: var(--cf-surface);
    border: 1px solid var(--cf-border);
    border-radius: 9px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-cb-type="contact-form"] .cf-field textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}

[data-cb-type="contact-form"] .cf-field input::placeholder,
[data-cb-type="contact-form"] .cf-field textarea::placeholder {
    color: var(--cf-placeholder);
}

[data-cb-type="contact-form"] .cf-field input:focus,
[data-cb-type="contact-form"] .cf-field textarea:focus {
    outline: none;
    border-color: var(--cf-accent);
    box-shadow: 0 0 0 3px var(--cf-accent-soft);
}

/* Consent-style checkbox field: control + text on one row */
[data-cb-type="contact-form"] .cf-field.cf-check {
    flex-direction: row;
    align-items: center;
    gap: 9px;
}

[data-cb-type="contact-form"] .cf-field.cf-check input {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--cf-accent);
}

[data-cb-type="contact-form"] .cf-field.cf-check .cf-label {
    font-weight: 400;
    font-size: 14px;
    color: var(--cf-muted);
}

/* Submit button */
[data-cb-type="contact-form"] .cf-submit {
    align-self: flex-start;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: var(--cf-accent);
    border: none;
    border-radius: 9px;
    padding: 12px 24px;
    cursor: pointer;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

[data-cb-type="contact-form"] .cf-submit:hover {
    filter: brightness(0.94);
}

[data-cb-type="contact-form"] .cf-submit:disabled {
    opacity: 0.65;
    cursor: default;
}

[data-cb-type="contact-form"] .cf-submit:focus-visible {
    outline: 2px solid var(--cf-accent);
    outline-offset: 2px;
}

/* Status message */
[data-cb-type="contact-form"] .cf-status {
    margin: 0;
    font-size: 14px;
    min-height: 1em;
}

[data-cb-type="contact-form"] .cf-status:empty {
    display: none;
}

[data-cb-type="contact-form"] .cf-status.is-success {
    color: var(--cf-success);
}

[data-cb-type="contact-form"] .cf-status.is-error {
    color: var(--cf-error);
}

/* Responsive */
@media (max-width: 600px) {
    [data-cb-type="contact-form"] .cf-submit {
        align-self: stretch;
        text-align: center;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    [data-cb-type="contact-form"] .cf-field input,
    [data-cb-type="contact-form"] .cf-field textarea,
    [data-cb-type="contact-form"] .cf-submit {
        transition: none !important;
    }
}

/* High contrast */
@media (prefers-contrast: high) {
    [data-cb-type="contact-form"] .cf-field input,
    [data-cb-type="contact-form"] .cf-field textarea {
        border: 2px solid currentColor;
    }
}
