/**
 * Infineural CRM — Frontend Forms CSS
 * Theme-adaptive styling: inherits theme font, supports light/dark/system.
 * Uses CSS custom properties so it blends with any WordPress theme.
 */

/* ── CSS Variables (Adaptive defaults to match WP theme) ──────────────────── */
.infcrm-form-wrapper {
    --ifcrm-bg:          transparent;
    --ifcrm-bg-input:    rgba(127, 127, 127, 0.06);
    --ifcrm-border:      rgba(127, 127, 127, 0.3);
    --ifcrm-border-focus:#6366f1;
    --ifcrm-text:        currentColor;
    --ifcrm-text-muted:  inherit;
    --ifcrm-label:       currentColor;
    --ifcrm-primary:     #6366f1;
    --ifcrm-primary-hover:#4f46e5;
    --ifcrm-required:    #ef4444;
    --ifcrm-radius:      8px;
    --ifcrm-shadow:      none;
    --ifcrm-shadow-focus:0 0 0 3px rgba(99,102,241,0.2);
    --ifcrm-font:        inherit;
}

/* ── Explicit Theme Overrides ───────────────────────────────────────────────
   These apply if a theme uses common dark classes or if explicitly requested */
[data-theme="dark"] .infcrm-form-wrapper,
.dark .infcrm-form-wrapper,
.theme-dark .infcrm-form-wrapper,
.infcrm-form-wrapper.infcrm-theme-dark {
    --ifcrm-bg:         #1c1c28;
    --ifcrm-bg-input:   #16161f;
    --ifcrm-border:     rgba(255,255,255,0.1);
    --ifcrm-text:       #f1f5f9;
    --ifcrm-text-muted: #94a3b8;
    --ifcrm-label:      #cbd5e1;
    --ifcrm-shadow:     0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="light"] .infcrm-form-wrapper,
.infcrm-form-wrapper.infcrm-theme-light {
    --ifcrm-bg:         #ffffff;
    --ifcrm-bg-input:   #f9fafb;
    --ifcrm-border:     #d1d5db;
    --ifcrm-text:       #111827;
    --ifcrm-text-muted: #6b7280;
    --ifcrm-label:      #374151;
    --ifcrm-shadow:     0 1px 3px rgba(0,0,0,0.08);
}

/* ── Form Wrapper ─────────────────────────────────────────────────────────── */
.infcrm-form-wrapper {
    max-width: 640px;
    margin: 24px auto;
    padding: 32px;
    font-family: var(--ifcrm-font);
    background: var(--ifcrm-bg);
    border: 1px solid var(--ifcrm-border);
    border-radius: calc(var(--ifcrm-radius) * 1.5);
    box-shadow: var(--ifcrm-shadow);
    color: var(--ifcrm-text);
    box-sizing: border-box;
}

/* ── Fields Layout ────────────────────────────────────────────────────────── */
.infcrm-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.infcrm-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.infcrm-width-full  { width: 100%; }
.infcrm-width-half  { width: calc(50% - 8px); }
.infcrm-width-third { width: calc(33.333% - 11px); }

@media (max-width: 560px) {
    .infcrm-form-wrapper { padding: 20px 16px; }
    .infcrm-width-half,
    .infcrm-width-third { width: 100%; }
}

/* ── Labels ───────────────────────────────────────────────────────────────── */
.infcrm-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ifcrm-label);
    display: block;
    letter-spacing: 0.01em;
}

.infcrm-required { color: var(--ifcrm-required); margin-left: 2px; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.infcrm-input,
.infcrm-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9375rem;
    font-family: var(--ifcrm-font);
    border: 1.5px solid var(--ifcrm-border);
    border-radius: var(--ifcrm-radius);
    background-color: var(--ifcrm-bg-input);
    color: var(--ifcrm-text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.infcrm-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.infcrm-input:focus,
.infcrm-select:focus {
    outline: none;
    border-color: var(--ifcrm-border-focus);
    box-shadow: var(--ifcrm-shadow-focus);
    background-color: var(--ifcrm-bg);
}

.infcrm-input::placeholder { color: var(--ifcrm-text-muted); opacity: 1; }

textarea.infcrm-input {
    min-height: 110px;
    resize: vertical;
    line-height: 1.6;
}

/* ── Radio & Checkbox ─────────────────────────────────────────────────────── */
.infcrm-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.infcrm-radio-label,
.infcrm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9375rem;
    color: var(--ifcrm-text);
    cursor: pointer;
    line-height: 1.4;
}

.infcrm-radio-label input,
.infcrm-checkbox-label input {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    accent-color: var(--ifcrm-primary);
    cursor: pointer;
}

/* ── Help Text ────────────────────────────────────────────────────────────── */
.infcrm-help-text {
    font-size: 0.8125rem;
    color: var(--ifcrm-text-muted);
    line-height: 1.5;
}

/* ── Submit Button ────────────────────────────────────────────────────────── */
.infcrm-form-submit { margin-top: 28px; }

.infcrm-btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--ifcrm-font);
    color: #ffffff;
    background: linear-gradient(135deg, var(--ifcrm-primary) 0%, var(--ifcrm-primary-hover) 100%);
    border: none;
    border-radius: var(--ifcrm-radius);
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.18s ease, transform 0.1s ease, box-shadow 0.18s ease;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.infcrm-btn-submit:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}

.infcrm-btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

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

/* ── Messaging ────────────────────────────────────────────────────────────── */
.infcrm-form-messaging {
    font-size: 0.9375rem;
    line-height: 1.6;
    border-radius: var(--ifcrm-radius);
    padding: 12px 16px;
    margin-top: 16px;
    display: none;
}
