/* Notificações - Custom CSS Adaptado do Tailwind */

/* Wrapper fixo no topo direito, com auto-hide no scroll */
.sino-fixed-wrapper {
  position: fixed;
  top: 12px;
  right: 12px;
  /* z-index abaixo de modais (1055), toasts (1090), popovers (1070) e tooltips (1080) do Bootstrap,
     mas acima do conteúdo normal — mesmo nível do .fixed-top padrão. */
  z-index: 1030;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.sino-fixed-wrapper.sino-hidden {
  transform: translateY(-150%);
  opacity: 0;
  pointer-events: none;
}

/* No mobile a navbar exibe o botão hamburguer (.menu-toggle-btn) no canto
   superior direito. O sino fixo (right: 12px) cairia exatamente sobre ele,
   então o deslocamos para a esquerda do hamburguer, evitando a sobreposição. */
@media (max-width: 991.98px) {
  .sino-fixed-wrapper {
    right: 66px;
  }
}

/* Mapeia o sino sobre os tokens de design da aplicacao (style.css),
   para herdar a paleta, o tema claro/escuro e os raios/sombras globais.
   Nao redefinir cores fixas aqui — usar sempre as variaveis do tema. */
:root {
  --sino-surface: var(--bg-elevated);
  --sino-bg: var(--bg-main);
  --sino-primary: var(--link);
  --sino-text: var(--text-main);
  --sino-muted: var(--text-muted);
  --sino-border: var(--border-color);
  --sino-hover: color-mix(in srgb, var(--link) 10%, transparent);
  --sino-unread: color-mix(in srgb, var(--link) 8%, transparent);
  --sino-danger: var(--color-danger);
}

/* Container do Sino na Navbar */
.nav-notificacoes {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sino-btn {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--sino-muted);
  position: relative;
  /* Dimensoes iguais + aspect-ratio garantem um circulo perfeito
     (sem depender da largura do glifo, que deixava o botao oval). */
  width: 2.5rem;
  height: 2.5rem;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 50%;
  box-shadow: var(--shadow-2);
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sino-btn:hover {
  background-color: var(--sino-hover);
  color: var(--link);
  box-shadow: var(--shadow-3);
}

.sino-btn i {
  font-size: 1.25rem;
}

.sino-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: var(--sino-danger);
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.15rem 0.3rem;
  border-radius: 9999px;
  line-height: 1;
  min-width: 18px;
  text-align: center;
  border: 2px solid var(--bg-elevated);
}

/* Animação do Sino (Pulse Ring) */
.sino-badge.pulse {
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Popover Dropdown */
.notificacoes-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  width: 350px;
  background-color: var(--sino-surface);
  border: 1px solid var(--sino-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  z-index: 1050;
  display: none; /* hidden by default */
  flex-direction: column;
  overflow: hidden;
}

.notificacoes-dropdown.show {
  display: flex;
  animation: slideDown 0.2s ease-out;
}

/* Telas pequenas: o dropdown de 350px ancorado a direita do sino estoura pela
   esquerda e corta o conteudo. Fora da topbar (sino flutuante: login, perfil,
   alterar senha), prendemos o dropdown a viewport com folga nas duas bordas.
   A variante dentro da topbar tem tratamento proprio em _topbar.css. */
@media (max-width: 575.98px) {
  .sino-fixed-wrapper .notificacoes-dropdown {
    position: fixed;
    top: 3.75rem;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
  }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cabeçalho do Dropdown */
.notificacoes-header {
  padding: 1rem;
  border-bottom: 1px solid var(--sino-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--sino-bg);
}

.notificacoes-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--sino-text);
  margin: 0;
}

.notificacoes-mark-read {
  font-size: 0.8rem;
  color: var(--sino-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}

.notificacoes-mark-read:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Lista de Notificações */
.notificacoes-body {
  max-height: 300px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.notificacao-item {
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  border-bottom: 1px solid var(--sino-border);
  transition: background-color 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.notificacao-item:last-child {
  border-bottom: none;
}

.notificacao-item:hover {
  background-color: var(--sino-hover);
}

.notificacao-item.unread {
  background-color: var(--sino-unread);
}

.notificacao-icon {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--link) 14%, transparent);
  color: var(--sino-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
  font-size: 1.1rem;
}

.notificacao-content {
  flex: 1;
  min-width: 0;
}

.notificacao-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--sino-text);
  margin: 0 0 0.25rem 0;
}

.notificacao-item-text {
  font-size: 0.85rem;
  color: var(--sino-muted);
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  /* Truncate multi-line */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notificacao-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* Footer do Dropdown */
.notificacoes-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sino-border);
  text-align: center;
  background-color: var(--sino-bg);
}

.notificacoes-view-all {
  font-size: 0.85rem;
  color: var(--sino-primary);
  text-decoration: none;
  font-weight: 500;
}

.notificacoes-view-all:hover {
  text-decoration: underline;
}

/* Notificações vazias */
.notificacoes-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--sino-muted);
}
.notificacoes-empty i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--border-color);
}
