/* ===== 撰写商务邮件 · 收件客户选择器 =====
   只在 #modal.mrp-active（即 customer-email 撰写框）内生效，避免影响线索开发信等其它撰写框。 */

/* 隐藏从 .mail-compose-fields 里挪出来的「收件人」label 占位
   （lead-email-compose.js 会按 label:first-child 删除它，必须仍是第一个子元素） */
#modal.mrp-active .mail-compose-fields > label.mrp-hidden { display: none !important; }
#modal.mrp-active .mail-compose-fields { grid-template-columns: minmax(0, 1fr) !important; }

/* 收件区改为单列：标题 → 选择器 → 状态行 */
#modal.mrp-active .mail-compose-recipient {
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: stretch !important;
  gap: 12px !important;
  padding: 18px 18px 14px !important;
}
#modal.mrp-active .mail-compose-recipient .mail-compose-section-title small { max-width: 560px; }

/* to 的隐藏字段（仅用于表单提交与旧代码读写）。
   注意：挂载后它被移进 .mrp-box，已不在 .mail-compose-fields 里，所以不能限定作用域。 */
#modal .mrp-to,
#modal input.mrp-to {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  border: 0 !important; opacity: 0 !important;
  background: transparent !important;
  pointer-events: none !important;
  box-shadow: none !important;
}

/* 注意：作者样式里的 display 会压过 UA 的 [hidden]{display:none}，
   所以凡是我自己设了 display 的元素，都必须显式补一条 [hidden] 规则。 */
.mrp-panel[hidden],
.mrp-chips[hidden],
.mrp-count[hidden] { display: none !important; }

