/* Centro notifiche: campanella nell'header e pannello a comparsa.
   BEM, design token condivisi. Allineato alla tendina utente per coerenza. */

.notif {
  position: relative;
  display: flex;
  align-items: center;
}

/* Campanella */
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-family: inherit;
  color: var(--color-ink-soft);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.notif-bell:hover {
  background-color: var(--color-bg);
  color: var(--color-brand-primary);
}

.notif-bell[aria-expanded="true"] {
  background-color: var(--color-brand-secondary-bg);
  color: var(--color-brand-primary);
}

.notif-bell__icon {
  width: 22px;
  height: 22px;
  display: block;
}

.notif-bell__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--fw-bold);
  line-height: 1;
  color: var(--color-surface);
  background-color: var(--state-anomaly);
  border: 2px solid var(--color-surface);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* Pannello */
.notif-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 380px;
  max-width: calc(100vw - 2 * var(--space-4));
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-raised);
  z-index: var(--z-tooltip);
  overflow: hidden;
}

.notif-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.notif-panel__title {
  font-weight: var(--fw-bold);
  color: var(--color-ink);
}

.notif-panel__action {
  font-family: inherit;
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--color-brand-primary);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.notif-panel__action:hover {
  text-decoration: underline;
}

.notif-panel__tools {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg);
}

.notif-panel__filter {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-caption);
  color: var(--color-ink);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-button);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.notif-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
}

/* Voce notifica */
.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

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

.notif-item:hover {
  background-color: var(--color-bg);
}

.notif-item.is-unread {
  background-color: var(--color-brand-secondary-bg);
}

.notif-item.is-unread:hover {
  background-color: var(--state-ok-bg);
}

.notif-item__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.notif-item__icon svg {
  width: 18px;
  height: 18px;
}

.notif-item--success .notif-item__icon { color: var(--state-ok); background-color: var(--state-ok-bg); }
.notif-item--info .notif-item__icon { color: var(--color-brand-secondary); background-color: var(--color-brand-secondary-bg); }
.notif-item--warning .notif-item__icon { color: var(--state-review); background-color: var(--state-review-bg); }
.notif-item--error .notif-item__icon { color: var(--state-anomaly); background-color: var(--state-anomaly-bg); }

.notif-item__body {
  flex: 1;
  min-width: 0;
}

.notif-item__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.notif-item__agent {
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium);
  color: var(--color-brand-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item__time {
  flex-shrink: 0;
  font-size: var(--fs-caption);
  color: var(--color-muted);
  white-space: nowrap;
}

.notif-item__title {
  display: block;
  margin-top: 2px;
  font-weight: var(--fw-medium);
  color: var(--color-ink);
}

.notif-item__text {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-caption);
  color: var(--color-ink-soft);
}

.notif-empty {
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--color-muted);
}

@media (max-width: 480px) {
  .notif-panel {
    position: fixed;
    top: 64px;
    right: var(--space-4);
    left: var(--space-4);
    width: auto;
  }
}
