/**
 * 弹框组件 - 与当前系统设计规范一致
 * 使用 design-tokens 主色、圆角、阴影、层级
 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  box-sizing: border-box;
  animation: modal-backdrop-in var(--transition-base) ease-out;
}

.modal-backdrop.is-hidden {
  pointer-events: none;
  opacity: 0;
  animation: modal-backdrop-out var(--transition-base) ease-in forwards;
}

@keyframes modal-backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.modal-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-dialog-in var(--transition-base) ease-out;
}

.modal-backdrop.is-hidden .modal-dialog {
  animation: modal-dialog-out var(--transition-base) ease-in forwards;
}

@keyframes modal-dialog-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modal-dialog-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-xl);
  flex-shrink: 0;
  margin-top: 22px;
}

.modal-title {
  height: 24px;
  font-family: PingFang SC, PingFang SC, sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: rgba(0, 0, 0, 0.9);
  line-height: 24px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  margin: 0;
}

.modal-close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent url(../assets/icons/icon-close.png) center center no-repeat;
  background-size: contain;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast);
}

.modal-close:hover {
  opacity: 0.8;
}

.modal-close::after {
  content: '';
  display: none;
}

.modal-body {
  padding: var(--spacing-sm) var(--spacing-xl) var(--spacing-sm);
  font-family: PingFang SC, PingFang SC, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.6);
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-body p {
  margin: 0 0 0.5em;
  line-height: 22px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-xl) var(--spacing-sm);
  flex-shrink: 0;
  margin-bottom: 32px;
  margin-top: 10px;
}

/* 取消按钮：宽度不写死，由内边距+文案决定 */
.modal-footer .btn {
  min-width: 0;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}

.modal-footer .btn--secondary {
  order: 0;
  height: 32px;
  font-family: PingFang SC, PingFang SC, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.6);
  line-height: 22px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.modal-footer .btn--secondary:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.25);
  color: rgba(0, 0, 0, 0.6);
}

.modal-footer .btn--primary {
  order: 1;
  height: 32px;
  background: #186338;
  border-radius: 3px;
  border: none;
  color: #fff;
  font-family: PingFang SC, PingFang SC, sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 22px;
}

.modal-footer .btn--primary:hover {
  background: #14522d;
  color: #fff;
}
