/* NOTIFICATIONS: live pop-ups (core/toast.js notifyToast) and the
   Notifications section on Profile (components/notificationSettings.js). */

/* ---- Live pop-up ---- */
.ntoast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(420px, calc(100vw - 24px));
  box-sizing: border-box;
  padding: 13px 10px 15px 14px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  pointer-events: auto;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  animation: toast-in var(--duration-base) var(--ease-out);
}
.ntoast:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.ntoast__icon {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  color: var(--text-primary);
}
.ntoast--ok .ntoast__icon {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.ntoast__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ntoast__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}
.ntoast__body {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ntoast__cta {
  flex: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.ntoast__close {
  flex: none;
  width: 30px;
  height: 30px;
  margin-left: -4px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ntoast__close:hover {
  background: var(--surface-sunken);
}
.ntoast__timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--color-success);
  transform-origin: left;
  animation: ntoast-timer linear forwards;
}
.ntoast--info .ntoast__timer {
  background: var(--text-primary);
}
@keyframes ntoast-timer {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
/* Security alert: dark, no timer, stays until opened or closed. */
.ntoast--alert {
  background: var(--gray-1000, #09090b);
  border-color: var(--gray-1000, #09090b);
  color: #fff;
}
.ntoast--alert .ntoast__icon {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.ntoast--alert .ntoast__body {
  color: #d4d4d8;
}
.ntoast--alert .ntoast__close {
  color: #a1a1aa;
}
.ntoast--alert .ntoast__close:hover {
  background: rgba(255, 255, 255, 0.1);
}
:root[data-theme="dark"] .ntoast--alert {
  border-color: #3f3f46;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ntoast--alert {
    border-color: #3f3f46;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ntoast {
    animation: none;
  }
  .ntoast__timer {
    animation: none;
    opacity: 0;
  }
}

/* ---- Profile → Notifications ---- */
.ns-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--surface-border);
}
.ns-row:last-child {
  border-bottom: 0;
}
.ns-row__icon {
  color: var(--text-secondary);
  display: flex;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 1px;
}
.ns-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ns-row__label {
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ns-row__sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.4;
}
.ns-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  background: var(--surface-sunken);
  color: var(--text-secondary);
}
.ns-pill--on {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.ns-pill--on::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ns-pill--warn {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}
.ns-ctl {
  flex-shrink: 0;
  display: flex;
}
.ns-locked {
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Switch: a real checkbox (keyboard + screen readers), drawn as a pill. */
.ns-switch {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  width: 46px;
  height: 28px;
}
.ns-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.ns-switch input:disabled {
  cursor: default;
}
.ns-switch__track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--surface-border-strong);
  transition: background 0.2s;
}
.ns-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}
.ns-switch input:checked + .ns-switch__track {
  background: var(--text-primary);
}
.ns-switch input:checked + .ns-switch__track::after {
  transform: translateX(18px);
  background: var(--surface-raised); /* white on light, dark knob on a light track in dark */
}
.ns-switch input:focus-visible + .ns-switch__track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.ns-switch input:disabled + .ns-switch__track {
  opacity: 0.5;
}
@media (prefers-reduced-motion: reduce) {
  .ns-switch__track,
  .ns-switch__track::after {
    transition: none;
  }
}

.ns-extra {
  border-top: 1px solid var(--surface-border);
  padding: 10px 14px 14px 45px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: var(--text-sm);
}
.ns-extra:empty {
  display: none;
}
.ns-steps {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.55;
}
.ns-steps strong {
  color: var(--text-primary);
}
.ns-foot {
  margin: 8px 4px 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-secondary);
}

/* "You'll hear about" (residents, inside the push card) and "Always sent". */
.ns-hear {
  border-top: 1px solid var(--surface-border);
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ns-hear__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}
.ns-always {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ns-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-base);
}
.ns-item__mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-sunken);
  color: var(--text-secondary);
}
.ns-item__mark--ok {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.ns-locked {
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
}
#ns-turn-on {
  margin: 0;
}

/* Gate posts: push is required. Red banner on Scan while it's off. */
.ns-banner {
  border: 1px solid #fecaca;
  border-radius: var(--radius-xl);
  background: #fef2f2;
  color: #7f1d1d;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ns-banner[hidden] {
  display: none;
}
.ns-banner__top {
  display: flex;
  gap: 12px;
}
.ns-banner__icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: #fee2e2;
  color: #b91c1c;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ns-banner__text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ns-banner__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.ns-banner__sub {
  font-size: var(--text-sm);
  line-height: 1.45;
  color: #991b1b;
}
.ns-banner__btn {
  height: 48px;
  border: 0;
  border-radius: var(--radius-lg);
  background: #b91c1c;
  color: #fff;
  font: inherit;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.ns-banner__btn:disabled {
  opacity: 0.6;
}
:root[data-theme="dark"] .ns-banner {
  background: #2a1416;
  border-color: #5b1d1d;
  color: #fecaca;
}
:root[data-theme="dark"] .ns-banner__sub {
  color: #fca5a5;
}
:root[data-theme="dark"] .ns-banner__icon {
  background: #451a1d;
  color: #fca5a5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ns-banner {
    background: #2a1416;
    border-color: #5b1d1d;
    color: #fecaca;
  }
  :root:not([data-theme="light"]) .ns-banner__sub {
    color: #fca5a5;
  }
  :root:not([data-theme="light"]) .ns-banner__icon {
    background: #451a1d;
    color: #fca5a5;
  }
}
