/* 伪全屏宿主：锁定 body 滚动，避免双滚动条与触摸滑动穿透 */
body.pisell-floor-map-layout-fullscreen-host {
  overflow: hidden !important;
}

.pisell-floor-map-layout {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  background: #fafafa;

  /**
   * 伪全屏：撑满视口，替代浏览器 Fullscreen API；与资源墙大屏（pisell-resource-wall-fixed-viewport）
   * 一致体验。z-index 故意高于常见弹层但低于 antd Modal 默认 1000，必要时可在宿主侧覆盖。
   */
  &--pseudo-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 2000;
    background: #fff;
  }

  &-loading,
  &-save-error {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 8px 12px;
    font-size: 14px;
  }

  &-loading {
    top: 0;
    background: rgba(255, 255, 255, 0.9);
    color: #666;
  }

  &-save-error {
    top: 0;
    background: #fff2f0;
    color: #cf1322;
  }

  &-edit-placeholder-toolbar {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    font-size: 12px;
    color: #999;
    background: #fff;
    border: 1px dashed #d9d9d9;
    border-radius: 4px;
    z-index: 5;
  }

  /**
   * 右侧编辑面板（图元 / 连线共用）：上下锚定，底部留出 ViewControls Dock，
   * 避免面板白底盖住右下缩放等操作栏。
   */
  &-edit-panel-wrap {
    position: absolute;
    top: 16px;
    right: 16px;
    bottom: calc(16px + var(--fmap-viewport-dock-bottom-clearance, 78px));
    transform: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    max-width: min(280px, calc(100% - 32px));

    > .pisell-floor-map-layout-edit-panel,
    > .pisell-floor-map-layout-edge-edit-panel {
      flex: 1 1 auto;
      min-height: 0;
      max-height: 100%;
      height: auto;
      box-sizing: border-box;
    }
  }

  &-edit-panel-wrap-constrained {
    overflow: hidden;
  }

  &-edit-panel-wrap--phone-drawer {
    /**
     * 覆盖桌面端 &-edit-panel-wrap 的 absolute 居中，避免抽屉内排版错位。
     * 必须额外清掉桌面基类的 `bottom: calc(16px + 78px)` 与 `max-width: min(280px, …)`：
     * 前者会在 position:relative 下把面板整体上移 ~94px，后者会让 320px 抽屉里只渲染 280px，
     * 表现为「面板偏上 + 右侧白边」。请勿删除 `inset: auto` / `max-width: none` / `width: 100%`。
     */
    position: relative;
    inset: auto;
    transform: none;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: none;
    height: 100%;
    box-sizing: border-box;
    /**
     * 顶部安全区由内层内容节点吸收。早先放在 antd 外层 fixed root（.…-drawer）上的
     * `padding-top: env(safe-area-inset-top)` 会让 antd 的 `position:absolute; right:0`
     * content-wrapper 解析 padding 边后整块向下平移，iOS Safari 出现整抽屉位移；
     * 落到内容节点则只把面板内部下移，不再扰动 fixed/absolute 定位链。
     */
    padding-top: env(safe-area-inset-top, 0px);
  }

  /**
   * 手机编辑态：左侧图元栏悬浮，不占 flex，画布始终铺满下层。
   */
  &-edit-layout--phone-toolbar {
    position: relative;
    flex: 1 1 0;
    display: block;
    min-height: 0;
    /** 保证左侧悬浮抽屉的 absolute 参照高度为整块地图区（否则仅有绝对子项时高度链可能塌缩） */
    height: 100%;
    overflow: hidden;

    > .pisell-floor-map-layout-map-area--phone-fill {
      position: absolute;
      inset: 0;
      flex: none !important;
      width: auto !important;
      height: auto !important;
    }
  }

  &-place-overlay {
    position: absolute;
    left: 0;
    top: 0;
    cursor: crosshair;
    z-index: 1;
  }

  /* 编辑态拖入图源：平时穿透事件，激活时盖住画布以接收 drop */

  &-map-drop-layer {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 0;
    box-sizing: border-box;

    &-active {
      pointer-events: auto;
      z-index: 100;
      box-shadow: inset 0 0 0 2px var(--fmap-primary, #1677ff);
      background: color-mix(in srgb,
      var(--fmap-primary, #1677ff) 6%,
      transparent);
    }
  }

  /** 视口内悬浮层：不随 Transform 缩放平移，与 ViewControls 同级 */

  /**
   * 右下 ViewControls Dock（14px + 56px chrome + 8px 间距），供右侧编辑面板底部留白。
   * 数值与 {@link FLOOR_MAP_VIEWPORT_DOCK_BOTTOM_CLEARANCE} 保持一致。
   */
  &-floor-map-view {
    --fmap-viewport-dock-bottom-clearance: 78px;
  }

  &-viewport-overlay {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 19;
    pointer-events: none;
    max-width: min(280px, 46vw);

    > * {
      pointer-events: auto;
    }

    &--bottom-start {
      top: auto;
      bottom: 12px;
      max-width: min(92vw, 560px);
    }
  }

  /** 编辑态：画布区域（含 Transform）为右侧 FloorMapEditPanel 预留宽度 */

  &-map-area {
    box-sizing: border-box;

    &--edit-panel-inset {
      padding-right: 336px;
    }
  }
}

/**
 * 右侧属性 antd Drawer 根（portal body）。
 * 顶部安全区不再放在这个 fixed 外层（会让 antd content-wrapper 整块下移、iOS 上抽屉位移），
 * 已迁移到 `.…-edit-panel-wrap--phone-drawer` 内容节点；本块保留作占位，便于后续追加根级样式。
 */
.pisell-floor-map-layout-edit-panel-phone-drawer-root {
  // 暂无规则；如需新增整体抽屉级样式（如 mask 颜色、z-index 微调）写在此处。
}
