/* contextual-chat.css — CortexHive Contextual Chat: floating, draggable, resizable, threaded-per-object chat windows.
   Self-contained. Matches the product's dark/glass aesthetic. 2026-06-03. */
.mchat-win{
  position:fixed; z-index:9000; display:flex; flex-direction:column;
  width:380px; height:520px; min-width:300px; min-height:240px;
  background:rgba(16,15,26,0.92); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px);
  border:1px solid rgba(110,139,255,0.22); border-radius:14px;
  box-shadow:0 18px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.03) inset;
  color:var(--text,#EAECF3); font-family:var(--font-body,'Hanken Grotesk',sans-serif); overflow:hidden;
}
.mchat-win.minimized{height:46px!important; min-height:46px; resize:none;}
.mchat-win.minimized .mchat-body, .mchat-win.minimized .mchat-inputwrap, .mchat-win.minimized .mchat-resize{display:none;}
.mchat-titlebar{
  display:flex; align-items:center; gap:8px; padding:9px 11px; cursor:move; user-select:none;
  background:linear-gradient(180deg,rgba(110,139,255,0.10),rgba(110,139,255,0.02)); border-bottom:1px solid rgba(255,255,255,0.06);
}
.mchat-title{font-size:12px; font-weight:600; letter-spacing:0.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0;}
.mchat-ctx{font-size:9.5px; color:#8FA6FF; opacity:0.8; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.mchat-agent{
  background:rgba(255,255,255,0.05); color:#EAECF3; border:1px solid rgba(110,139,255,0.2); border-radius:6px;
  font-size:10px; padding:2px 4px; max-width:120px; outline:none; cursor:pointer;
}
.mchat-iconbtn{
  width:24px; height:24px; display:flex; align-items:center; justify-content:center; cursor:pointer;
  background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:6px; color:#cdd0dd; font-size:13px; line-height:1;
}
.mchat-iconbtn:hover{background:rgba(110,139,255,0.12); color:#8FA6FF;}
.mchat-iconbtn.on{background:rgba(110,139,255,0.18); color:#8FA6FF; border-color:rgba(110,139,255,0.4);}
.mchat-body{flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:9px; scrollbar-width:none;}
.mchat-body::-webkit-scrollbar{display:none;}
.mchat-msg{max-width:84%; padding:8px 11px; border-radius:11px; font-size:12.5px; line-height:1.5; white-space:pre-wrap; word-wrap:break-word;}
.mchat-msg.user{align-self:flex-end; background:rgba(110,139,255,0.16); border:1px solid rgba(110,139,255,0.25);}
.mchat-msg.agent{align-self:flex-start; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.08);}
.mchat-msg.sys{align-self:center; background:transparent; color:#8a8699; font-size:11px; font-style:italic; max-width:100%; text-align:center;}
.mchat-msg.err{align-self:flex-start; background:rgba(255,90,90,0.12); border:1px solid rgba(255,90,90,0.3); color:#ffb3b3;}
.mchat-typing{align-self:flex-start; color:#8FA6FF; font-size:11px; opacity:0.8;}
.mchat-activity{align-self:flex-start; max-width:92%; background:rgba(110,139,255,0.05); border:1px solid rgba(110,139,255,0.15); border-radius:10px; padding:7px 10px; font-size:11px; color:#8A90A2;}
.mchat-activity-head{font-size:10.5px; color:#8FA6FF; opacity:0.9; cursor:pointer; display:flex; align-items:flex-start; gap:5px; user-select:none; overflow-wrap:anywhere;}
.mchat-activity-head:before{content:'▸'; display:inline-block; transition:transform .15s;}
.mchat-activity.expanded .mchat-activity-head:before{transform:rotate(90deg);}
.mchat-activity-think{display:none; white-space:pre-wrap; font-style:italic; opacity:0.75; margin-top:6px; max-height:160px; overflow-y:auto; font-family:monospace; font-size:10.5px;}
.mchat-activity.expanded .mchat-activity-think:not(:empty){display:block;}
.mchat-activity-tools{display:flex; flex-wrap:wrap; gap:5px; margin-top:6px;}
.mchat-activity-tools:empty{margin-top:0;}
.mchat-tool-chip{font-size:10px; line-height:1.35; padding:2px 7px; border-radius:8px; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); display:inline-block; max-width:100%; overflow-wrap:anywhere;}
.mchat-tool-chip.pending{color:#8FA6FF; border-color:rgba(110,139,255,0.3); animation:mchatToolPulse 1.2s ease-in-out infinite;}
.mchat-tool-chip.done{color:#8fe3b0; border-color:rgba(52,211,153,0.3);}
.mchat-tool-chip.error{color:#ffb3b3; border-color:rgba(255,90,90,0.3);}
/* CHAT-PENDING-ACTION-MC-V1: a mutation the server STAGED and did not run. It
   must not read as done (green) or as failed (red): amber, still, waiting. */
.mchat-tool-chip.wait{color:var(--amber,#e0a458); border-color:rgba(224,164,88,0.38); background:rgba(224,164,88,0.08);}
@keyframes mchatToolPulse{0%,100%{opacity:0.6;}50%{opacity:1;}}
.mchat-inputwrap{border-top:1px solid rgba(255,255,255,0.06); padding:8px;}
.mchat-attach{display:flex; flex-wrap:wrap; gap:5px; margin-bottom:6px;}
.mchat-attach:empty{display:none;}
.mchat-thumb{position:relative; font-size:9px; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.1); border-radius:6px; padding:3px 18px 3px 6px; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.mchat-thumb img{height:28px; border-radius:4px; display:block;}
.mchat-thumb .x{position:absolute; top:1px; right:3px; cursor:pointer; color:#ff8585;}
.mchat-thumb.uploading{opacity:0.55;}
.mchat-thumb.error{border-color:rgba(255,90,90,0.5); color:#ffb3b3;}
.mchat-thumb.ready{border-color:rgba(110,139,255,0.35);}
/* FILE-ATTACH-V1: attachments rendered inside a message bubble */
.mchat-msg-atts{display:flex; flex-wrap:wrap; gap:6px; margin-top:6px;}
.mchat-msg-atts:empty{display:none;}
.mchat-att{display:inline-flex; align-items:center; gap:5px; text-decoration:none; color:inherit; max-width:180px;}
.mchat-att.img img{max-width:160px; max-height:160px; border-radius:7px; display:block;}
.mchat-att.file{background:rgba(255,255,255,0.07); border:1px solid rgba(255,255,255,0.12); border-radius:7px; padding:5px 9px; font-size:11.5px;}
.mchat-att.file .nm{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.mchat-att.file:hover{background:rgba(110,139,255,0.14);}
/* DELIVERABLE-DELIVERY-V1 (v1.1.141): the inline "your deliverable is ready"
   card inside a chat bubble. Bee/honey accent, one clean line-icon, one
   primary Download, no emoji. Mirrors .artifact-card in public/styles.css so
   both chat surfaces read as the same product. */
.mchat-msg.has-artifact{max-width:94%;}
.mchat-artifacts{display:flex; flex-direction:column; gap:7px; margin-top:8px;}
.mchat-artifacts:empty{display:none;}
.mchat-artifact{
  display:flex; align-items:center; gap:10px; padding:9px 11px;
  background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1);
  border-left:3px solid var(--yellow,#f0c040); border-radius:10px;
  white-space:normal;
}
.mchat-artifact-icon{
  flex:none; width:30px; height:30px; display:flex; align-items:center; justify-content:center;
  border-radius:8px; background:rgba(240,192,64,0.12); color:var(--yellow,#f0c040);
}
.mchat-artifact-icon svg{width:17px; height:17px;}
.mchat-artifact-meta{flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:2px;}
.mchat-artifact-title{font-size:12.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.mchat-artifact-fmt{font-size:10.5px; color:#8a8699;}
.mchat-artifact-actions{flex:none; display:flex; align-items:center; gap:6px;}
.mchat-artifact-download{
  display:inline-flex; align-items:center; gap:5px; padding:6px 11px; border-radius:8px;
  background:var(--yellow,#f0c040); color:#1a1400; border:1px solid transparent;
  font-size:11.5px; font-weight:600; text-decoration:none; cursor:pointer;
}
.mchat-artifact-download svg{width:13px; height:13px;}
.mchat-artifact-download:hover{filter:brightness(1.06);}
.mchat-artifact-view{
  display:inline-flex; align-items:center; padding:6px 10px; border-radius:8px;
  background:transparent; color:inherit; border:1px solid rgba(255,255,255,0.14);
  font-size:11.5px; font-weight:500; text-decoration:none;
}
.mchat-artifact-view:hover{border-color:var(--yellow,#f0c040); color:var(--yellow,#f0c040);}
/* CHAT-PENDING-ACTION-MC-V1: the approve/reject card for a staged mutating
   Power-up call. Amber rail (the same "waiting on you" accent as the chip),
   restrained type, no emoji. Mirrors .msg-pending in public/styles.css so both
   chat surfaces read as the same product. */
.mchat-pending{
  align-self:flex-start; max-width:94%; padding:10px 12px;
  background:rgba(224,164,88,0.06); border:1px solid rgba(224,164,88,0.28);
  border-left:3px solid var(--amber,#e0a458); border-radius:11px;
  font-size:12.5px; line-height:1.5; white-space:normal;
}
.mchat-pending-head{font-size:12.5px; font-weight:600; color:var(--text,#EAECF3);}
.mchat-pending-body{margin-top:5px; color:#8a8699; overflow-wrap:anywhere;}
.mchat-pending-body code{font-size:11.5px; word-break:break-all;}
.mchat-pending-actions{display:flex; gap:7px; margin-top:9px;}
.mchat-pending-approve, .mchat-pending-reject{
  padding:6px 11px; border-radius:8px; font-size:11.5px; font-weight:600;
  font-family:inherit; cursor:pointer; border:1px solid rgba(255,255,255,0.14);
}
.mchat-pending-approve{background:var(--amber,#e0a458); color:#1a1204; border-color:var(--amber,#e0a458);}
.mchat-pending-approve:hover{filter:brightness(1.06);}
.mchat-pending-reject{background:transparent; color:#8a8699;}
.mchat-pending-reject:hover{color:var(--text,#EAECF3); border-color:rgba(255,255,255,0.3);}
.mchat-pending-approve:disabled, .mchat-pending-reject:disabled{opacity:0.5; cursor:default;}
.mchat-pending-resolved{margin-top:9px; font-size:12px; font-weight:500;}
.mchat-pending-resolved.ok{color:#8fe3b0;}
.mchat-pending-resolved.rejected{color:#8a8699;}
.mchat-pending-resolved.wait{color:var(--amber,#e0a458);}
.mchat-pending-resolved.err{color:#ffb3b3;}
.mchat-inputrow{display:flex; align-items:flex-end; gap:6px;}
.mchat-textarea{
  flex:1; resize:none; min-height:38px; max-height:160px; padding:9px 11px; font-size:12.5px; line-height:1.5;
  background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.1); border-radius:9px; color:var(--text,#EAECF3); font-family:var(--font-body,'Hanken Grotesk',sans-serif); outline:none;
  font-family:inherit; overflow-y:auto;
}
.mchat-textarea:focus{border-color:rgba(110,139,255,0.4); box-shadow:0 0 0 2px rgba(110,139,255,0.08);}
.mchat-send{flex:none; width:38px; height:38px; border-radius:9px; border:1px solid rgba(110,139,255,0.3); background:rgba(110,139,255,0.16); color:#8FA6FF; cursor:pointer; font-size:15px;}
.mchat-send:hover{background:rgba(110,139,255,0.26);}
.mchat-resize{position:absolute; right:0; bottom:0; width:16px; height:16px; cursor:nwse-resize; z-index:2;}
.mchat-resize::after{content:""; position:absolute; right:3px; bottom:3px; width:7px; height:7px; border-right:2px solid rgba(255,255,255,0.25); border-bottom:2px solid rgba(255,255,255,0.25);}
.mchat-state{font-size:9px; color:#8FA6FF; opacity:0.75; padding:0 2px 4px;}
/* embedded/docked mode (e.g. the Campus drawer Chat tab) — fills its container, no float/drag/resize */
.mchat-win.mchat-embedded{position:absolute!important; inset:0!important; width:auto!important; height:auto!important; min-width:0; min-height:0; border:none; border-radius:0; box-shadow:none; background:transparent; backdrop-filter:none; -webkit-backdrop-filter:none;}
.mchat-win.mchat-embedded .mchat-titlebar{cursor:default; background:transparent; padding:8px 6px;}
.mchat-win.mchat-embedded .mchat-titlebar select.mchat-agent:first-of-type{flex:1; max-width:none;} /* agent picker fills the row (title is hidden in embedded mode) */
.mchat-win.mchat-embedded .mchat-resize{display:none;}

/* MCHAT-MOBILE-V1 (2026-07-11, from a phone check): the chat spawned as a
   desktop 380x520 draggable window on phones — it landed ON TOP of the view,
   its close button rendered off-screen, and you were trapped. On phones every
   chat window is a full-screen sheet: no drag, no resize, big close target,
   16px input font so iOS doesn't zoom-jump on focus. */
@media (max-width: 768px) {
  .mchat-win {
    left: 0 !important; top: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100% !important; height: 100% !important; height: 100dvh !important;
    min-width: 0; border-radius: 0; border-left: none; border-right: none;
    z-index: 9500;
  }
  .mchat-titlebar { cursor: default; padding: 12px 10px; flex-wrap: wrap; row-gap: 6px; }
  .mchat-iconbtn { width: 38px; height: 38px; min-width: 38px; font-size: 16px; }
  .mchat-iconbtn[title="Minimize"] { display: none; } /* minimize is meaningless full-screen */
  .mchat-agent { max-width: 105px; font-size: 11px; padding: 6px 4px; }
  .mchat-textarea { font-size: 16px; }
  .mchat-resize { display: none; }
  .mchat-inputwrap { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  /* the deliverable card stacks rather than squeezing its Download off-screen */
  .mchat-msg.has-artifact { max-width: 100%; }
  .mchat-artifact { flex-wrap: wrap; }
  .mchat-artifact-actions { width: 100%; }
  .mchat-artifact-download { flex: 1 1 auto; justify-content: center; min-height: 38px; }
  .mchat-artifact-view { min-height: 38px; }
  /* the approval decision is the last thing that should be hard to tap */
  .mchat-pending { max-width: 100%; }
  .mchat-pending-actions { flex-wrap: wrap; }
  .mchat-pending-approve { flex: 1 1 auto; min-height: 40px; }
  .mchat-pending-reject { flex: 1 1 auto; min-height: 40px; }
}
