/* Notificações estilo iPhone (appAlert) */

#app-alert-stack {
  position: fixed;
  top: calc(var(--ui-topbar-h, 66px) + 12px + env(safe-area-inset-top, 0px));
  right: 12px;
  left: auto;
  z-index: 11050;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(390px, calc(100vw - 24px));
  pointer-events: none;
}

#app-mention-stack {
  position: fixed;
  top: calc(var(--ui-topbar-h, 66px) + 12px + env(safe-area-inset-top, 0px));
  right: 12px;
  left: auto;
  z-index: 11049;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(390px, calc(100vw - 24px));
  pointer-events: none;
}

#app-alert-stack .ios-toast,
#app-mention-stack .ios-toast {
  pointer-events: auto;
  touch-action: none;
}

/* Sobrescreve .app-alert.animate legado (app.all.css) que empurra o toast para fora da tela */
#app-alert-stack .ios-toast.app-alert,
#app-mention-stack .ios-toast.app-alert,
.ios-toast.app-alert.animate {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  z-index: auto !important;
  border-radius: 18px !important;
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.18),
    0 2px 8px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.65) !important;
}

.ios-toast.alert-success,
.ios-toast.alert-danger,
.ios-toast.alert-warning,
.ios-toast.alert-info {
  background: rgba(255, 255, 255, 0.82) !important;
  color: #0f172a !important;
}

.ios-toast {
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.18),
    0 2px 8px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  color: #0f172a;
  opacity: 0;
  transform: translate3d(110%, 0, 0) scale(0.96);
  transition:
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease;
  will-change: transform, opacity;
  cursor: grab;
  user-select: none;
}

.ios-toast.is-visible {
  opacity: 1 !important;
  transform: translate3d(0, 0, 0) scale(1);
}

.ios-toast.is-dragging {
  cursor: grabbing;
  transition: none;
}

.ios-toast.is-snapping {
  transition:
    transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.24s ease;
}

.ios-toast.is-dismissing {
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 1, 1),
    opacity 0.28s ease;
  pointer-events: none;
}

.ios-toast__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 42%);
  pointer-events: none;
}

.ios-toast__inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}

.ios-toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
}

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

.ios-toast__title {
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.ios-toast__message,
.ios-toast .app-alert-message {
  display: block;
  margin: 0;
  max-width: none;
  min-width: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
  color: #334155;
  word-break: break-word;
}

.ios-toast .progress,
.ios-toast .btn-close {
  display: none !important;
}

.ios-toast.alert-success .ios-toast__icon {
  background: rgba(34, 197, 94, 0.14);
  color: #16a34a;
}

.ios-toast.alert-success .ios-toast__title {
  color: #15803d;
}

.ios-toast.alert-danger .ios-toast__icon {
  background: rgba(239, 68, 68, 0.14);
  color: #dc2626;
}

.ios-toast.alert-danger .ios-toast__title {
  color: #b91c1c;
}

.ios-toast.alert-warning .ios-toast__icon {
  background: rgba(245, 158, 11, 0.16);
  color: #d97706;
}

.ios-toast.alert-warning .ios-toast__title {
  color: #b45309;
}

.ios-toast.alert-info .ios-toast__icon {
  background: rgba(56, 164, 248, 0.14);
  color: #0284c7;
}

.ios-toast.alert-info .ios-toast__title {
  color: #0369a1;
}

.ios-toast .undo-delete {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8125rem;
}

.ios-toast .undo-delete strong {
  color: inherit;
}

/* Toast de menção @ em comentário de tarefa (mesmo stack) */
.ios-toast--mention .ios-toast__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.ios-toast--mention .ios-toast__avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(15, 23, 42, 0.1);
  background: #fff;
}

.ios-toast--mention .ios-toast__avatar-ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(15, 23, 42, 0.1);
  background: #e2e8f0;
  color: #475569;
}

.ios-toast--mention .ios-toast__title {
  font-size: 0.875rem;
  color: #0f172a;
}

.ios-toast--mention .ios-toast__subtitle {
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #64748b;
  margin-top: 1px;
}

.ios-toast--mention .ios-toast__task {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  margin-top: 5px;
  color: #1d4ed8;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.ios-toast--mention .ios-toast__nav {
  color: inherit;
  text-decoration: none;
}

