/* =====================================================================
   Recovery widget — barra flutuante de leads pendentes
   ===================================================================== */

.rw {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 340px;
  max-width: calc(100vw - 28px);
  background: #ffffff;
  color: #232323;
  border: 1px solid rgba(35,35,35,.10);
  border-radius: 12px;
  z-index: 75; /* abaixo dos dialogs (60-70), acima do conteúdo */
  font-family: 'Manrope', system-ui, sans-serif;
  box-shadow: none;
  transform: translateY(0);
  transition: transform .2s ease, opacity .2s ease;
}
.rw[hidden] { display: none; }
.rw.is-minimized .rw__list { display: none; }
.rw.is-minimized { width: auto; }
.rw.is-minimized .rw__title { max-width: 160px; }

/* Pulse quando minimizado E houver leads pendentes (count != is-zero).
   Some quando aberto (sem .is-minimized) ou vazio (count.is-zero). */
@keyframes rw-pulse-ring {
  0%   { box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 0 0 0   rgba(47,128,237,.55); }
  70%  { box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 0 0 14px rgba(47,128,237,0); }
  100% { box-shadow: 0 4px 16px rgba(0,0,0,.12), 0 0 0 0   rgba(47,128,237,0); }
}
@keyframes rw-count-pop {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.14); }
}
.rw.is-minimized:not(:has(.rw__count.is-zero)) {
  animation: rw-pulse-ring 1.8s ease-out infinite;
}
.rw.is-minimized:not(:has(.rw__count.is-zero)) .rw__count {
  animation: rw-count-pop 1.8s ease-in-out infinite;
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  .rw.is-minimized:not(:has(.rw__count.is-zero)),
  .rw.is-minimized:not(:has(.rw__count.is-zero)) .rw__count {
    animation: none;
  }
}

.rw__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  background: #4b2cff; /* verde escuro Madenorte — destaca contra o fundo claro */
  border-radius: 12px 12px 0 0;
  cursor: pointer; /* o cabeçalho inteiro expande/contrai */
}
.rw.is-minimized .rw__head { border-bottom: 0; border-radius: 12px; }
.rw__title {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .2px;
}
.rw__title i { font-size: 12px; color: rgba(255,255,255,.85); }
.rw__count {
  background: #2f80ed;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.rw__count.is-zero { background: rgba(255,255,255,.22); color: #fff; }
.rw__minimize {
  margin-left: auto;
  background: transparent;
  border: 0;
  width: 22px; height: 22px;
  border-radius: 6px;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rw__minimize:hover { background: rgba(255,255,255,.16); color: #fff; }

.rw__list {
  max-height: 460px;
  overflow-y: auto;
  padding: 8px;
}
.rw__list::-webkit-scrollbar { width: 6px; }
.rw__list::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 4px; }
.rw__empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 12px;
  color: #6f7772;
}

/* Pílula de alerta */
.rw-pill {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(35,35,35,.08);
  background: #fafafa;
  margin-bottom: 6px;
  transition: background .15s ease, border-color .15s ease, opacity .25s ease, transform .25s ease;
  flex-wrap: wrap;
}
.rw-pill:last-child { margin-bottom: 0; }
.rw-pill:hover { background: #f4f6f5; border-color: rgba(35,35,35,.16); }
.rw-pill.is-leaving { opacity: 0; transform: translateX(40px); pointer-events: none; }

/* --- Tipo: operador devendo (URGENTE, vermelho claro) --- */
.rw-pill.rw-pill--op {
  background: rgba(194, 65, 74, .10);
  border-color: rgba(194, 65, 74, .25);
}
.rw-pill.rw-pill--op:hover {
  background: rgba(194, 65, 74, .14);
  border-color: rgba(194, 65, 74, .45);
}

/* --- Tipo: cliente em silêncio (neutro, amarelo discreto opcional) --- */
.rw-pill.rw-pill--cli {
  background: #fafafa;
  border-color: rgba(35,35,35,.08);
}

/* --- Tipo: follow-up agendado (verde escuro Madenorte) --- */
.rw-pill.rw-pill--followup {
  background: rgba(75, 44, 255, .07);
  border-color: rgba(75, 44, 255, .28);
}
.rw-pill.rw-pill--followup:hover {
  background: rgba(75, 44, 255, .11);
  border-color: rgba(75, 44, 255, .45);
}
.rw-pill__type--followup { background: #4b2cff; }  /* follow-up: verde escuro */
.rw-pill--followup .rw-pill__time {
  background: rgba(75, 44, 255, .14);
  color: #4b2cff;
}
.rw-pill--followup .rw-pill__label { color: #4b2cff; }

.rw-pill__type {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
.rw-pill__type--op  { background: #c2414a; }  /* operador devendo: vermelho (urgente) */
.rw-pill__type--cli { background: #6f7772; }  /* cliente em silêncio: cinza */

.rw-pill__body {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Linha do topo: nome + chip de tempo na direita */
.rw-pill__top {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.rw-pill__name {
  font-size: 13px;
  font-weight: 700;
  color: #232323;
  min-width: 0;
  flex: 1 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rw-pill__time {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.08);
  color: #495157;
  white-space: nowrap;
}
.rw-pill--op .rw-pill__time {
  background: rgba(194, 65, 74, .18);
  color: #c2414a;
}
.rw-pill__label {
  font-size: 11px;
  color: #6f7772;
  font-weight: 600;
}
.rw-pill--op .rw-pill__label { color: #c2414a; }

.rw-pill__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.rw-pill__btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 7px;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, color .15s, transform .05s;
  position: relative;
}
.rw-pill__btn i { font-size: 11px; }
.rw-pill__btn--primary { background: #2f80ed; color: #fff; }
.rw-pill__btn--primary:hover { background: #1e6fe0; }
.rw-pill__btn--primary:active { transform: scale(.97); }
.rw-pill__btn--primary:disabled { opacity: .6; cursor: wait; }
.rw-pill__btn--ghost {
  background: transparent; color: #6f7772; border: 1px solid rgba(35,35,35,.14);
  flex: 0 0 auto; padding: 7px 10px;
}
.rw-pill__btn--ghost:hover { background: rgba(0,0,0,.05); color: #232323; }

.rw-pill__owner-info {
  flex: 1;
  font-size: 11px;
  color: #6f7772;
  padding: 7px 10px;
  background: rgba(0,0,0,.04);
  border-radius: 7px;
  text-align: center;
}

/* Tooltip do botão Disparar — mostra a mensagem que será enviada */
.rw-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0; right: 0;
  background: rgba(15, 25, 40, .96);
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: 7px;
  z-index: 80;
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}
.rw-tip::before { content: '↓ Mensagem que será enviada:'; display: block; font-size: 9px; opacity: .65; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.rw-pill__btn--primary:hover .rw-tip { opacity: 1; }

/* Posicionamento em telas pequenas */
@media (max-width: 600px) {
  .rw { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
}
