/* Cabarrus Team chat — Teams-style additions (Oct 29 2026, Jeremy). Loaded by cabarrus.html only.
   Emoji picker, @mention autocomplete + highlight, edit own message, photos + lightbox, 🏃 On it pill.
   Uses the chat panel's theme tokens (--cc-*) so classic / maroon / enterprise all match. */

.cab-chat-panel {
  --ct-mention: rgba(232,121,249,.16); --ct-mention-ink: #f5d0fe; --ct-you: rgba(226,182,92,.24); --ct-you-ink: #F6E2B8;
  --ct-hit: rgba(226,182,92,.10); --ct-hit-line: #E2B65C;
  --ct-onit: rgba(52,211,153,.14); --ct-onit-line: rgba(52,211,153,.55); --ct-onit-ink: #a7f3d0;
  --ct-tool: rgba(255,255,255,.05); --ct-tool-hover: rgba(232,121,249,.14);
  --ct-rule: #c4b5e0;
}
html[data-theme="maroon"] .cab-chat-panel {
  --ct-mention: rgba(138,21,56,.08); --ct-mention-ink: #8A1538; --ct-you: #F7EBD3; --ct-you-ink: #6E0F2C;
  --ct-hit: #FFF8EC; --ct-hit-line: #B48A3C;
  --ct-onit: #EAF6EF; --ct-onit-line: #4E9A6E; --ct-onit-ink: #1F5A38;
  --ct-tool: #FBF7F3; --ct-tool-hover: #F7EBD3;
  --ct-rule: #6E5F66;
}
html[data-theme="enterprise"] .cab-chat-panel {
  --ct-mention: rgba(26,110,142,.09); --ct-mention-ink: #0F5470; --ct-you: #FBF0DB; --ct-you-ink: #6B4A10;
  --ct-hit: #FFF9EE; --ct-hit-line: #C8902E;
  --ct-onit: #E8F5EE; --ct-onit-line: #3F8F63; --ct-onit-ink: #1C5636;
  --ct-tool: #F5F8FB; --ct-tool-hover: #E6EEF5;
  --ct-rule: #4A5A70;
}

/* ---------- composer ---------- */
.cab-chat-form.cab-teams { position: relative; }
.cab-tools { display: flex; gap: 6px; flex: 0 0 auto; }
.cab-tool {
  display: inline-grid; place-items: center; width: 46px; height: 46px; padding: 0; margin: 0; cursor: pointer;
  border-radius: var(--cc-radius); border: 1px solid var(--cc-field-line); background: var(--ct-tool); color: var(--cc-accent);
  -webkit-tap-highlight-color: transparent; transition: background-color .15s, border-color .15s, transform .15s;
}
.cab-tool svg { width: 21px; height: 21px; }
.cab-tool:hover, .cab-tool.is-open { background: var(--ct-tool-hover); border-color: var(--cc-field-hover); }
.cab-tool:active { transform: scale(.96); }
.cab-tool:focus-visible { outline: 2px solid var(--cc-focus-line); outline-offset: 2px; }
.cab-tool:disabled { opacity: .55; cursor: progress; }

.cab-photo-rule {
  display: flex; align-items: center; gap: 6px; margin: 7px 0 0; padding: 0 2px;
  font-family: var(--cc-sans); font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--ct-rule);
}
.cab-photo-rule-ico { display: inline-grid; flex: 0 0 auto; color: var(--cc-gold); }
.cab-photo-rule-ico svg { width: 15px; height: 15px; }

