.pisell-lowcode-floating-layer-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.pisell-lowcode-floating-layer-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease;
}

.pisell-lowcode-floating-layer-content-wrapper {
  position: absolute;
  max-width: 100vw;
  transition: opacity 0.2s ease, transform 0.2s ease;
  will-change: opacity, transform;
  backface-visibility: hidden;
}

.pisell-lowcode-floating-layer-mode-drawer {
  &.pisell-lowcode-floating-layer-right {
    .pisell-lowcode-floating-layer-content-wrapper {
      top: 0;
      right: 0;
      bottom: 0;
    }
  }

  &.pisell-lowcode-floating-layer-left {
    .pisell-lowcode-floating-layer-content-wrapper {
      top: 0;
      bottom: 0;
      left: 0;
    }
  }

  &.pisell-lowcode-floating-layer-top {
    .pisell-lowcode-floating-layer-content-wrapper {
      top: 0;
      right: 0;
      left: 0;
    }
  }

  &.pisell-lowcode-floating-layer-bottom {
    .pisell-lowcode-floating-layer-content-wrapper {
      right: 0;
      bottom: 0;
      left: 0;
    }
  }
}

.pisell-lowcode-floating-layer-mode-modal {
  .pisell-lowcode-floating-layer-content-wrapper {
    top: 0;
    left: 0;
    overflow: hidden;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
  }
}

.pisell-lowcode-floating-layer-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08),
    0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
}

.pisell-lowcode-floating-layer-header {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  min-height: 56px;
  padding: 16px 24px;
  border-bottom: 0;
}

.pisell-lowcode-floating-layer-header-with-close {
  padding-right: 72px;
}

.pisell-lowcode-floating-layer-header-title {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
}

.pisell-lowcode-floating-layer-title {
  min-width: 0;
  flex: 1;
  color: rgba(0, 0, 0, 0.88);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

.pisell-lowcode-floating-layer-close {
  position: absolute;
  top: 50%;
  right: 12px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  line-height: 1;
  transform: translateY(-50%);
}

.pisell-lowcode-floating-layer-close > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.pisell-lowcode-floating-layer-close-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
}

.pisell-lowcode-floating-layer-close-icon::before,
.pisell-lowcode-floating-layer-close-icon::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  content: '';
  transform-origin: center;
}

.pisell-lowcode-floating-layer-close-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.pisell-lowcode-floating-layer-close-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.pisell-lowcode-floating-layer-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.88);
}

.pisell-lowcode-floating-layer-extra {
  flex: 0 0 auto;
  margin-inline-start: 12px;
}

.pisell-lowcode-floating-layer-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 24px;
  overflow: auto;
}

.pisell-lowcode-floating-layer-footer {
  flex: 0 0 auto;
  padding: 24px;
  border-top: 1px solid rgba(5, 5, 5, 0.06);
}

// 只有显式开启 autoHideHeaderFooterOnScroll 的 Drawer 才切换滚动模型；
// 未开启时保持原 DOM 与布局，避免影响已有 Modal、Kiosk 和普通调用方。
.pisell-lowcode-floating-layer-content-auto-hide-header-footer {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;

  > .pisell-lowcode-floating-layer-body {
    position: relative;
    z-index: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    // 内容不足一屏时自动撑开中间区域，让 Footer 仍停在抽屉底部；内容
    // 超过一屏时按真实高度增长。整个过程不需要测量 Header/Footer 高度。
    flex: 1 0 auto;
    overflow: visible;
  }

  > .pisell-lowcode-floating-layer-header-collapse-region,
  > .pisell-lowcode-floating-layer-footer-collapse-region {
    position: sticky;
    z-index: 3;
    width: 100%;
    flex-shrink: 0;

    > .pisell-lowcode-floating-layer-header,
    > .pisell-lowcode-floating-layer-footer {
      position: relative;
      z-index: 3;
      width: 100%;
    }
  }

  > .pisell-lowcode-floating-layer-header-collapse-region {
    top: 0;
  }

  > .pisell-lowcode-floating-layer-footer-collapse-region {
    bottom: 0;
  }

  // position 本身不能补间，松手恢复 sticky 时只做轻量淡入。阴影位于
  // Footer 内部，因此会与 Footer 作为一个整体同步淡入。
  &:not(.pisell-lowcode-floating-layer-content-header-footer-in-flow) {
    > .pisell-lowcode-floating-layer-header-collapse-region,
    > .pisell-lowcode-floating-layer-footer-collapse-region {
      animation: pisell-floating-layer-sticky-fade-in 180ms ease-out;
    }
  }

  // 滚动期间让同一份 Header / Footer 回到长列表原来的头尾位置。
  &.pisell-lowcode-floating-layer-content-header-footer-in-flow {
    > .pisell-lowcode-floating-layer-header-collapse-region,
    > .pisell-lowcode-floating-layer-footer-collapse-region {
      position: relative;
      top: auto;
      bottom: auto;
      animation: none;
    }
  }
}

@keyframes pisell-floating-layer-sticky-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pisell-lowcode-floating-layer-content-auto-hide-header-footer {
    > .pisell-lowcode-floating-layer-header-collapse-region,
    > .pisell-lowcode-floating-layer-footer-collapse-region {
      animation: none;
    }
  }
}

.pisell-lowcode-floating-layer-default-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