.mrp-root { position: relative; }
.mrp-root.is-open .mrp-box { border-color: #159a73; box-shadow: 0 0 0 3px rgba(39, 163, 122, .14); }

/* ---------- 收件人输入框（chips + 输入） ---------- */
.mrp-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 50px; padding: 7px 10px;
  border: 1px solid #cfdcd7; border-radius: 12px;
  background: #fff; cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.mrp-box:hover { border-color: #a9cfc3; }
.mrp-icon { flex: 0 0 auto; color: #86a49d; font-size: 15px; line-height: 1; padding-left: 2px; }
.mrp-box.has-value .mrp-icon { display: none; }

.mrp-chips { display: contents; }
.mrp-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 5px 5px 11px; border-radius: 999px;
  border: 1px solid #bfe3d5;
  background: linear-gradient(180deg, #f1faf6, #e7f5ef);
  color: #12654c; font-size: 11px; font-weight: 800;
  animation: mrp-chip-in .14s ease;
}
.mrp-chip > b { max-width: 168px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrp-chip > i {
  font-style: normal; font-weight: 500; color: #5d8b80; font-size: 10px;
  max-width: 168px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrp-chip-ext { border-color: #dcd6bf; background: linear-gradient(180deg, #fdfaef, #f8f2e0); color: #7a6420; }
.mrp-chip-ext > i { color: #93835a; }
.mrp-chip > button {
  flex: 0 0 auto; width: 17px; height: 17px; border-radius: 50%;
  border: 0; background: rgba(18, 101, 76, .1); color: #12654c;
  font-size: 12px; line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: background .14s ease, transform .14s ease;
}
.mrp-chip > button:hover { background: #159a73; color: #fff; transform: scale(1.08); }
.mrp-chip-ext > button { background: rgba(122, 100, 32, .12); color: #7a6420; }
.mrp-chip-ext > button:hover { background: #c79a2a; color: #fff; }

.mrp-input {
  flex: 1 1 180px; min-width: 140px;
  border: 0 !important; outline: none !important; background: transparent !important;
  box-shadow: none !important; padding: 8px 4px !important;
  font-size: 13px; color: #17333a;
}
.mrp-input::placeholder { color: #9db3ad; }
.mrp-count {
  flex: 0 0 auto; margin-left: auto;
  padding: 4px 10px; border-radius: 999px;
  background: #e8f7f1; color: #0b7458; font-size: 11px; font-weight: 800; white-space: nowrap;
}

@keyframes mrp-chip-in { from { opacity: 0; transform: translateY(-2px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- 下拉面板 ---------- */
.mrp-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 60;
  display: flex; flex-direction: column;
  max-height: min(366px, 52vh);
  border: 1px solid #d3e3dd; border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(14, 58, 56, .17);
  overflow: hidden;
  animation: mrp-panel-in .15s ease;
}
.mrp-panel.drop-up { top: auto; bottom: calc(100% + 8px); }
@keyframes mrp-panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.mrp-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-bottom: 1px solid #edf2f0; background: #f8fbfa;
}
.mrp-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: #eef4f2; }
.mrp-tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 13px; border-radius: 7px;
  color: #5c7570; font-size: 11px; font-weight: 800;
  transition: background .14s ease, color .14s ease;
}
.mrp-tab:hover { color: #0b7458; }
.mrp-tab.is-on { background: #fff; color: #0b7458; box-shadow: 0 1px 3px rgba(14, 58, 56, .1); }
.mrp-tab > b { color: #159a73; }
.mrp-tip { color: #829490; font-size: 10px; }

.mrp-list { overflow: auto; padding: 6px; flex: 1 1 auto; }
.mrp-list::-webkit-scrollbar { width: 9px; }
.mrp-list::-webkit-scrollbar-thumb { background: #d5e2dd; border-radius: 9px; }

.mrp-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 9px;
  background: transparent; cursor: pointer; text-align: left;
  font: inherit; color: #17333a;
  transition: background .12s ease;
}
.mrp-row:hover, .mrp-row.is-cursor { background: #f1f8f5; }
.mrp-row.is-on { background: #e9f7f1; }
.mrp-row.is-on:hover { background: #e0f4ec; }

.mrp-check {
  flex: 0 0 auto; width: 19px; height: 19px; border-radius: 6px;
  border: 1.5px solid #cfdcd7; background: #fff;
  display: grid; place-items: center;
  color: #fff; font-size: 11px; font-weight: 900; line-height: 1;
}
.mrp-row.is-on .mrp-check { border-color: #159a73; background: #159a73; }
.mrp-row-add .mrp-check { border-style: dashed; border-color: #cbbd8c; color: #b9992a; background: #fffdf5; }

.mrp-row-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.mrp-row-main > b {
  font-size: 12.5px; font-weight: 800; color: #17333a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrp-row-main > small {
  font-size: 10.5px; color: #7b8f8b;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrp-tag {
  flex: 0 0 auto; max-width: 92px; padding: 3px 8px; border-radius: 999px;
  background: #f1f5f4; color: #6d8380; font-size: 10px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrp-tag.is-on { background: #159a73; color: #fff; }
.mrp-row-add .mrp-tag { background: #fdf6e3; color: #a8811c; }

.mrp-empty { padding: 26px 14px; text-align: center; color: #8b9c99; font-size: 12px; }

.mrp-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-top: 1px solid #edf2f0; background: #f8fbfa;
}
.mrp-stat { color: #7b8f8b; font-size: 11px; }
.mrp-foot-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mrp-btn {
  border: 1px solid #d7e1dd; background: #fff; border-radius: 8px;
  padding: 6px 11px; color: #425e64; font-size: 11px; font-weight: 800; cursor: pointer;
  transition: border-color .14s ease, color .14s ease, background .14s ease;
}
.mrp-btn:hover { border-color: #159a73; color: #0b7458; background: #f3faf7; }
.mrp-btn-main { border-color: #159a73; background: #159a73; color: #fff; }
.mrp-btn-main:hover { background: #0e8562; color: #fff; }

/* ---------- 状态行 ---------- */
#modal.mrp-active .mail-selected-customer {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 13px; font-size: 11px;
}
#modal.mrp-active .mail-selected-customer b { color: #0b7458; }
#modal.mrp-active .mail-selected-customer[data-state="on"] { background: #eaf7f1; box-shadow: inset 0 0 0 1px #cfe9de; }

/* ---------- 窄屏 ---------- */
@media (max-width: 720px) {
  .mrp-panel { max-height: 58vh; }
  .mrp-foot { flex-direction: column; align-items: stretch; }
  .mrp-foot-btns { justify-content: flex-end; }
  .mrp-chip > b, .mrp-chip > i { max-width: 104px; }
}
