/* ============================================
   AI 市集 · 咨询聊天抽屉 (market-chat) — ACID THEME
   Reusable slide-in chat drawer. Injected by js/market-chat.js.
   ============================================ */

.mchat-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.28s ease;
}
.mchat-backdrop.open { opacity: 1; pointer-events: all; }

.mchat {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 10001;
  width: 400px; max-width: 92vw;
  background: rgba(10, 10, 16, 0.96);
  backdrop-filter: blur(24px) saturate(1.3);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.mchat.open { transform: translateX(0); }

/* header */
.mchat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.mchat-av {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 900; color: #000;
}
.mchat-peer-info { flex: 1; min-width: 0; }
.mchat-name { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.mchat-role { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--cyan); background: rgba(0, 255, 209, 0.1); border: 1px solid rgba(0, 255, 209, 0.28); padding: 1px 7px; border-radius: 4px; }
.mchat-online { font-size: 11px; font-weight: 600; color: #C8FF00; }
.mchat-ctx {
  font-size: 12px; color: var(--text-muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mchat-ctx a { color: var(--cyan); }
.mchat-close {
  width: 34px; height: 34px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); border-radius: 50%; color: var(--text-muted); transition: var(--transition);
}
.mchat-close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.mchat-close [data-lucide] { width: 17px; height: 17px; }

/* controlled-comms guard banner */
.mchat-guard {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px; font-size: 11.5px; color: var(--text-muted);
  background: rgba(0, 255, 209, 0.04); border-bottom: 1px solid var(--border);
  line-height: 1.4;
}
.mchat-guard [data-lucide] { width: 14px; height: 14px; stroke: var(--cyan); flex-shrink: 0; }

/* messages */
.mchat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.mchat-body::-webkit-scrollbar { width: 6px; }
.mchat-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 3px; }

.mc-day { text-align: center; font-size: 11px; color: var(--text-muted); margin: 2px 0; }
.mc-sys {
  align-self: center; max-width: 90%; text-align: center;
  font-size: 11.5px; color: var(--text-muted); line-height: 1.5;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 3px;
}
.mc-sys.warn { color: var(--orange); background: rgba(255, 106, 0, 0.06); border-color: rgba(255, 106, 0, 0.25); }
.mc-sys [data-lucide] { width: 12px; height: 12px; vertical-align: -2px; margin-right: 3px; }

.mc-msg { display: flex; gap: 9px; align-items: flex-end; max-width: 84%; }
.mc-msg.me { align-self: flex-end; flex-direction: row-reverse; }
.mc-msg.them { align-self: flex-start; }
.mc-msg-av {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #000;
}
.mc-msg.me .mc-msg-av { display: none; }
.mc-msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mc-msg.me .mc-msg-col { align-items: flex-end; }
.mc-bubble {
  padding: 10px 14px; font-size: 13px; line-height: 1.5; word-break: break-word;
  border: 1px solid var(--border);
}
.mc-msg.them .mc-bubble { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); border-radius: 12px 12px 12px 2px; }
.mc-msg.me .mc-bubble { background: rgba(200, 255, 0, 0.15); color: var(--text-primary); border-color: rgba(200, 255, 0, 0.32); border-radius: 12px 12px 2px 12px; }
.mc-bubble .masked { color: var(--orange); font-weight: 700; }
.mc-time { font-size: 10px; color: var(--text-muted); padding: 2px 2px 0; }

/* typing indicator */
.mc-typing { display: flex; gap: 9px; align-items: flex-end; align-self: flex-start; }
.mc-typing-bubble { display: flex; gap: 4px; padding: 12px 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); border-radius: 12px 12px 12px 2px; align-items: center; }
.mc-typing-bubble span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: mcTyping 1.2s infinite ease-in-out; }
.mc-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.mc-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mcTyping { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* quick replies */
.mchat-quick { display: flex; gap: 7px; padding: 10px 14px 0; flex-wrap: wrap; }
.mc-quick-chip {
  font-size: 12px; color: var(--text-secondary); background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border); border-radius: 100px; padding: 6px 14px; cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.mc-quick-chip:hover { border-color: rgba(0, 255, 209, 0.35); color: var(--cyan); }

/* input */
.mchat-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.mchat-input textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 40px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary);
  padding: 10px 12px; font-family: inherit; font-size: 13px; line-height: 1.5; transition: var(--transition);
}
.mchat-input textarea:focus { outline: none; border-color: rgba(0, 255, 209, 0.4); }
.mchat-send {
  width: 40px; height: 40px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--gradient-main); border: none; border-radius: 8px; cursor: pointer; transition: var(--transition);
}
.mchat-send:hover { filter: brightness(1.1); }
.mchat-send:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.mchat-send [data-lucide] { width: 18px; height: 18px; stroke: #000; }

@media (max-width: 768px) {
  .mchat { width: 100%; max-width: 100%; }
}


/* ══════════════════════════════════════
   LIGHT THEME OVERRIDES (auto-generated)
   ══════════════════════════════════════ */
[data-theme="light"] .form-input,
[data-theme="light"] .form-textarea,
[data-theme="light"] .form-select { 
  background: var(--bg-input) !important; 
  color: var(--text-primary) !important; 
  border-color: var(--border) !important; 
}
[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-textarea:focus,
[data-theme="light"] .form-select:focus { 
  border-color: var(--acid) !important; 
  box-shadow: 0 0 0 3px var(--acid-bg) !important; 
}
[data-theme="light"] .form-input::placeholder,
[data-theme="light"] .form-textarea::placeholder { 
  color: var(--text-muted) !important; 
}

/* ── Market-chat light patches ── */
[data-theme="light"] .mchat {
  background: rgba(255, 255, 255, 0.98) !important;
  border-left: 1px solid var(--border) !important;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.08) !important;
}
[data-theme="light"] .mchat-head {
  background: rgba(0, 0, 0, 0.01) !important;
  border-bottom: 1px solid var(--border) !important;
}
[data-theme="light"] .mchat-name {
  color: var(--text-primary) !important;
}
[data-theme="light"] .mchat-role {
  color: #0d9488 !important;
  background: rgba(13, 148, 136, 0.08) !important;
  border-color: rgba(13, 148, 136, 0.2) !important;
}
[data-theme="light"] .mchat-online {
  color: #65a30d !important; /* Soft green standard for light mode */
}
[data-theme="light"] .mchat-close {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}
[data-theme="light"] .mchat-close:hover {
  background: rgba(0, 0, 0, 0.08) !important;
  color: var(--text-primary) !important;
}
[data-theme="light"] .mchat-guard {
  background: rgba(13, 148, 136, 0.04) !important;
  border-bottom-color: var(--border) !important;
  color: var(--text-muted) !important;
}
[data-theme="light"] .mchat-guard [data-lucide] {
  stroke: #0d9488 !important;
}
[data-theme="light"] .mc-sys {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}
[data-theme="light"] .mc-sys.warn {
  background: rgba(234, 88, 12, 0.06) !important;
  border-color: rgba(234, 88, 12, 0.2) !important;
  color: #ea580c !important;
}
[data-theme="light"] .mc-msg.them .mc-bubble {
  background: #f4f4f5 !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .mc-msg.me .mc-bubble {
  background: rgba(200, 255, 0, 0.22) !important;
  color: var(--text-primary) !important;
  border-color: rgba(200, 255, 0, 0.45) !important;
}
[data-theme="light"] .mc-typing-bubble {
  background: #f4f4f5 !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .mc-quick-chip {
  background: #f4f4f5 !important;
  border-color: var(--border) !important;
  color: var(--text-secondary) !important;
}
[data-theme="light"] .mc-quick-chip:hover {
  background: #e4e4e7 !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .mchat-input {
  border-top: 1px solid var(--border) !important;
}
[data-theme="light"] .mchat-input textarea {
  background: #ffffff !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .mchat-input textarea:focus {
  border-color: var(--acid) !important;
}
[data-theme="light"] .mchat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12) !important;
}
