:root {
  --notif-z-index: var(--app-z-toast, 1100);
  --notif-dropdown-z-index: var(--app-z-dropdown, 200);
}

#toast-container {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--notif-z-index);
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin-left: auto;
  background: #ffffff;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  color: #0f172a;
  padding: 12px;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  pointer-events: auto;
}

.toast--visible {
  transform: translateY(0);
  opacity: 1;
}

.toast--exiting,
.toast--swiped {
  transform: translateX(120%);
  opacity: 0;
}

.toast__icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0fdfa;
  color: #0f766e;
}

.toast__content {
  min-width: 0;
  flex: 1 1 auto;
}

.toast__title {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
}

.toast__message {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.35;
  color: #334155;
}

.toast__time {
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
}

.toast__actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toast__cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  text-decoration: none;
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
}

.toast__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #64748b;
  border-radius: 8px;
}

.toast__close:hover {
  background: #f1f5f9;
}

.toast__progress {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  height: 3px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.15);
  overflow: hidden;
}

.toast__progress::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #2563eb;
  transform-origin: left center;
  animation-name: toast-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  animation-duration: inherit;
}

.toast--success .toast__icon {
  background: #e8f8ef;
  color: #047857;
}

.toast--error .toast__icon {
  background: #fee2e2;
  color: #b91c1c;
}

.toast--warning .toast__icon {
  background: #fff7ed;
  color: #c2410c;
}

.toast--critical {
  border-color: #ef4444;
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.notif-badge {
  position: relative;
}

.notif-badge__count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: var(--font-size-caption, 12px);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(92vw, 360px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: var(--notif-dropdown-z-index);
}

.notif-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.notif-dropdown__header,
.notif-dropdown__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f7;
}

.notif-dropdown__footer {
  border-top: 1px solid #edf2f7;
  border-bottom: 0;
}

.notif-dropdown__title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.notif-dropdown__mark-read,
.notif-dropdown__footer a {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
}

.notif-dropdown__mark-read {
  border: 0;
  background: transparent;
  padding: 0;
}

.notif-dropdown__list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 72px;
}

.notif-loading__spinner {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid #dbeafe;
  border-top-color: #2563eb;
  animation: notif-spin 0.8s linear infinite;
}

@keyframes notif-spin {
  to {
    transform: rotate(360deg);
  }
}

.notif-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
}

.notif-item--unread {
  background: #f8fbff;
}

.notif-item__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0fdfa;
  color: #0f766e;
}

.notif-item__title {
  margin: 0;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
}

.notif-item__message {
  margin: 3px 0 0;
  font-size: 12px;
  color: #334155;
}

.notif-item__meta {
  margin-top: 6px;
  font-size: var(--font-size-caption, 12px);
  color: #64748b;
}

.notif-item__actions {
  display: flex;
  gap: 6px;
}

.notif-item__action {
  width: 24px;
  height: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #475569;
}

@media (max-width: 768px) {
  .toast {
    max-width: 100%;
  }
}

html.dark .toast,
html.dark .notif-dropdown {
  background: #18181b;
  border-color: #27272a;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
  color: #f4f4f5;
}

html.dark .toast__message,
html.dark .notif-item__message {
  color: #d4d4d8;
}

html.dark .toast__time,
html.dark .toast__close,
html.dark .notif-item__meta {
  color: #a1a1aa;
}

html.dark .toast__icon,
html.dark .notif-item__icon {
  background: rgba(20, 184, 166, 0.14);
  color: #5eead4;
}

html.dark .toast__cta,
html.dark .notif-item__action {
  background: #101014;
  border-color: #27272a;
  color: #e4e4e7;
}

html.dark .toast__close:hover,
html.dark .notif-item__action:hover {
  background: #27272a;
}

html.dark .toast__progress {
  background: rgba(20, 184, 166, 0.14);
}

html.dark .toast__progress::after {
  background: #14b8a6;
}

html.dark .notif-dropdown__header,
html.dark .notif-dropdown__footer,
html.dark .notif-item {
  border-color: #27272a;
}

html.dark .notif-dropdown__title,
html.dark .notif-item {
  color: #f4f4f5;
}

html.dark .notif-dropdown__mark-read,
html.dark .notif-dropdown__footer a {
  color: #2dd4bf;
}

html.dark .notif-loading__spinner {
  border-color: rgba(20, 184, 166, 0.22);
  border-top-color: #2dd4bf;
}

html.dark .notif-item--unread {
  background: rgba(20, 184, 166, 0.08);
}
