/* ============================================================
   components.css - 通用弹窗 + 富文本编辑器（前后台共用）
   ============================================================ */

/* ---------- 弹窗 Dialog ---------- */
.dlg-mask {
  position: fixed; inset: 0; z-index: 800; display: grid; place-items: center;
  background: rgba(8, 20, 15, .55); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
  padding: 20px;
}
.dlg-mask.show { opacity: 1; pointer-events: auto; }
.dlg {
  width: 100%; max-width: 470px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.97);
  transition: transform .22s var(--ease);
}
.dlg-mask.show .dlg { transform: none; }
.dlg.wide { max-width: 660px; }
.dlg-head { display: flex; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.dlg-head b { font-size: 15px; }
.dlg-x { margin-left: auto; width: 28px; height: 28px; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--muted); }
.dlg-x:hover { background: var(--bg-2); color: var(--text); }
.dlg-body { padding: 18px; overflow-y: auto; }
.dlg-body label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin: 12px 0 6px; }
.dlg-body label:first-child { margin-top: 0; }
.dlg-input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--bg-2); outline: none; transition: .18s var(--ease);
}
textarea.dlg-input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.7; }
.dlg-input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
select.dlg-input { cursor: pointer; }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dlg-hint { font-size: 11.8px; color: var(--muted); line-height: 1.85; margin-top: 8px; background: var(--bg-2); padding: 9px 11px; border-radius: 9px; }
.dlg-tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 3px; border-radius: 10px; margin-bottom: 14px; }
.dlg-tabs button { flex: 1; height: 30px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.dlg-tabs button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.dlg-drop {
  border: 2px dashed var(--border-2); border-radius: var(--r); padding: 34px 16px; text-align: center;
  color: var(--muted); font-size: 13.5px; cursor: pointer; transition: .18s var(--ease); line-height: 1.9;
}
.dlg-drop:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dlg-drop small { font-size: 11.5px; opacity: .8; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); }
.dlg-btn {
  height: 36px; padding: 0 18px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  background: var(--brand); color: #fff; transition: .18s var(--ease);
}
.dlg-btn:hover { background: var(--brand-2); }
.dlg-btn.ghost { background: var(--bg-2); color: var(--text-2); }
.dlg-btn.ghost:hover { background: var(--border); }
.dlg-btn.danger { background: var(--accent); }
.dlg-btn.danger:hover { filter: brightness(1.08); }

/* ---------- 富文本编辑器 RichEditor ---------- */
.rte {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
  display: flex; flex-direction: column; overflow: hidden;
}
.rte.fullscreen { position: fixed; inset: 0; z-index: 700; border-radius: 0; border: none; }
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 7px 9px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0; z-index: 5;
}
.rte-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); transition: .15s var(--ease); }
.rte-btn svg { width: 16px; height: 16px; }
.rte-btn:hover { background: var(--bg-2); color: var(--text); }
.rte-btn.active { background: var(--brand-soft); color: var(--brand); }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }

.rte-body { position: relative; flex: 1; min-height: 0; display: flex; }
.rte-area {
  flex: 1; min-height: 400px; max-height: 64vh; overflow-y: auto; padding: 22px 26px;
  outline: none; font-size: 15.5px; line-height: 1.9;
}
.rte.fullscreen .rte-area { max-height: none; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rte-area.drag { background: var(--brand-soft); outline: 2px dashed var(--brand); outline-offset: -8px; }
.rte-area .match-card { user-select: none; }
.rte-source {
  display: none; flex: 1; min-height: 400px; max-height: 64vh; padding: 18px 20px;
  border: none; outline: none; resize: none; background: #0d1b16; color: #a5d6c0;
  font-family: var(--font-mono); font-size: 12.8px; line-height: 1.7; width: 100%;
}
.rte.source-mode .rte-area { display: none; }
.rte.source-mode .rte-source { display: block; }
.rte.fullscreen .rte-source { max-height: none; }

.rte-status {
  display: flex; gap: 16px; align-items: center; padding: 7px 14px;
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.rte-status .rte-save { margin-left: auto; color: var(--brand); }

@media (max-width: 720px) {
  .rte-area, .rte-source { padding: 16px 15px; min-height: 300px; max-height: 55vh; }
  .rte-toolbar { padding: 6px; gap: 1px; }
  .rte-btn { width: 28px; height: 28px; }
  .rte-sep { margin: 0 3px; }
  .dlg-grid, .dlg-grid3 { grid-template-columns: 1fr; }
}
