/* ============================================================
   气氛 Bot 专属样式 (L2 真融合 · 2026-05-01)
   预览 chat-bubble · 可视化按行编辑 · 媒体 picker · 日志展开
   配色对齐 lead-system tokens (--bg-* / --line-* / --ink-* / --brand-600)
   ============================================================ */

/* ── Modal 加宽 (默认 .modal max-width: 520px 不够 atmosphere 看)
   :has() 选择器把外层 #modalContent 撑到 920px ─────────────── */
#modalContent:has(.atm-modal-wide) {
  max-width: 920px !important;
  width: 95vw;
  padding: 20px;
}
.atm-modal-wide { width: 100%; }

/* ── Visibility & status badges ──────────────── */
.badge.atm-vis-public  { background: rgba(26,138,63,.15); color: var(--bqr-green-1); }
.badge.atm-vis-team    { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge.atm-vis-private { background: rgba(148,163,184,.15); color: #94a3b8; }
.badge.atm-badge-ok    { background: rgba(26,138,63,.15); color: var(--bqr-green-1); }
.badge.atm-badge-err   { background: rgba(214,90,58,.15);  color: var(--bqr-warn); }
.badge.atm-badge-warn  { background: rgba(212,168,87,.15); color: var(--bqr-gold); }
.badge.atm-badge-info  { background: rgba(59,130,246,.15); color: #60a5fa; }

/* ── Script view/edit · 按行卡片 ───────────────── */
.atm-lines-wrap {
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow-y: auto;
  max-height: 55vh;
  background: var(--bg-2);
}
.atm-line {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
}
.atm-line:last-child { border-bottom: 0; }
.atm-line-idx {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-1);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.atm-line-body { flex: 1; min-width: 0; }
.atm-line-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.atm-line-text { color: var(--ink-1); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.atm-line-meta { font-size: 11px; color: var(--ink-4); margin-top: 4px; }

/* role tags · 9 色调色板对齐 chat-bubble avatar */
.atm-role-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.atm-role-tag.r0 { background: #dbeafe; color: #1d4ed8; }
.atm-role-tag.r1 { background: #d1fae5; color: #047857; }
.atm-role-tag.r2 { background: #ede9fe; color: #6d28d9; }
.atm-role-tag.r3 { background: #fce7f3; color: #be185d; }
.atm-role-tag.r4 { background: #fef3c7; color: #b45309; }
.atm-role-tag.r5 { background: #ccfbf1; color: #0f766e; }
.atm-role-tag.r6 { background: #ffedd5; color: #c2410c; }
.atm-role-tag.r7 { background: #e0e7ff; color: #4338ca; }
.atm-role-tag.r8 { background: #fee2e2; color: #b91c1c; }

/* ── Edit mode · 行内表单 ───────────────────── */
.atm-le {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.atm-le:last-child { border-bottom: 0; }
.atm-le-contact { background: rgba(212,168,87,.04); }
.atm-le-idx {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-1);
  color: var(--ink-3);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-top: 4px;
}
.atm-le-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 56px 90px 1fr auto auto auto;
  gap: 6px;
  align-items: center;
}
.atm-le-grid input,
.atm-le-grid select {
  padding: 6px 8px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg-1);
  color: var(--ink-1);
  font-size: 13px;
}
.atm-le-role { width: 56px; text-align: center; }
.atm-le-type { width: 90px; }
.atm-le-body { width: 100%; }
.atm-le-media {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg-1);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
}
.atm-le-media.has { background: rgba(26,138,63,.15); color: var(--bqr-green-1); border-color: rgba(26,138,63,.3); }
.atm-le-delay { display: flex; align-items: center; gap: 4px; }
.atm-le-delay input { width: 56px; text-align: center; }
.atm-le-delay span { font-size: 11px; color: var(--ink-4); }
.atm-le-del {
  padding: 6px 10px;
  border: 1px solid var(--bqr-warn);
  border-radius: 4px;
  background: rgba(214,90,58,.1);
  color: var(--bqr-warn);
  cursor: pointer;
  font-size: 13px;
}
.atm-le-actions { margin-top: 6px; display: flex; gap: 6px; }
.atm-le-actions .has-variants { background: rgba(212,168,87,.15); color: var(--bqr-gold); border-color: rgba(212,168,87,.3); }

/* media chip · 已选素材 */
.atm-le-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-size: 12px;
}
.atm-le-thumb {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: 3px;
}
.atm-le-thumb-ph {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink-4);
  background: var(--bg-2); border-radius: 3px;
}
.atm-le-chip code { color: var(--ink-2); flex: 1; }
.atm-le-chip button {
  background: none; border: 0; color: var(--ink-4);
  cursor: pointer; font-size: 16px; padding: 2px 6px;
}

/* variant editor 内联 */
.atm-le-variants {
  margin-top: 8px;
  padding: 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  flex-basis: 100%;
}

/* ── Preview shell · chat 模拟 ──────────────── */
.atm-chat-stage {
  background: #e5ddd5;  /* WhatsApp 风背景 */
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.02) 0 1px, transparent 1px 12px);
  border-radius: 10px;
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.atm-chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 85%;
}
.atm-chat-row.right {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.atm-chat-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.atm-chat-col { display: flex; flex-direction: column; min-width: 0; }
.atm-chat-name {
  font-size: 11px;
  color: #555;
  margin-bottom: 2px;
  padding: 0 6px;
}
.atm-chat-row.right .atm-chat-name { text-align: right; }
.atm-chat-bubble {
  background: white;
  color: #111b21;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  max-width: 100%;
  word-break: break-word;
  line-height: 1.4;
}
.atm-chat-row.right .atm-chat-bubble { background: #d9fdd3; }
.atm-chat-card { padding: 0; overflow: hidden; }
.atm-chat-img { width: 100%; max-width: 200px; border-radius: 4px; margin-top: 4px; display: block; }
.atm-chat-meta {
  display: block;
  font-size: 10px;
  color: #667781;
  margin-top: 4px;
  text-align: right;
}

/* ── Media picker grid (剧本内调用) ─────────── */
.atm-picker-card:hover {
  background: var(--bg-2) !important;
  border-color: var(--brand-600) !important;
}

/* ── Media library card (素材库 page) ───────── */
.atm-media-card {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
}

/* ── Exec log table · row + detail 双行 ─────── */
.atm-log-tbl tr.atm-log-row { cursor: pointer; }
.atm-log-tbl tr.atm-log-row:hover { background: var(--bg-2); }
.atm-log-tbl tr.atm-log-row.atm-log-open td:first-child { color: var(--brand-600); }
.atm-log-tbl tr.atm-log-failed td:first-child { color: var(--bqr-warn); }
.atm-log-detail-inner {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 14px;
  padding: 12px 18px;
  background: var(--bg-2);
  font-size: 12px;
}
.atm-log-detail-inner .k {
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  font-weight: 600;
}
.atm-log-detail-inner .v {
  color: var(--ink-1);
  font-family: monospace;
  word-break: break-all;
}

/* ── 响应式微调 ───────────────────────────── */
@media (max-width: 720px) {
  .atm-le-grid {
    grid-template-columns: 56px 1fr auto;
    grid-template-rows: auto auto auto;
  }
  .atm-le-type { grid-column: 2; }
  .atm-le-body { grid-column: 1 / -1; grid-row: 2; }
  .atm-le-delay { grid-column: 1 / -1; grid-row: 3; }
  .atm-modal-wide { width: 100%; }
}