/* emoji popover */
.cab-emoji-pop {
  position: absolute; z-index: 30; left: 0; bottom: calc(100% + 8px);
  display: grid; grid-template-columns: repeat(8, 40px); gap: 2px; padding: 8px;
  background: var(--cc-pop, #241638); border: 1px solid var(--cc-pop-line, rgba(226,182,92,.4)); border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
  animation: ct-pop .14s ease-out both;
}
.cab-emoji-pop[hidden], .cab-mention-pop[hidden], .cab-photo-preview[hidden], .cab-lightbox[hidden] { display: none !important; }
@keyframes ct-pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.cab-emoji-opt {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  font-size: 22px; line-height: 1; transition: background-color .12s, transform .12s;
}
.cab-emoji-opt:hover, .cab-emoji-opt:focus-visible { background: var(--ct-tool-hover); transform: scale(1.12); outline: none; }

/* @mention autocomplete */
.cab-mention-pop {
  position: absolute; z-index: 31; left: 104px; right: 0; bottom: calc(100% + 8px); max-width: 360px; padding: 6px;
  background: var(--cc-pop, #241638); border: 1px solid var(--cc-pop-line, rgba(226,182,92,.4)); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
  font-family: var(--cc-sans); animation: ct-pop .14s ease-out both;
}
.cab-mention-opt { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; border-radius: 8px; cursor: pointer; color: var(--cc-ink); }
.cab-mention-opt.is-active, .cab-mention-opt:hover { background: var(--ct-mention); }
.cab-mention-at { font-weight: 800; color: var(--cc-accent); }
.cab-mention-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-mention-role { margin-left: auto; padding: 0 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; line-height: 1.6; background: var(--cc-role-bg); color: var(--cc-role-ink); }

/* photo ready-to-send */
.cab-photo-preview {
  display: flex; align-items: center; gap: 12px; margin: 0 0 10px; padding: 8px 8px 8px 8px;
  border-radius: 12px; border: 1px dashed var(--cc-me-line); background: var(--cc-me);
  font-family: var(--cc-sans); color: var(--cc-ink);
}
.cab-photo-preview-img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.cab-photo-preview-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.cab-photo-preview-info strong { font-size: 14px; }
.cab-photo-preview-info span { font-size: 12.5px; color: var(--cc-muted); }
.cab-photo-preview-x { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--cc-muted); cursor: pointer; }
.cab-photo-preview-x svg { width: 16px; height: 16px; }
.cab-photo-preview-x:hover { background: var(--ct-tool-hover); color: var(--cc-ink); }

/* ---------- messages ---------- */
.cab-mention { padding: 0 3px; margin: 0 -1px; border-radius: 4px; font-family: var(--cc-sans); font-size: .9em; font-weight: 700; background: var(--ct-mention); color: var(--ct-mention-ink); }
.cab-mention.is-you { background: var(--ct-you); color: var(--ct-you-ink); box-shadow: inset 0 -1.5px 0 var(--ct-hit-line); }
.cab-msg.is-mention-me { background: var(--ct-hit); border-color: var(--ct-hit-line); box-shadow: inset 3px 0 0 var(--ct-hit-line), 0 0 0 3px color-mix(in srgb, var(--ct-hit-line) 18%, transparent); }
.cab-msg.is-mention-me::before { content: "@"; font-family: var(--cc-sans); font-weight: 800; font-size: 11px; color: var(--cc-accent); }

.cab-msg-edited { font-size: 11.5px; font-style: italic; color: var(--cc-muted); }
.cab-msg-edit {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; margin: -2px -6px -2px 0; border: 0; border-radius: 999px;
  background: transparent; color: var(--cc-muted); font-family: var(--cc-sans); font-size: 11.5px; font-weight: 700; cursor: pointer;
  opacity: .72; transition: opacity .15s, background-color .15s, color .15s;
}
.cab-msg-edit svg { width: 13px; height: 13px; }
.cab-msg:hover .cab-msg-edit, .cab-msg-edit:focus-visible { opacity: 1; }
.cab-msg-edit:hover { background: var(--ct-tool-hover); color: var(--cc-accent); }
.cab-msg-edit:focus-visible { outline: 2px solid var(--cc-focus-line); outline-offset: 1px; }
.cab-msg-text.is-empty { display: none; }

.cab-msg-editbox { margin: 4px 0 2px; }
.cab-msg-editinput {
  box-sizing: border-box; width: 100%; min-height: 64px; resize: vertical; padding: 8px 10px; margin: 0;
  border-radius: var(--cc-radius); border: 1px solid var(--cc-focus-line); background: var(--cc-field); color: var(--cc-ink);
  font-family: var(--cc-sans); font-size: 16px; line-height: 1.45; box-shadow: var(--cc-focus); outline: none;
}
.cab-msg-editrow { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; font-family: var(--cc-sans); }
.cab-msg-edithint { margin-right: auto; font-size: 11.5px; color: var(--cc-muted); }
.cab-msg-editbtn {
  height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer; font-family: var(--cc-sans); font-size: 13px; font-weight: 700;
  border: 1px solid var(--cc-field-line); background: var(--cc-field); color: var(--cc-ink);
}
.cab-msg-editbtn.is-save { border-color: transparent; background: var(--cc-accent); color: #fff; }
html:not([data-theme="maroon"]):not([data-theme="enterprise"]) .cab-msg-editbtn.is-save { background: linear-gradient(180deg, #b43fc9, #7a2193); }
.cab-msg-editbtn:disabled { opacity: .6; cursor: progress; }
.cab-msg-editbtn:focus-visible { outline: 2px solid var(--cc-focus-line); outline-offset: 2px; }

/* photo thumbnail */
.cab-msg-photo {
  position: relative; display: block; width: min(100%, 280px); max-height: 220px; aspect-ratio: 4 / 3; margin: 6px 0 4px; padding: 0; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--cc-card-line); background: var(--cc-chip); cursor: zoom-in;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); transition: transform .15s, box-shadow .15s;
}
.cab-msg-photo img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.cab-msg-photo.is-loaded img { opacity: 1; }
.cab-msg-photo:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.cab-msg-photo:focus-visible { outline: 2px solid var(--cc-focus-line); outline-offset: 2px; }
.cab-msg-photo-wait { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--cc-sans); font-size: 12.5px; font-weight: 600; color: var(--cc-muted); }
.cab-msg-photo.is-loaded .cab-msg-photo-wait { display: none; }
.cab-msg-photo.is-failed { cursor: pointer; }

/* 🏃 On it pill */
.cab-react-pill.is-onit { background: var(--ct-onit); border-color: var(--ct-onit-line); color: var(--ct-onit-ink); padding-right: 12px; }
.cab-react-pill.is-onit.is-mine { box-shadow: inset 0 0 0 1px var(--ct-onit-line); }
.cab-react-onit { font-size: 12.5px; font-weight: 700; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- lightbox ---------- */
html.cab-lightbox-open, html.cab-lightbox-open body { overflow: hidden; }
.cab-lightbox {
  position: fixed; inset: 0; z-index: 2147483600; display: grid; place-items: center; padding: 24px;
  background: rgba(10,6,16,.88); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: ct-fade .16s ease-out both;
}
@keyframes ct-fade { from { opacity: 0; } }
.cab-lightbox-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; max-height: 100%; }
.cab-lightbox-img { display: block; max-width: min(96vw, 1280px); max-height: calc(100vh - 120px); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #222; min-width: 120px; min-height: 80px; }
.cab-lightbox-cap { max-width: min(96vw, 900px); text-align: center; font-family: "Source Sans 3", system-ui, sans-serif; font-size: 14px; line-height: 1.4; color: #f1eef4; overflow-wrap: anywhere; }
.cab-lightbox-close {
  position: fixed; top: 14px; right: 14px; width: 46px; height: 46px; display: grid; place-items: center; padding: 0;
  border: 1px solid rgba(255,255,255,.3); border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.cab-lightbox-close svg { width: 18px; height: 18px; }
.cab-lightbox-close:hover { background: rgba(255,255,255,.22); }
.cab-lightbox-close:focus-visible { outline: 2px solid #E2B65C; outline-offset: 2px; }

/* ---------- phones ---------- */
@media (max-width: 520px) {
  .cab-tools { gap: 4px; }
  .cab-tool { width: 42px; }
  .cab-chat-form.cab-teams .cab-chat-row { gap: 6px; }
  html body .cab-chat-panel .cab-chat-form.cab-teams .btn.cab-chat-send { padding: 0 13px; }
  html body .cab-chat-panel .cab-chat-form.cab-teams .btn.cab-chat-send > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html body .cab-chat-panel .cab-chat-form.cab-teams .cab-chat-send-ico { width: 19px; height: 19px; }
  .cab-emoji-pop { grid-template-columns: repeat(8, 1fr); left: 0; right: 0; }
  .cab-emoji-opt { width: auto; height: 38px; font-size: 21px; }
  .cab-mention-pop { left: 0; max-width: none; }
  .cab-msg-edit-txt { display: none; }
  .cab-msg-edit { width: 32px; height: 32px; justify-content: center; padding: 0; margin: -6px -6px -6px 0; }
  .cab-msg-photo { width: 100%; max-height: 240px; }
  .cab-lightbox { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .cab-emoji-pop, .cab-mention-pop, .cab-lightbox { animation: none; }
  .cab-tool, .cab-emoji-opt, .cab-msg-photo, .cab-msg-photo img, .cab-msg-edit { transition: none; }
}

/* the floating theme button stays out of the way while a photo is open */
html.cab-lightbox-open .lais-theme-host { display: none !important; }
