/* The custom fields of a contact route: a tinted panel with the mapped fields, and the modal that pairs them.
   The source side is drawn in the brand blue, the target side in teal, the panel in the contact colour. */

.cfmap, .cf-modal { --cf-src: var(--brand-text); --cf-tgt: var(--accent-teal); --cf-accent: var(--rt-contact); }

.cf-panel {
  margin-top: 20px; padding: 16px 18px 14px;
  border: 1px solid color-mix(in srgb, var(--cf-accent) 22%, var(--line));
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--cf-accent) 9%, transparent) 0%, transparent 55%),
    linear-gradient(135deg, color-mix(in srgb, var(--cf-src) 5%, var(--panel)) 0%, color-mix(in srgb, var(--cf-tgt) 5%, var(--panel)) 100%);
}

.cf-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cf-head-text { flex: 1 1 260px; min-width: 0; }
.cf-head-text b { display: block; font-size: var(--fs-m); font-weight: 600; color: var(--ink); }
.cf-head-text span { font-size: var(--fs-s); color: var(--ink-3); }
.cf-flow { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.cf-head > .btn { flex: none; }

/* The arrow between two fields: both ways or one way, in a small brand badge. */
.cf-arrow {
  display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 999px;
  font-size: var(--fs-s); font-weight: 700; line-height: 1;
  color: var(--brand-text); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-line);
}

/* A field name, tinted for its side. */
.cf-chip {
  --tone: var(--cf-src);
  display: inline-flex; align-items: center; max-width: 100%; min-width: 0; padding: 4px 10px; border-radius: 999px;
  font-size: var(--fs-s); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere;
  color: color-mix(in srgb, var(--tone) 88%, var(--ink)); background: color-mix(in srgb, var(--tone) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 24%, transparent);
}
.cf-chip.tgt { --tone: var(--cf-tgt); }
.cf-chip.ghost { color: var(--ink-4); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

.cf-table { background: var(--panel); border-radius: var(--r-m); }
table.data.fieldtable tr.fieldgroup[data-group="custom"] td { --tone: var(--rt-contact); }
.cf-notes-cell { white-space: normal; }
.cf-notes-cell .pill { margin: 2px 0 2px 6px; }

.cf-empty {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 1px dashed color-mix(in srgb, var(--cf-accent) 35%, var(--line)); border-radius: var(--r-m);
  background: color-mix(in srgb, var(--panel) 75%, transparent); font-size: var(--fs-s); color: var(--ink-3);
}
.cf-empty[hidden] { display: none; }
.cf-empty b { color: var(--ink); font-weight: 600; }
.cf-empty-ic {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--r-m);
  color: var(--cf-accent); background: color-mix(in srgb, var(--cf-accent) 12%, transparent);
}
.cf-empty-ic svg { width: 17px; height: 17px; }

/* ---------- The modal ---------- */
.cf-modal.planmodal { width: min(960px, calc(100vw - 32px)); }
.cf-modal .pm-head {
  align-items: center;
  background:
    radial-gradient(90% 160% at 0% 0%, color-mix(in srgb, var(--cf-accent) 14%, transparent) 0%, transparent 60%),
    linear-gradient(120deg, color-mix(in srgb, var(--cf-src) 9%, var(--panel)) 0%, color-mix(in srgb, var(--cf-tgt) 8%, var(--panel)) 100%);
}
.cf-modal-ic {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--r-l);
  color: var(--on-brand); background: var(--brand-grad-fill); box-shadow: 0 8px 18px -10px var(--brand);
}
.cf-modal-ic svg { width: 19px; height: 19px; }
.cf-modal-title { flex: 1; min-width: 0; }

.cf-label {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--ink-3);
}
.cf-count { padding: 1px 8px; border-radius: 999px; font-weight: 600; letter-spacing: 0; color: var(--brand-text); background: var(--brand-soft); }

.cf-mapped { margin-bottom: 20px; }
.cf-pairs { display: grid; gap: 8px; margin-bottom: 8px; }
.cf-pairs:empty { display: none; margin: 0; }
.cf-pair {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-left: 3px solid var(--cf-accent);
  border-radius: var(--r-m); background: var(--panel); box-shadow: var(--sh-xs);
}
.cf-pair-text { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.cf-notes { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.cf-remove {
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-m); cursor: pointer;
  color: var(--bad); background: var(--bad-soft); transition: background .15s ease, color .15s ease;
}
.cf-remove:hover { color: var(--on-bad); background: var(--bad); }
.cf-remove svg { width: 15px; height: 15px; }

.cf-add { padding-top: 16px; border-top: 1px solid var(--line-soft); }
.cf-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cf-col {
  --tone: var(--cf-src);
  min-width: 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--tone) 24%, var(--line)); border-radius: var(--r-l); background: var(--panel);
}
.cf-col.tgt { --tone: var(--cf-tgt); }
.cf-col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--tone) 18%, var(--line)); background: color-mix(in srgb, var(--tone) 9%, var(--panel));
}
.cf-col-word { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: color-mix(in srgb, var(--tone) 85%, var(--ink)); }
.cf-col-body { padding: 12px; }
.cf-search { width: 100%; margin-bottom: 10px; }

.cf-list { display: grid; gap: 4px; min-height: 120px; align-content: start; }
.cf-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--r-m); background: none; transition: background .15s ease, border-color .15s ease;
}
.cf-row:hover { background: color-mix(in srgb, var(--tone) 6%, transparent); }
.cf-row.on { border-color: color-mix(in srgb, var(--tone) 45%, transparent); background: color-mix(in srgb, var(--tone) 11%, transparent); }
.cf-tick {
  display: grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--panel); transition: background .15s ease, border-color .15s ease;
}
.cf-row.on .cf-tick { border-color: var(--tone); background: var(--tone); }
.cf-row.on .cf-tick::after { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--panel); }
.cf-row-text { display: grid; flex: 1; min-width: 0; }
.cf-name { font-size: var(--fs-s); font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.cf-type { font-size: var(--fs-2xs); color: var(--ink-4); }
.cf-none { padding: 10px; }

.cf-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.cf-pager .btn svg { width: 15px; height: 15px; }

.cf-add-row {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; padding: 10px 12px;
  border-radius: var(--r-m); background: var(--panel-2);
}
.cf-picked { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }

.cf-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }

@media (max-width: 720px) {
  .cf-panel { padding: 14px; }
  .cf-flow { display: none; }
  .cf-head > .btn { width: 100%; justify-content: center; }
  .cf-cols { grid-template-columns: 1fr; }
  .cf-pair { grid-template-columns: minmax(0, 1fr) auto; }
  .cf-notes { grid-column: 1 / -1; justify-content: flex-start; }
}
