/* ------------------------------------------------------------------
   Ask ProcurementIQ Copilot — floating launcher + side panel.
   Loaded after app.css so it inherits the ProcurementIQ tokens.
------------------------------------------------------------------ */
:root {
  --cop-grad: linear-gradient(103deg, #1b4a78 0%, #2b6ead 55%, #3d86c9 100%);
  --cop-z: 60;
}

/* ---------------- floating launcher ---------------- */
.cop-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: var(--cop-z);
  display: inline-flex; align-items: center; gap: 9px;
  padding: 13px 22px 13px 18px; border: none; border-radius: 999px;
  background: var(--cop-grad); color: #fff; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 700; letter-spacing: -.005em;
  box-shadow: 0 10px 24px rgba(16, 44, 78, .28), 0 2px 6px rgba(16, 44, 78, .18);
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
.cop-fab svg { width: 18px; height: 18px; flex-shrink: 0; }
.cop-fab:hover { transform: translateY(-2px);
                 box-shadow: 0 14px 30px rgba(16, 44, 78, .32), 0 2px 6px rgba(16, 44, 78, .2); }
.cop-fab:active { transform: translateY(0); }
.cop-fab[hidden] { display: none; }

/* ---------------- panel shell ---------------- */
.cop-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: var(--cop-z);
  width: 420px; max-width: calc(100vw - 32px);
  /* fill the viewport height, leaving a small gap above and below */
  height: min(1000px, calc(100vh - 52px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 46px rgba(16, 44, 78, .26), 0 3px 10px rgba(16, 44, 78, .12);
  animation: cop-in .18s ease-out;
}
.cop-panel[hidden] { display: none; }
@keyframes cop-in { from { opacity: 0; transform: translateY(10px) scale(.99); } }

/* ---------------- header ---------------- */
.cop-head { background: var(--cop-grad); color: #fff; padding: 14px 16px; }
.cop-head-row { display: flex; align-items: center; gap: 10px; }
.cop-head-row h2 { font-size: 15.5px; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.cop-head-row > svg { width: 19px; height: 19px; }
.cop-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0; border: none; border-radius: 7px;
  background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer;
  transition: background .15s;
}
.cop-icon-btn svg { width: 15px; height: 15px; }
.cop-icon-btn:hover { background: rgba(255, 255, 255, .24); }
/* ---------------- thread ---------------- */
.cop-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex;
              flex-direction: column; gap: 12px; background: #fbfcfe; }
.cop-msg { max-width: 92%; border-radius: 12px; padding: 12px 14px; font-size: 13.5px;
           line-height: 1.55; animation: cop-msg-in .18s ease-out; }
@keyframes cop-msg-in { from { opacity: 0; transform: translateY(5px); } }
.cop-msg.bot { background: #eaf2fb; color: #234668; border-top-left-radius: 4px;
               align-self: flex-start; }
.cop-msg.me { background: var(--blue-deep); color: #fff; border-top-right-radius: 4px;
              align-self: flex-end; }
.cop-msg strong { font-weight: 700; }
.cop-msg p + p { margin-top: 8px; }
.cop-msg ul { list-style: none; margin: 8px 0 0; }
.cop-msg li { padding-left: 14px; position: relative; margin-bottom: 5px; }
.cop-msg li::before { content: "·"; position: absolute; left: 3px; font-weight: 800; }
.cop-msg li.ok::before { content: "✓"; left: 0; font-size: 11px; color: var(--green); }
.cop-msg li.no::before { content: "✕"; left: 0; font-size: 11px; color: var(--red); }
.cop-num { font-weight: 800; }
.cop-num.bad { color: var(--red); }
.cop-num.good { color: var(--green); }
.cop-num.warn { color: var(--amber-deep); }

.cop-msg a { color: #1d4f7e; font-weight: 600; text-decoration: underline;
             text-underline-offset: 2px; }
.cop-msg a:hover { color: var(--blue); }

.cop-srcs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px;
            padding-top: 10px; border-top: 1px solid #d5e3f3; }
.cop-srcs b { font-size: 9.5px; font-weight: 700; letter-spacing: .09em;
              text-transform: uppercase; color: #5d7fa6; width: 100%; }
.cop-src { font-size: 10.5px; font-weight: 600; color: #33507a; background: #fff;
           border: 1px solid #cfdff1; border-radius: 5px; padding: 3px 8px; }
.cop-jump {
  margin-top: 11px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #b9d2ec; background: #fff; color: var(--blue-deep);
  border-radius: 7px; padding: 7px 13px; cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 700; transition: all .15s;
}
.cop-jump:hover { border-color: var(--blue); background: #f2f7fd; }

.cop-typing { display: flex; gap: 4px; padding: 14px; }
.cop-typing span { width: 6px; height: 6px; border-radius: 50%; background: #8aa9cb;
                   animation: cop-blink 1.1s infinite; }
.cop-typing span:nth-child(2) { animation-delay: .18s; }
.cop-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes cop-blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* ---------------- composer ---------------- */
.cop-foot { border-top: 1px solid var(--line); background: #fff; padding: 12px 14px 11px; }
.cop-form { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
            border-radius: 9px; padding: 4px 4px 4px 13px; transition: border-color .15s; }
.cop-form:focus-within { border-color: var(--blue); }
.cop-form input {
  flex: 1; border: none; outline: none; background: none; padding: 9px 0;
  font-family: var(--font); font-size: 13px; color: var(--ink);
}
.cop-form input::placeholder { color: #97a3b4; }
.cop-send {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0; border: none; border-radius: 7px;
  background: none; color: var(--blue); cursor: pointer; transition: background .15s;
}
.cop-send svg { width: 18px; height: 18px; }
.cop-send:hover { background: #eef3fa; }
.cop-note { font-size: 10.5px; color: var(--muted); margin-top: 9px; line-height: 1.4; }

.cop-fab:focus-visible, .cop-icon-btn:focus-visible,
.cop-send:focus-visible, .cop-jump:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}

@media (max-width: 560px) {
  .cop-panel { right: 0; bottom: 0; width: 100%; max-width: 100%;
               height: 100%; border-radius: 0; border: none; }
  .cop-fab { right: 14px; bottom: 14px; padding: 12px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .cop-panel, .cop-msg { animation: none; }
  .cop-fab:hover { transform: none; }
  .cop-typing span { animation: none; opacity: .55; }
}