/* Toast + dialoghi di conferma BMS */

.bms-toast-stack {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.65rem;
  padding:
    max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
  pointer-events: none;
}

.bms-toast {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem 0.75rem;
  align-items: start;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.85rem 0.9rem 0.95rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, rgba(22, 29, 53, 0.96) 0%, rgba(12, 18, 38, 0.98) 100%);
  box-shadow:
    0 22px 50px -20px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(14px);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(0.75rem) scale(0.94);
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.bms-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.bms-toast.is-leaving {
  opacity: 0;
  transform: translateY(-0.5rem) scale(0.97);
}

.bms-toast__accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0.85rem 0 0 0.85rem;
}
.bms-toast--success .bms-toast__accent { background: linear-gradient(180deg, #72ff7f, #4d8e53); }
.bms-toast--error .bms-toast__accent { background: linear-gradient(180deg, #fb7185, #ef4444); }
.bms-toast--warning .bms-toast__accent { background: linear-gradient(180deg, #fde047, #f59e0b); }
.bms-toast--info .bms-toast__accent { background: linear-gradient(180deg, #67e8f9, #3b82f6); }

.bms-toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  flex-shrink: 0;
}
.bms-toast__icon svg { width: 1.1rem; height: 1.1rem; }
.bms-toast--success .bms-toast__icon { color: #86efac; background: rgba(77, 142, 83, 0.18); }
.bms-toast--error .bms-toast__icon { color: #fca5a5; background: rgba(239, 68, 68, 0.16); }
.bms-toast--warning .bms-toast__icon { color: #fde047; background: rgba(245, 158, 11, 0.16); }
.bms-toast--info .bms-toast__icon { color: #93c5fd; background: rgba(59, 130, 246, 0.16); }

.bms-toast__body { min-width: 0; padding-top: 0.05rem; }
.bms-toast__title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--bms-text, #fff);
}
.bms-toast__text {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--bms-text-muted, #97a0c2);
}

.bms-toast__close {
  border: none;
  background: transparent;
  color: var(--bms-text-muted, #97a0c2);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
  border-radius: 0.35rem;
}
.bms-toast__close:hover { color: var(--bms-text, #fff); background: rgba(255, 255, 255, 0.06); }

.bms-toast__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  transform-origin: left center;
  animation: bms-toast-progress 4.8s linear forwards;
  opacity: 0.85;
}
.bms-toast--success .bms-toast__progress { background: linear-gradient(90deg, #4d8e53, #72ff7f); }
.bms-toast--error .bms-toast__progress { background: linear-gradient(90deg, #ef4444, #fb7185); }
.bms-toast--warning .bms-toast__progress { background: linear-gradient(90deg, #f59e0b, #fde047); }
.bms-toast--info .bms-toast__progress { background: linear-gradient(90deg, #3b82f6, #67e8f9); }

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

@media (prefers-reduced-motion: reduce) {
  .bms-toast { transition: none; }
  .bms-toast__progress { animation: none; display: none; }
}

/* Confirm dialog */
.bms-confirm { z-index: 110; }
.bms-confirm__panel {
  width: min(92vw, 24rem);
  text-align: center;
  padding: 1.35rem 1.25rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.85);
}
.bms-confirm__icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.bms-confirm__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.28);
}
.bms-confirm__icon svg { width: 1.35rem; height: 1.35rem; }
.bms-confirm--danger .bms-confirm__icon {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}
.bms-confirm--warning .bms-confirm__icon {
  color: #fde047;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
}
.bms-confirm__title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bms-text, #fff);
}
.bms-confirm__message {
  margin: 0 0 1rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--bms-text-muted, #97a0c2);
}
.bms-confirm__message p { margin: 0 0 0.45rem; }
.bms-confirm__message p:last-child { margin-bottom: 0; }

.bms-confirm__actions {
  display: flex;
  gap: 0.55rem;
  justify-content: center;
}
.bms-confirm__actions .topbar-btn,
.bms-confirm__actions .btn-primary {
  min-width: 6.5rem;
  justify-content: center;
}
.bms-confirm__ok.bms-btn-danger {
  background: linear-gradient(135deg, #ef4444, #fb355e);
  border-color: rgba(251, 53, 94, 0.5);
}
.bms-confirm__ok.bms-btn-danger:hover {
  filter: brightness(1.06);
}

@media (max-width: 480px) {
  .bms-toast {
    width: min(20rem, calc(100vw - 1.5rem));
  }
  .bms-confirm__actions { flex-direction: column-reverse; }
  .bms-confirm__actions .topbar-btn,
  .bms-confirm__actions .btn-primary { width: 100%; }
}
