/* ────────────────────────────────────────────────────────────────────
 * Spartan CRM — Team Response Watch bar (SM-EMAIL-RESP-01)
 * Companion to modules/38d-email-response-watch-bar.js
 *
 * Admin (all states) / manager (their state) top-of-screen banner that pulses
 * over OVERDUE client emails another rep hasn't answered. Escalates by how far
 * past the SLA the oldest item is:
 *   ≤ end of next business day + a bit  → .rw-pulse-normal  (2.4s)
 *   1 day past due                       → .rw-pulse-super   (1.4s, thick border)
 *   2+ days past due                     → .rw-pulse-extreme (0.85s, darker)
 *
 * Sits just BELOW the AI email-reminders bar (#email-reminders-root, z 9000)
 * when both are present — 38d sets `top` inline from the er banner height.
 * All motion gated by prefers-reduced-motion: reduce.
 * ──────────────────────────────────────────────────────────────────── */

#response-watch-root {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8950; /* just under #email-reminders-root (9000), above topbar/app */
  pointer-events: none;
}
#response-watch-root .rw-banner {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(190,18,60,.97) 0%, rgba(136,10,40,.97) 100%);
  color: #fff;
  font-family: 'Archivo', system-ui, sans-serif;
  font-size: 13px;
  border-bottom: 2px solid rgba(255,255,255,.18);
  box-shadow: 0 6px 22px -2px rgba(190,18,60,.55);
}

.rw-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.rw-icon svg { width: 19px; height: 19px; }

.rw-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rw-h {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-family: 'Archivo Narrow', sans-serif;
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.92);
}
.rw-sep { opacity: .5; }
.rw-tag {
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.32);
  padding: 2px 6px; border-radius: 4px;
}
.rw-tag-count { background: #fff; color: #7f1d1d; }
.rw-state {
  background: rgba(0,0,0,.22);
  padding: 2px 6px; border-radius: 4px; letter-spacing: .06em;
}

.rw-title {
  font-size: 14px; font-weight: 800; color: #fff; letter-spacing: -.005em; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: calc(100vw - 520px);
}
.rw-title .rw-rep { text-decoration: underline; text-decoration-color: rgba(255,255,255,.5); text-underline-offset: 2px; }
.rw-title .rw-client { color: #FFE1E6; }
.rw-text {
  font-size: 12px; color: rgba(255,255,255,.9); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: calc(100vw - 520px);
}
.rw-text .rw-subj { font-style: italic; color: #fff; }

.rw-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.rw-more, .rw-action {
  padding: 7px 12px; border-radius: 7px;
  font-family: 'Archivo Narrow', sans-serif;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: #fff;
  transition: background 150ms ease, transform 150ms ease;
}
.rw-more:hover, .rw-action:hover { background: rgba(255,255,255,.24); transform: translateY(-1px); }
.rw-action.rw-open { background: #fff; color: #9f1239; border-color: #fff; }
.rw-action.rw-open:hover { background: #FFE4E6; }

/* ── Pulse keyframes — escalating ─────────────────────────────────── */
@keyframes rw-pulse-normal {
  0%, 100% { box-shadow: 0 6px 22px -2px rgba(190,18,60,.55), 0 0 0 0 rgba(190,18,60,.5); }
  50%      { box-shadow: 0 6px 22px -2px rgba(190,18,60,.55), 0 0 0 7px rgba(190,18,60,0); }
}
@keyframes rw-pulse-super {
  0%, 100% { box-shadow: 0 6px 22px -2px rgba(190,18,60,.75), inset 0 0 0 2px rgba(255,255,255,.4), 0 0 0 0 rgba(190,18,60,.75); }
  50%      { box-shadow: 0 6px 22px -2px rgba(190,18,60,.95), inset 0 0 0 3px rgba(255,255,255,.7), 0 0 0 11px rgba(190,18,60,0); }
}
@keyframes rw-pulse-extreme {
  0%, 100% { box-shadow: 0 8px 30px -2px rgba(190,18,60,.95), inset 0 0 0 3px rgba(255,255,255,.8); transform: translateY(0); }
  50%      { box-shadow: 0 8px 42px -2px rgba(190,18,60,1),   inset 0 0 0 5px rgba(255,255,255,1);   transform: translateY(-1px); }
}
.rw-banner.rw-pulse-normal  { animation: rw-pulse-normal 2.4s ease-in-out infinite; }
.rw-banner.rw-pulse-super   { animation: rw-pulse-super 1.4s ease-in-out infinite; }
.rw-banner.rw-pulse-extreme { animation: rw-pulse-extreme 0.85s ease-in-out infinite; background: linear-gradient(180deg,#9f1239 0%,#7f1d1d 100%); }

@media (prefers-reduced-motion: reduce) {
  .rw-banner, .rw-banner.rw-pulse-normal, .rw-banner.rw-pulse-super, .rw-banner.rw-pulse-extreme { animation: none !important; }
  .rw-banner.rw-pulse-super, .rw-banner.rw-pulse-extreme { box-shadow: 0 8px 28px -2px rgba(190,18,60,.7), inset 0 0 0 2.5px #fff; }
}

@media (max-width: 900px) {
  #response-watch-root .rw-banner { grid-template-columns: 36px 1fr; gap: 10px; padding: 10px 14px; }
  #response-watch-root .rw-actions { grid-column: 1 / -1; justify-content: flex-end; flex-wrap: wrap; }
  .rw-title, .rw-text { max-width: 100%; }
}
