/* ============================================================
   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: 'DM Sans', sans-serif;
  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);
  border: 1px solid 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));
}

/* Header + filtros vivem DENTRO da zona de scroll (.notif-list), como um
   bloco "sticky" — isto é o que garante, de forma inequívoca e bem definida
   pelo CSS (sem depender de estarem "fora" do scroll), que nunca desaparecem
   ao fazer scroll: ficam sempre colados ao topo da área visível. */
/* Header ("Notificações" + "⋮") é conteúdo NORMAL — desaparece ao rolar a
   lista para baixo, tal como qualquer conteúdo. Só a faixa de filtros (a
   seguir) fica fixa, substituindo-o visualmente. */
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--wire, #ffffff1e);
  background: var(--ink-2, #16161f);
  flex-shrink: 0;
}
.notif-panel-title {
  font-family: 'Syne', sans-serif;
  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;
}
.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%;
  height: 2.5rem;
  margin-top: -2.5rem;
  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: 'DM Sans', sans-serif;
  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(--amber, #f5a623); }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-row1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.notif-item-title {
  flex: 1;
  min-width: 0;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.78125rem;
  color: var(--text, #e8e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-item-msg {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.71875rem;
  line-height: 1.3;
  color: var(--text-2, #b8b8cc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-item-time {
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  font-size: 0.65625rem;
  color: var(--text-3, #888898);
}
.notif-item-retry-row { margin-top: 0.2rem; }
.notif-retry {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--amber, #f5a623);
  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: 1px 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: 'DM Sans', sans-serif;
  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 {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--wire, #ffffff1e);
  background: var(--ink-2, #16161f);
  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 {
  flex: 1 1 50%;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  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(--ink, #0a0a0f);
}