/*
 * Custom fields - the inputs on the product / customer / vendor / order / purchase order forms (.fmcf)
 * and the designer in Options > Global > Custom fields (.fmcf-row ...).
 * Markup comes from includes/functions/custom_fields.php, behaviour from includes/scripts/ux/22-custom-fields.js.
 */

/* ---------- the inputs on a record form ---------- */
.fmcf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.fmcf-field { min-width: 0; }
.fmcf-field.fmcf-wide { grid-column: 1 / -1; }
.fmcf-field > label { display: block; margin: 0 0 4px; font-weight: 600; font-size: 13px; color: var(--fm-ink-2, #3a4560); }
.fmcf-req { color: var(--fm-danger, #b91c1c); margin-left: 3px; text-decoration: none; cursor: help; }
.fmcf-help { display: block; margin-top: 4px; font-size: 12px; line-height: 1.4; color: var(--fm-muted, #6b7689); }
.fmcf-checks { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.fmcf-check { display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 6px 11px; border: 1px solid var(--fm-line, #e4e8f0); border-radius: 999px; background: #fff; font-weight: 500; font-size: 13px; cursor: pointer; }
.fmcf-check:has(input:checked) { background: var(--fm-primary-50, #e9f6fd); border-color: var(--fm-primary-100, #c9e8f7); color: var(--fm-primary-600, #075985); }
.fmcf-check input { margin: 0; }
.fmcf .is-invalid, .fmcf-field.is-invalid .form-control { border-color: var(--fm-danger, #b91c1c); }
.fmcf-empty { color: var(--fm-muted, #6b7689); font-size: 13px; margin: 0 0 10px; }
@media (max-width: 640px) { .fmcf { grid-template-columns: 1fr; } }

/* ---------- the designer dialog ---------- */
#company_fm_custom_fields_Modal .modal-dialog { max-width: 760px; }
#company_fm_custom_fields_Modal .fm_custom_fields_list { margin-top: 18px !important; }
.fmcf-lead { color: var(--fm-muted, #6b7689); font-size: 13px; margin: 6px 0 0; }
.fmcf-rows { display: grid; gap: 10px; }
.fmcf-empty-state { text-align: center; padding: 26px 16px; border: 2px dashed var(--fm-primary-100, #c9e8f7); border-radius: 14px; background: var(--fm-primary-50, #e9f6fd); color: var(--fm-primary-600, #075985); }
.fmcf-empty-state b { display: block; font-size: 15px; margin-bottom: 4px; }

.fmcf-row { background: var(--fm-bg, #f2f7fb); border: 1px solid var(--fm-line-2, #eef1f6) !important; border-radius: 14px; padding: 10px 12px !important; margin: 0 !important; transition: box-shadow .15s, opacity .15s; }
.fmcf-row.is-dragging { opacity: .45; }
.fmcf-row.is-new { box-shadow: 0 0 0 2px var(--fm-accent, #0ea5e9); }
.fmcf-row-main { display: grid; grid-template-columns: 24px minmax(0, 1fr) 150px auto auto auto; gap: 8px; align-items: center; }
.fmcf-handle { cursor: grab; color: var(--fm-muted, #6b7689); text-align: center; padding: 8px 0; user-select: none; }
.fmcf-handle:active { cursor: grabbing; }
.fmcf-move { display: inline-flex; flex-direction: column; gap: 1px; }
.fmcf-move button, .fmcf-more { border: 1px solid var(--fm-line, #e4e8f0); background: #fff; color: var(--fm-ink-2, #3a4560); border-radius: 8px; width: 32px; height: 32px; line-height: 1; font-size: 12px; }
.fmcf-move button { height: 17px; border-radius: 5px; font-size: 9px; width: 28px; }
.fmcf-move button:hover, .fmcf-more:hover { background: var(--fm-primary-50, #e9f6fd); color: var(--fm-primary, #0369a1); }
.fmcf-more.is-on { color: var(--fm-primary, #0369a1); border-color: var(--fm-primary-100, #c9e8f7); background: var(--fm-primary-50, #e9f6fd); }
.fmcf-row-extra { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--fm-line, #e4e8f0); display: grid; gap: 10px; }
.fmcf-row-extra[hidden], .fmcf-opts[hidden] { display: none; }
.fmcf-row-extra label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.fmcf-row-extra label small { font-weight: 400; color: var(--fm-muted, #6b7689); }
.fmcf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fmcf-flags { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.fmcf-flags label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.fmcf-add { margin-top: 12px; }

@media (max-width: 640px) {
	.fmcf-row-main { grid-template-columns: 24px minmax(0, 1fr) auto auto; }
	.fmcf-row-main .fmcf-type { grid-column: 2 / 5; grid-row: 2; }
	.fmcf-two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .fmcf-row { transition: none; } }