.ios-toast--mention .ios-toast__nav:hover {
  text-decoration: underline;
}

.ios-toast--mention .ios-toast__message {
  font-size: 0.75rem;
  margin-top: 6px;
  max-height: 3.2em;
  overflow: hidden;
}

body[data-color="1E202D"] .ios-toast--mention .ios-toast__title,
body[data-color="1e202d"] .ios-toast--mention .ios-toast__title {
  color: #f1f5f9;
}

body[data-color="1E202D"] .ios-toast--mention .ios-toast__subtitle,
body[data-color="1e202d"] .ios-toast--mention .ios-toast__subtitle {
  color: #94a3b8;
}

body[data-color="1E202D"] .ios-toast--mention .ios-toast__task,
body[data-color="1e202d"] .ios-toast--mention .ios-toast__task {
  color: #93a8ff;
}

body[data-color="1E202D"] .ios-toast--mention .ios-toast__avatar-img,
body[data-color="1e202d"] .ios-toast--mention .ios-toast__avatar-img {
  border-color: rgba(255, 255, 255, 0.12);
  background: #2a303c;
}

body[data-color="1E202D"] .ios-toast--mention .ios-toast__avatar-ph,
body[data-color="1e202d"] .ios-toast--mention .ios-toast__avatar-ph {
  border-color: rgba(255, 255, 255, 0.12);
  background: #323948;
  color: #aeb6ce;
}

/* Stack legado de menções (substituído por #app-mention-stack) */
.task-mention-toast-stack {
  display: none !important;
}

/* Esconde notificações legadas fora do stack */
body > .app-alert.animate:not(.ios-toast),
body > .alert.app-alert:not(.ios-toast) {
  display: none !important;
}

/* Modo escuro */
body[data-color="1E202D"] .ios-toast,
body[data-color="1e202d"] .ios-toast {
  background: rgba(28, 31, 38, 0.88);
  color: #e8ebf3;
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.42),
    0 2px 8px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body[data-color="1E202D"] .ios-toast__shine,
body[data-color="1e202d"] .ios-toast__shine {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%);
}

body[data-color="1E202D"] .ios-toast__message,
body[data-color="1e202d"] .ios-toast__message,
body[data-color="1E202D"] .ios-toast .app-alert-message,
body[data-color="1e202d"] .ios-toast .app-alert-message {
  color: #c4cbdd;
}

body[data-color="1E202D"] .ios-toast.alert-success .ios-toast__title,
body[data-color="1e202d"] .ios-toast.alert-success .ios-toast__title {
  color: #86efac;
}

body[data-color="1E202D"] .ios-toast.alert-danger .ios-toast__title,
body[data-color="1e202d"] .ios-toast.alert-danger .ios-toast__title {
  color: #fca5a5;
}

body[data-color="1E202D"] .ios-toast.alert-warning .ios-toast__title,
body[data-color="1e202d"] .ios-toast.alert-warning .ios-toast__title {
  color: #fcd34d;
}

body[data-color="1E202D"] .ios-toast.alert-info .ios-toast__title,
body[data-color="1e202d"] .ios-toast.alert-info .ios-toast__title {
  color: #7dd3fc;
}

/* RTL */
html[dir="rtl"] #app-alert-stack,
body[dir="rtl"] #app-alert-stack,
html[dir="rtl"] #app-mention-stack,
body[dir="rtl"] #app-mention-stack {
  right: auto;
  left: 12px;
}

html[dir="rtl"] .ios-toast,
body[dir="rtl"] .ios-toast {
  transform: translate3d(-110%, 0, 0) scale(0.96);
}

html[dir="rtl"] .ios-toast.is-visible,
body[dir="rtl"] .ios-toast.is-visible {
  transform: translate3d(0, 0, 0) scale(1);
}

@media (max-width: 767px) {
  #app-alert-stack,
  #app-mention-stack {
    top: calc(var(--ui-topbar-h, 66px) + 10px + env(safe-area-inset-top, 0px));
    right: 10px;
    width: min(390px, calc(100vw - 20px));
  }

  html[dir="rtl"] #app-alert-stack,
  body[dir="rtl"] #app-alert-stack,
  html[dir="rtl"] #app-mention-stack,
  body[dir="rtl"] #app-mention-stack {
    left: 10px;
  }
}
