/* ============================================================================
   AMAC Suite — In-Suite AI Chatbot widget v1.0.0  (shared, suite-wide)
   ----------------------------------------------------------------------------
   Pairs with amac-ai-chat-v1.js. Scoped to .amac-aichat-* so it cannot collide
   with any app's styles. Navy suite palette (#022544), matching the Feedback
   widget. The launcher sits just ABOVE the bottom-right Feedback pill; the chat
   panel docks into the bottom-right corner.
   ========================================================================= */

:root {
  --amac-aichat-navy: #022544;
  --amac-aichat-navy-2: #0a3a63;
  --amac-aichat-accent: #1d6fb8;
  --amac-aichat-ai-bg: #f1f5f9;
  --amac-aichat-ink: #14242f;
}

/* ---- launcher button (fixed, just above the Feedback pill) --------------- */
.amac-aichat-btn {
  position: fixed;
  right: 18px;
  bottom: 64px;                   /* sits above the Feedback button (bottom:18) */
  z-index: 2147482000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: var(--amac-aichat-navy);
  color: #fff;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(2, 37, 68, 0.35);
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.amac-aichat-btn:hover { background: var(--amac-aichat-navy-2); transform: translateY(-1px); }
.amac-aichat-btn:active { transform: translateY(0); }
.amac-aichat-btn:focus-visible { outline: 3px solid var(--amac-aichat-accent); outline-offset: 2px; }
.amac-aichat-btn svg { flex: 0 0 auto; }
.amac-aichat-btn[hidden] { display: none; }

@media (max-width: 600px) {
  .amac-aichat-btn { padding: 12px; right: 12px; bottom: 66px; }
  .amac-aichat-btn-label { display: none; }
}
@media print { .amac-aichat-btn, .amac-aichat-panel { display: none !important; } }

/* ---- docked chat panel --------------------------------------------------- */
.amac-aichat-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483100;            /* above the Feedback launcher/menu */
  display: flex;
  flex-direction: column;
  width: 400px;
  max-width: calc(100vw - 36px);
  height: 640px;
  max-height: calc(100vh - 36px);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  font: 400 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--amac-aichat-ink);
  animation: amac-aichat-pop .14s ease-out;
}
.amac-aichat-panel[hidden] { display: none; }
@keyframes amac-aichat-pop { from { transform: translateY(10px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 600px) {
  .amac-aichat-panel { right: 8px; left: 8px; bottom: 8px; top: 8px; width: auto; height: auto; max-height: none; }
}

/* ---- header -------------------------------------------------------------- */
.amac-aichat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  background: var(--amac-aichat-navy);
  color: #fff;
}
.amac-aichat-head h2 { margin: 0; font-size: 15px; font-weight: 700; flex: 1 1 auto; }
.amac-aichat-head .amac-aichat-sub { font-size: 11px; font-weight: 400; opacity: .8; display: block; margin-top: 1px; }
.amac-aichat-head .amac-aichat-model {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 10px; font-weight: 700; letter-spacing: .02em; color: #fff; vertical-align: 1px;
}
.amac-aichat-head .amac-aichat-model[hidden] { display: none; }
.amac-aichat-iconbtn {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  width: 30px; height: 30px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 17px; line-height: 1;
}
.amac-aichat-iconbtn:hover { background: rgba(255, 255, 255, 0.14); }
.amac-aichat-iconbtn:focus-visible { outline: 2px solid #cfe3f5; outline-offset: 1px; }

/* ---- thread (messages) --------------------------------------------------- */
.amac-aichat-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  background: #fbfcfe;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.amac-aichat-msg { max-width: 86%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.amac-aichat-msg.is-user { align-self: flex-end; background: var(--amac-aichat-navy); color: #fff; border-bottom-right-radius: 4px; }
.amac-aichat-msg.is-ai { align-self: flex-start; background: var(--amac-aichat-ai-bg); color: var(--amac-aichat-ink); border-bottom-left-radius: 4px; }
.amac-aichat-msg.is-note { align-self: center; background: #fff6e0; color: #7a5c12; border: 1px solid #f0dca6; font-size: 13px; max-width: 100%; }
.amac-aichat-msg.is-err { align-self: flex-start; background: #fdecea; color: #a82315; border: 1px solid #f5c6c0; }

.amac-aichat-meta { font-size: 10.5px; color: #8595a3; margin-top: 2px; align-self: flex-start; }

/* typing indicator */
.amac-aichat-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 11px 13px; background: var(--amac-aichat-ai-bg); border-radius: 12px; }
.amac-aichat-typing span { width: 7px; height: 7px; border-radius: 50%; background: #93a3b2; animation: amac-aichat-bounce 1.2s infinite ease-in-out; }
.amac-aichat-typing span:nth-child(2) { animation-delay: .15s; }
.amac-aichat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes amac-aichat-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* empty state */
.amac-aichat-empty { margin: auto; text-align: center; color: #6b7c8a; padding: 20px; }
.amac-aichat-empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--amac-aichat-ink); }
.amac-aichat-empty p { margin: 0 0 4px; font-size: 13px; }
.amac-aichat-examples { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.amac-aichat-example {
  border: 1px solid #d8e1ea; background: #fff; border-radius: 999px; padding: 7px 12px;
  font: 400 13px inherit; color: #2b4a63; cursor: pointer; text-align: left;
}
.amac-aichat-example:hover { background: #eef4fa; border-color: var(--amac-aichat-accent); }

/* ---- composer ------------------------------------------------------------ */
.amac-aichat-composer { border-top: 1px solid #e1e8ef; padding: 10px; background: #fff; }
.amac-aichat-inputrow { display: flex; gap: 8px; align-items: flex-end; }
.amac-aichat-input {
  flex: 1 1 auto; box-sizing: border-box; resize: none; min-height: 40px; max-height: 120px;
  padding: 9px 11px; border: 1px solid #c7d2db; border-radius: 10px; font: inherit; color: var(--amac-aichat-ink);
}
.amac-aichat-input:focus { outline: none; border-color: var(--amac-aichat-accent); box-shadow: 0 0 0 3px rgba(29, 111, 184, 0.18); }
.amac-aichat-send {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--amac-aichat-navy);
  background: var(--amac-aichat-navy); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.amac-aichat-send:hover:not(:disabled) { background: var(--amac-aichat-navy-2); }
.amac-aichat-send:disabled { opacity: .5; cursor: default; }
.amac-aichat-foot { margin: 6px 2px 0; font-size: 10.5px; color: #8595a3; text-align: center; }

/* ---- conversation list (history view) ------------------------------------ */
.amac-aichat-list { flex: 1 1 auto; overflow-y: auto; padding: 8px; background: #fbfcfe; }
.amac-aichat-listhead { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }
.amac-aichat-listhead h3 { margin: 0; font-size: 13px; color: #56697a; text-transform: uppercase; letter-spacing: .04em; }
.amac-aichat-newbtn { border: 1px solid var(--amac-aichat-accent); background: #fff; color: var(--amac-aichat-accent); border-radius: 8px; padding: 5px 10px; font: 600 12px inherit; cursor: pointer; }
.amac-aichat-newbtn:hover { background: #eef4fa; }
.amac-aichat-conv {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 10px 10px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font: inherit; color: var(--amac-aichat-ink);
}
.amac-aichat-conv:hover { background: #eef4fa; }
.amac-aichat-conv-main { flex: 1 1 auto; min-width: 0; }
.amac-aichat-conv-title { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amac-aichat-conv-meta { display: block; font-size: 11px; color: #8595a3; }
.amac-aichat-conv-del { flex: 0 0 auto; border: 0; background: transparent; color: #aab6c2; cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; border-radius: 6px; }
.amac-aichat-conv-del:hover { color: #c0392b; background: #fbe9e7; }
.amac-aichat-list-empty { text-align: center; color: #8595a3; padding: 24px 12px; font-size: 13px; }

/* ---- "How to use" help view (app-aware) --------------------------------- */
.amac-aichat-help { flex: 1 1 auto; overflow-y: auto; padding: 14px; background: #fbfcfe; }
.amac-aichat-help-body h3 { margin: 0 0 8px; font-size: 16px; color: var(--amac-aichat-ink); }
.amac-aichat-help-body h4 { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #56697a; }
.amac-aichat-help-body p { margin: 0 0 8px; font-size: 13px; color: #2b3b46; }
.amac-aichat-help-body ul { margin: 0; padding-left: 18px; }
.amac-aichat-help-body li { font-size: 13px; color: #2b3b46; margin-bottom: 5px; }
.amac-aichat-help-examples { margin-top: 4px; display: flex; flex-direction: column; gap: 6px; }
.amac-aichat-help-link { display: inline-block; margin-top: 10px; border: 0; background: transparent; color: var(--amac-aichat-accent); cursor: pointer; font: 600 13px/1.2 inherit; padding: 4px 0; text-decoration: underline; }
.amac-aichat-help-link:hover { color: var(--amac-aichat-navy-2); }

/* ---- generated-document download card ------------------------------------ */
.amac-aichat-doc {
  align-self: flex-start; display: flex; align-items: center; gap: 10px;
  max-width: 86%; margin: 2px 0; padding: 9px 12px;
  background: #fff; border: 1px solid #d8e1ea; border-radius: 12px;
}
.amac-aichat-doc-ico { font-size: 20px; line-height: 1; flex: 0 0 auto; }
.amac-aichat-doc-main { display: flex; flex-direction: column; min-width: 0; }
.amac-aichat-doc-name { font-size: 13px; font-weight: 600; color: var(--amac-aichat-ink); word-break: break-all; }
.amac-aichat-doc-meta { font-size: 11px; color: #8595a3; }
.amac-aichat-doc-dl {
  flex: 0 0 auto; margin-left: 4px; padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--amac-aichat-navy); background: var(--amac-aichat-navy); color: #fff;
  font: 600 12.5px/1 inherit; cursor: pointer;
}
.amac-aichat-doc-dl:hover { background: var(--amac-aichat-navy-2); }

/* ---- proposed-write confirm card (Phase E) ------------------------------ */
.amac-aichat-action { align-self: stretch; margin: 2px 0; padding: 11px 12px; border: 1px solid #f0dca6; background: #fff8e8; border-radius: 12px; }
.amac-aichat-action-head { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #8a6d1a; margin-bottom: 4px; }
.amac-aichat-action-sum { font-size: 13.5px; color: var(--amac-aichat-ink); margin-bottom: 9px; }
.amac-aichat-action-type { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #c7d2db; border-radius: 8px; font: inherit; margin-bottom: 9px; }
.amac-aichat-action-type:focus { outline: none; border-color: var(--amac-aichat-accent); box-shadow: 0 0 0 3px rgba(29,111,184,.18); }
.amac-aichat-action-btns { display: flex; gap: 8px; }
.amac-aichat-action-confirm, .amac-aichat-action-cancel { padding: 7px 14px; border-radius: 8px; font: 600 13px/1 inherit; cursor: pointer; }
.amac-aichat-action-confirm { background: var(--amac-aichat-navy); border: 1px solid var(--amac-aichat-navy); color: #fff; }
.amac-aichat-action-confirm:hover:not(:disabled) { background: var(--amac-aichat-navy-2); }
.amac-aichat-action-cancel { background: #fff; border: 1px solid #c7d2db; color: #2b3b46; }
.amac-aichat-action-cancel:hover:not(:disabled) { background: #f1f5f9; }
.amac-aichat-action-confirm:disabled, .amac-aichat-action-cancel:disabled { opacity: .55; cursor: default; }
.amac-aichat-action-msg { margin-top: 8px; font-size: 12.5px; color: #56697a; }
.amac-aichat-action-msg.is-err { color: #a82315; }
.amac-aichat-action.is-done { background: #eef5ee; border-color: #cfe3c8; }
.amac-aichat-action-done { font-size: 13px; color: #56697a; }
.amac-aichat-action-done.is-ok { color: #1d7a35; font-weight: 600; }

/* ---- host-app button-leak guard ----------------------------------------- */
/* This widget is injected into EVERY suite app. Some hosts (the suite shell)
   define a global `body.suite-shell button { background: var(--ss-red); color:#fff }`
   leak that would repaint the widget's buttons red. Re-assert the widget's own
   colors with BOTH higher specificity (two classes, (0,2,x) — beats the leak's
   (0,1,2)) AND !important, so it wins even when the leak itself is !important.
   The launcher lives outside the panel, so it doubles its own class. */
.amac-aichat-btn.amac-aichat-btn { background: var(--amac-aichat-navy) !important; color: #fff !important; border-color: rgba(255, 255, 255, 0.18) !important; }
.amac-aichat-btn.amac-aichat-btn:hover { background: var(--amac-aichat-navy-2) !important; }
.amac-aichat-panel .amac-aichat-iconbtn { background: transparent !important; color: #fff !important; }
.amac-aichat-panel .amac-aichat-iconbtn:hover { background: rgba(255, 255, 255, 0.14) !important; }
.amac-aichat-panel .amac-aichat-send { background: var(--amac-aichat-navy) !important; color: #fff !important; border-color: var(--amac-aichat-navy) !important; }
.amac-aichat-panel .amac-aichat-send:hover:not(:disabled) { background: var(--amac-aichat-navy-2) !important; }
.amac-aichat-panel .amac-aichat-example { background: #fff !important; color: #2b4a63 !important; border-color: #d8e1ea !important; }
.amac-aichat-panel .amac-aichat-example:hover { background: #eef4fa !important; border-color: var(--amac-aichat-accent) !important; }
.amac-aichat-panel .amac-aichat-help-link { background: transparent !important; color: var(--amac-aichat-accent) !important; }
.amac-aichat-panel .amac-aichat-doc-dl { background: var(--amac-aichat-navy) !important; color: #fff !important; border-color: var(--amac-aichat-navy) !important; }
.amac-aichat-panel .amac-aichat-action-confirm { background: var(--amac-aichat-navy) !important; color: #fff !important; border-color: var(--amac-aichat-navy) !important; }
.amac-aichat-panel .amac-aichat-action-cancel { background: #fff !important; color: #2b3b46 !important; border-color: #c7d2db !important; }
.amac-aichat-panel .amac-aichat-newbtn { background: #fff !important; color: var(--amac-aichat-accent) !important; border-color: var(--amac-aichat-accent) !important; }
.amac-aichat-panel .amac-aichat-conv { background: transparent !important; color: var(--amac-aichat-ink) !important; }
.amac-aichat-panel .amac-aichat-conv:hover { background: #eef4fa !important; }
.amac-aichat-panel .amac-aichat-conv-del { background: transparent !important; color: #aab6c2 !important; }
.amac-aichat-panel .amac-aichat-conv-del:hover { background: #fbe9e7 !important; color: #c0392b !important; }
