/* LeadMagnet – Frontend Styles v3
 * Colours follow the active theme. Kadence palette variables are used when the theme
 * defines them (and the generic WordPress/theme.json ones next); otherwise the
 * fallbacks below apply. To brand it, override any --lm-* variable in your theme CSS. */
:root {
    --lm-accent:       var(--lm-accent-custom, var(--global-palette-btn-bg, var(--global-palette1, var(--wp--preset--color--primary, #0073aa))));
    --lm-accent-hover: var(--global-palette-btn-bg-hover, var(--global-palette2, #005f8a));
    --lm-accent-text:  var(--global-palette-btn, #fff);
    --lm-text:         var(--global-palette4, currentColor);
    --lm-heading:      var(--global-palette3, currentColor);
    --lm-muted:        var(--global-palette5, #666);
    --lm-surface:      var(--global-palette8, #f9f9f9);
    --lm-field-bg:     var(--global-palette9, #fff);
    --lm-border:       var(--global-palette7, #ddd);
    --lm-radius:       var(--lm-radius-custom, 6px);
}

.lm-widget, .lm-widget *, .lm-library, .lm-library *, .lm-lib-overlay, .lm-lib-overlay * { box-sizing: border-box; }
.lm-widget { color: var(--lm-text); line-height: 1.5; clear: both; }
.lm-widget p { margin-top: 0; }

.lm-widget { max-width: 520px; margin: 1.5rem auto; font-family: inherit; }
.lm-description { color: var(--lm-muted); margin-bottom: 1rem; }
.lm-guidance-link { margin-bottom: 1rem; }
.lm-guidance-link a { color: var(--lm-accent); text-decoration: none; font-weight: 500; }
.lm-guidance-link a:hover { text-decoration: underline; }

/* Form wrapper */
.lm-form-wrap { background: var(--lm-surface); border: 1px solid var(--lm-border); border-radius: calc(var(--lm-radius) + 2px); padding: 1.5rem; }
.lm-form-heading { margin: 0 0 1.2rem; font-size: 1.1rem; color: var(--lm-heading); }

/* Fields */
.lm-field { margin-bottom: 1rem; }
.lm-field label { display: block; font-weight: 600; margin-bottom: .3rem; color: var(--lm-heading); font-size: .9rem; }
.lm-req { color: #c00; }
.lm-optional { font-weight: 400; color: #888; font-size: .82rem; }

.lm-field input[type="text"],
.lm-field input[type="email"],
.lm-field input[type="tel"],
.lm-field input[type="number"],
.lm-field select,
.lm-field textarea {
    width: 100%; max-width: 100%; height: auto; min-height: 2.75rem; margin: 0; padding: .6rem .8rem; border: 1px solid var(--lm-border);
    background: var(--lm-field-bg); color: inherit; box-shadow: none;
    border-radius: var(--lm-radius); font-size: 1rem; line-height: 1.4; box-sizing: border-box;
    font-family: inherit; transition: border-color .2s;
}
.lm-field input:focus,
.lm-field select:focus,
.lm-field textarea:focus {
    outline: none; border-color: var(--lm-accent);
    box-shadow: 0 0 0 2px rgba(0,115,170,.15);
}
.lm-field textarea { resize: vertical; }

/* Checkbox fields */
.lm-field label.lm-checkbox-label, .lm-checkbox-label { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; font-weight: 400; }
.lm-checkbox-label input[type="checkbox"] { margin: 4px 0 0; flex-shrink: 0; width: auto; min-height: 0; height: auto; }

/* GDPR */
.lm-gdpr-field { background: var(--lm-field-bg); border: 1px solid var(--lm-border); border-radius: var(--lm-radius); padding: .8rem; }
.lm-gdpr-field label, .lm-gdpr-field label.lm-checkbox-label { font-weight: 400; font-size: .88rem; }
.lm-gdpr-field a { color: var(--lm-accent); }

/* Messages */
.lm-messages { margin-bottom: .75rem; font-size: .9rem; }
.lm-messages.lm-error-msg { color: #c00; }

/* Submit button */
.lm-submit-btn {
    display: block; width: 100%; margin: 0; padding: .75rem; background: var(--lm-accent);
    color: var(--lm-accent-text); border: none; border-radius: var(--lm-radius); font-size: 1rem; line-height: 1.4;
    font-weight: 600; cursor: pointer; transition: background .2s;
    text-transform: none; letter-spacing: normal; box-shadow: none; text-decoration: none;
}
.lm-submit-btn:hover, .lm-submit-btn:focus { background: var(--lm-accent-hover); color: var(--lm-accent-text); box-shadow: none; }
.lm-submit-btn:disabled { opacity: .6; cursor: not-allowed; }

/* Success state */
.lm-success-wrap {
    background: #eafaf1; border: 1px solid #a9dfbf;
    border-radius: 8px; padding: 1.5rem; text-align: center;
}
.lm-success-msg { font-size: 1.1rem; color: #1e8449; font-weight: 600; margin-bottom: .5rem; }
.lm-email-note { color: #555; font-size: .9rem; margin-bottom: 1rem; }
.lm-download-link {
    display: inline-block; padding: .6rem 1.2rem; background: #1e8449;
    color: #fff !important; border-radius: var(--lm-radius); text-decoration: none; font-weight: 600; line-height: 1.4;
}
.lm-download-link:hover { background: #196f3d; }

/* Error / expired */
.lm-error { color: #c00; }
.lm-expired { background: #fff3cd; border: 1px solid #ffc107; padding: .8rem 1rem; border-radius: 5px; color: #856404; }

/* ------------------------------------------------------------------ */
/* Promo code field                                                     */
/* ------------------------------------------------------------------ */
.lm-promo-field { margin-top: .25rem; }

.lm-promo-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lm-promo-row .lm-promo-input {
    flex: 1; min-width: 0;
    padding: .5rem .75rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .05em;
    transition: border-color .2s;
}

.lm-promo-row .lm-promo-input:focus {
    border-color: var(--lm-accent);
    outline: none;
}

.lm-promo-row .lm-promo-input[readonly] {
    background: #f6f6f6;
    color: #333;
}

.lm-promo-result {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.45;
}

.lm-promo-result.lm-promo-ok { color: #16a34a; }
.lm-promo-result.lm-promo-err { color: #dc2626; }

.lm-promo-remove {
    font-size: 12px;
    color: #888;
    text-decoration: underline;
    cursor: pointer;
    margin-left: 4px;
}

/* Paid notice in modal / form */
.lm-paid-notice {
    background: #faf5ff;
    border-left: 4px solid #7c3aed;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    color: #444;
    margin-bottom: 12px;
}

.lm-promo-row .lm-promo-apply-btn { flex: 0 0 auto; margin: 0; white-space: nowrap; }
.lm-widget .lm-promo-input { border-color: var(--lm-border); background: var(--lm-field-bg); }
.lm-widget .lm-promo-remove { color: var(--lm-muted); }
