/* ── Toast Notifications & Notification Bell ─────────────────────────────── */

/* ── Toast Container ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.625rem;
  pointer-events: none;
  width: min(360px, calc(100vw - 3rem));
}

/* ── Individual Toast ────────────────────────────────────────────────────── */
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  padding: 0.875rem 0.875rem 0.875rem 1rem;
  position: relative;
  overflow: hidden;
  animation: toast-in 0.3s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

.toast--leaving {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(3rem) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toast-out {
  0%   { opacity: 1; transform: translateX(0); max-height: 120px; padding-top: 0.875rem; padding-bottom: 0.875rem; }
  100% { opacity: 0; transform: translateX(3rem); max-height: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
}

/* Accent border — right side (RTL visual start) */
.toast::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 3px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.toast--success::before { background: var(--color-success); }
.toast--error::before   { background: var(--color-danger); }
.toast--warning::before { background: #f0b84b; }
.toast--info::before    { background: var(--color-primary); }

/* ── Toast Icon ──────────────────────────────────────────────────────────── */
.toast__icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast--success .toast__icon { background: rgba(63,185,80,0.15);  color: var(--color-success); }
.toast--error   .toast__icon { background: rgba(248,81,73,0.15);  color: var(--color-danger); }
.toast--warning .toast__icon { background: rgba(210,153,34,0.14); color: #f0b84b; }
.toast--info    .toast__icon { background: rgba(47,129,247,0.1);  color: var(--color-primary); }

/* ── Toast Body ──────────────────────────────────────────────────────────── */
.toast__body { flex: 1; min-width: 0; }

.toast__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
}

.toast__msg {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-top: 0.15rem;
}

/* ── Clickable toast ─────────────────────────────────────────────────────── */
.toast--clickable {
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.toast--clickable:hover {
  background: var(--color-surface2);
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
}

/* ── Close Button ────────────────────────────────────────────────────────── */
.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.toast__close:hover {
  color: var(--color-text);
  background: var(--color-surface2);
}

/* ── Progress Bar ────────────────────────────────────────────────────────── */
.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 3px;
  height: 2px;
  overflow: hidden;
}

.toast__progress-fill {
  height: 100%;
  width: 100%;
  transform-origin: right;
  animation: toast-progress linear forwards;
}
.toast--success .toast__progress-fill { background: var(--color-success); }
.toast--error   .toast__progress-fill { background: var(--color-danger); }
.toast--warning .toast__progress-fill { background: #f0b84b; }
.toast--info    .toast__progress-fill { background: var(--color-primary); }

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

/* ── Notification Bell ───────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
}

.notif-bell__btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: color var(--transition), background var(--transition);
}
.notif-bell__btn:hover,
.notif-bell__btn.has-unread {
  color: var(--color-text);
}
.notif-bell__btn:hover {
  background: var(--color-surface2);
}

/* Badge */
.notif-badge {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 1rem;
  height: 1rem;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 0.2rem;
  line-height: 1;
}

/* ── Notification Dropdown ───────────────────────────────────────────────── */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 1000;
  overflow: hidden;
  display: none;
}

.notif-dropdown.open {
  display: block;
  animation: notif-in 0.18s ease both;
}

@keyframes notif-in {
  from { opacity: 0; transform: translateY(-0.4rem); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.notif-dropdown__header h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.notif-read-all {
  font-size: 0.75rem;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
}
.notif-read-all:hover { color: var(--color-primary-hover); }

/* ── Notification List ───────────────────────────────────────────────────── */
.notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.notif-list::-webkit-scrollbar { width: 4px; }
.notif-list::-webkit-scrollbar-track { background: transparent; }
.notif-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface2); }

.notif-item__icon {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.notif-item--wallet   .notif-item__icon { background: rgba(47,129,247,0.1);  color: var(--color-primary); }
.notif-item--messenger .notif-item__icon { background: rgba(63,185,80,0.15); color: var(--color-success); }
.notif-item--default  .notif-item__icon { background: var(--color-surface2); color: var(--color-text-muted); }

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

.notif-item__title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.notif-item__msg {
  font-size: 0.77rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item__time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Empty state */
.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #toast-container {
    bottom: 1rem;
    right: 1rem;
    width: calc(100vw - 2rem);
  }

  .notif-dropdown {
    width: calc(100vw - 2rem);
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  .notif-dropdown.open {
    transform: translateX(-50%) translateY(0);
    animation: none;
  }
}
