/* SaaS modal system */
#modal-root {
  position: fixed;
  inset: 0;
  z-index: 2000;
  pointer-events: none;
}
#modal-root:empty {
  display: none;
}

body.has-modal {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, #020617 80%, transparent);
  backdrop-filter: blur(4px);
  animation: modal-fade-in 180ms ease forwards;
  pointer-events: auto;
}
.modal-backdrop.is-leaving {
  animation: modal-fade-out 180ms ease forwards;
}

.modal {
  background: var(--panel, #fff);
  color: var(--text, #0f172a);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  width: min(480px, 90vw);
  max-width: 480px;
  transform-origin: center;
  animation: modal-scale-in 200ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow: hidden;
}
.modal.is-leaving {
  animation: modal-scale-out 160ms ease forwards;
}

.modal-header {
  padding: 20px 24px 10px;
}
.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 0 24px 20px;
  color: var(--text-muted, var(--muted, #475569));
  font-size: 14px;
  line-height: 1.5;
}

.modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  background: color-mix(in oklab, var(--panel, #fff) 85%, transparent);
}
.modal-footer .btn {
  min-width: 110px;
}

.modal[data-type="alert"] .modal-title,
.modal[data-type="confirm"] .modal-title,
.modal[data-type="info"] .modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal[data-type="alert"] .modal-title::before,
.modal[data-type="confirm"] .modal-title::before,
.modal[data-type="info"] .modal-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
}
.modal[data-type="alert"] .modal-title::before {
  background: var(--error, #ef4444);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}
.modal-close:hover {
  background: color-mix(in oklab, var(--panel, #fff) 75%, transparent);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes modal-scale-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes modal-scale-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
  }
}

@media (max-width: 480px) {
  .modal {
    border-radius: 14px;
  }
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 18px;
    padding-right: 18px;
  }
}
