/* ============================================================
   rx-core — Centro de notificações (CANÓNICO, partilhado)
   Sino na nav + painel (filtros, lista, menu de opções). 100% genérico —
   sem qualquer conhecimento de domínio (análises, etc.); isso vive em quem
   chama (ex.: notifications.js fornece os items e o formato dos mesmos).
   Toasts: ver rx-core/toast.css (componente RXToast, usado internamente
   pelo motor deste componente — rx-core/notification-center.js).
   ============================================================ */


.notif-wrap { position: relative; display: inline-flex; }
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--wire, #ffffff1e);
  border-radius: 8px;
  color: var(--text-2, #b8b8cc);
  cursor: pointer;
  padding: 0.4375rem 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.notif-bell:hover { color: var(--text, #e8e8f0); border-color: var(--wire-2, #ffffff28); background: var(--ghost, #ffffff0d); }

.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-family: var(--rx-font-body);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--ink, #0a0a0f);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 2rem);
  /* Fallback (sem .open ainda aplicado); o tamanho real é fixado abaixo. */
  max-height: min(420px, calc(100vh - 6rem));
  overflow: hidden;
  background: var(--ink-2, #16161f);
  /* Borda âmbar-tintada — mesma linguagem visual já usada nos outros
     elementos "sticky"/flutuantes da app (ex: .nav-pills-wrap.is-stuck),
     em vez de um cinzento neutro qualquer. Dá ao contentor um contorno
     bem definido, a destacar-se claramente do conteúdo da página que
     fica por trás (evita a sensação de "ver o que está por baixo"). */
  border: 1px solid color-mix(in srgb, var(--amber, #f5a623) 40%, var(--wire-2, #ffffff28));
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  display: none;
  flex-direction: column;
  z-index: 200;
}
.notif-panel.open {
  display: flex;
  /* Altura FIXA (não max-height): a caixa mantém sempre o mesmo tamanho,
     com poucos ou muitos itens — evita o "encolher" estranho ao trocar de
     filtro ou quando há só 1-2 notificações. Nunca excede o ecrã visível. */
  height: min(420px, calc(100vh - 6rem));
}

/* Mobile: o painel deixa de ser ancorado ao botão do sino (que não está
   necessariamente perto da margem direita real — há outros ícones depois
   dele) e passa a ser ancorado ao próprio ecrã (fixed). Sem isto, o painel
   de 340px abria para a esquerda a partir do sino e saía do ecrã por mais
   de 50px (confirmado por medição) — o utilizador via o painel cortado. */
@media (max-width: 600px) {
  .notif-panel {
    position: fixed;
    top: calc(var(--nav-h, 59px) + 0.5rem);
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
  }
  .notif-panel.open {
    height: min(420px, calc(100vh - var(--nav-h, 59px) - 2rem));
  }
}

/* Contentor único sticky — header + filtros movem-se juntos, colados ao
   topo, sem precisar de calcular a altura exacta de cada um para os
   empilhar com offsets manuais. Antes só a faixa de filtros ficava fixa;
   o header ("Notificações" + "⋮") desaparecia ao rolar — pedido para
   ficarem os dois sempre visíveis juntos. */
.notif-sticky-top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--ink-2, #16161f);
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--wire, #ffffff1e);
  flex-shrink: 0;
}
.notif-panel-title {
  font-family: var(--rx-font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text, #e8e8f0);
}

.notif-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--wire-2, #ffffff1e) transparent;
}
.notif-items {
  display: flex;
  flex-direction: column;
  /* Compensa o .notif-bottom-fade (sticky, sobrepõe-se sempre aos últimos
     ~1.25rem visíveis) — sem isto, a ÚLTIMA notificação real ficava por
     baixo do fade quando se chegava ao fim do scroll, com o título a
     aparecer cortado/a desvanecer a meio. O gradiente do fade fica 100%
     opaco (cor sólida) aos 45% da sua altura (~0.56rem com o fade agora
     em 1.25rem) — por isso o padding tem de ser maior que esse ponto. */
  padding-bottom: 0.75rem;
}
.notif-item:last-child { border-bottom: none; }
/* Desvanecimento fixo ao FUNDO da área de scroll (sticky, não no fim
   absoluto da lista) — qualquer notificação que esteja visível no limite
   inferior do painel, em QUALQUER posição de scroll, nunca fica "colada"
   à borda; este elemento sobrepõe-se sempre por cima dela com um gradiente
   suave até à cor de fundo do painel. */
.notif-bottom-fade {
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  /* 1.25rem, não 2.5rem — o valor anterior ocupava quase a altura de uma
     notificação inteira, SEMPRE visível (mesmo a meio da lista, não só
     no fim), dando a sensação de que o conteúdo ficava sempre distante
     da borda do painel. */
  height: 1.25rem;
  margin-top: -1.25rem;
  background: linear-gradient(to bottom, transparent, var(--ink-2, #16161f) 45%, var(--ink-2, #16161f) 100%);
  pointer-events: none;
  flex-shrink: 0;
  z-index: 4;
}
html.light .notif-bottom-fade {
  background: linear-gradient(to bottom, transparent, var(--ink-2, #ffffff) 45%, var(--ink-2, #ffffff) 100%);
}
.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--wire-2, #ffffff1e); border-radius: 99px; }
.notif-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
  font-family: var(--rx-font-body);
  font-size: 0.8125rem;
  color: var(--text-3, #888898);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5625rem 0.875rem;
  border-bottom: 1px solid var(--wire, #ffffff12);
  position: relative;
}
.notif-item.unread { background: color-mix(in srgb, var(--amber, #f5a623) 6%, transparent); }
.notif-item.unread::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.95rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber, #f5a623);
}
.notif-item-icon { flex-shrink: 0; margin-top: 0.1rem; }
.notif-item-icon.notif-error { color: #f87171; }
.notif-item-icon.notif-success { color: #4ade80; }
.notif-item-icon.notif-info { color: var(--rx-accent-text); }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-row1 {
  display: flex;
  align-items: baseline;
}
.notif-item-title {
  flex: 1;
  min-width: 0;
  font-family: var(--rx-font-body);
  font-weight: 600;
  font-size: 0.78125rem;
  color: var(--text, #e8e8f0);
  line-height: 1.3;
  /* 2 linhas, não 1 (Aug 2026, bug real corrigido) — títulos gerados
     (nome + plataforma + contagem, ver notifications.js/formatLabel de
     cada produto) são normalmente longos de mais para uma linha só a
     340px de largura; cortavam quase sempre. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item-msg {
  font-family: var(--rx-font-body);
  font-size: 0.71875rem;
  line-height: 1.3;
  color: var(--text-2, #b8b8cc);
}
.notif-item-sep { color: var(--text-3, #888898); }
.notif-item-link-hint {
  color: var(--rx-accent-text);
  font-size: 0.6875rem;
  opacity: 0.85;
}
.notif-item-time {
  font-family: var(--rx-font-mono);
  font-size: 0.65625rem;
  color: var(--text-3, #888898);
}
.notif-item-retry-row { margin-top: 0.2rem; }
.notif-retry {
  font-family: var(--rx-font-body);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--rx-accent-text);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.notif-retry:hover { text-decoration: underline; }

.notif-item-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-3, #888898);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 5px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.notif-item-dismiss:hover { color: var(--text, #e8e8f0); opacity: 1; }
.notif-item-dismiss:active { opacity: 1; }

/* ── Menu de opções (⋮) — substitui os botões sempre-visíveis ── */
.notif-menu-wrap { position: relative; }
.notif-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-3, #888898);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: color 0.15s, background 0.15s;
}
.notif-menu-btn:hover { color: var(--text, #e8e8f0); background: var(--ghost, #ffffff0d); }
.notif-menu-btn:focus-visible { outline: 2px solid var(--amber, #f5a623); outline-offset: 1px; }

.notif-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  min-width: 180px;
  background: var(--ink-3, #1e1e2a);
  border: 2px solid var(--wire-2, #ffffff28);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 0.3rem;
  z-index: 210;
  flex-direction: column;
  gap: 0.05rem;
}
.notif-menu-dropdown.open { display: flex; }
.notif-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--rx-font-body);
  font-size: 0.78125rem;
  font-weight: 500;
  color: var(--text-2, #b8b8cc);
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: background 0.15s, color 0.15s;
}
.notif-menu-dropdown button:hover { background: var(--ghost, #ffffff0d); color: var(--text, #e8e8f0); }

/* ── Pills de filtro por tipo ─────────────────────────────────── */
.notif-filter-row {
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--wire, #ffffff1e);
  flex-shrink: 0;
  /* Sombra subtil para se destacar do conteúdo que desliza por baixo. */
  box-shadow: 0 6px 10px -8px rgba(0, 0, 0, 0.5);
}
.notif-filter-pills {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--ghost-2, #ffffff14);
  border-radius: 10px;
}
.notif-filter-pill {
  position: relative;
  flex: 1 1 33.33%;
  text-align: center;
  font-family: var(--rx-font-body);
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--text-3, #888898);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.3125rem 0.625rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.notif-filter-pill:hover { color: var(--text-2, #b8b8cc); }
.notif-filter-pill.active {
  background: var(--amber, #f5a623);
  color: var(--rx-accent-contrast);
}

/* Ponto de indicador de não lidas por separador (Sucesso/Erro) — "Tudo"
   não tem, o badge do sino já mostra o total global, seria redundante. */
.notif-tab-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red, #ef4444);
  margin-left: 0.3rem;
  vertical-align: middle;
}
.notif-filter-pill.active .notif-tab-dot { background: var(--rx-accent-contrast); }

/* Cabeçalho de agrupamento por tempo (Hoje/Ontem/Esta semana/Mais
   antigas) — discreto, só para orientar a leitura de uma lista longa. */
.notif-group-header {
  font-family: var(--rx-font-body);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3, #888898);
  padding: 0.625rem 0.875rem 0.25rem;
}