/* 左侧侧边栏：添加数据图元 / 添加装饰（图元预览）+ 保存 */
.pisell-floor-map-layout-toolbar {
  &.pisell-floor-map-layout-toolbar-sidebar {
    position: relative;
    /**
     * 中等宽度抽屉：248px → 124px。
     * 配合 cellW/cellH（见 FloorMapToolbar.tsx）按 0.5 倍渲染，preview-cell（最大 92px）
     * + 标准 padding（12 8）正好落在 124px 内，兼顾画布展示空间与图元预览可视性。
     */
    width: 124px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    z-index: 10;
    /** 收起态：只保留一条边和外突的切换按钮 */
    transition: width 0.2s ease;
    /**
     * 注意：根元素必须保持 overflow: visible —— 否则下方 collapse-handle
     * 用 right: -22px 外突的按钮会被裁掉。横向裁剪转移到 &-inner 内层做。
     */

    &.pisell-floor-map-layout-toolbar-sidebar--collapsed {
      width: 0;
      border-right: none;
      /**
       * 不再给 body/footer 设 display: none —— 让它们维持固定宽度参与动画的横向裁剪，
       * 否则收起态切换会先 hide 后再瞬间 show，反而更容易暴露挤压的瞬间。
       */
    }
  }

  /**
   * 内层容器：宽度跟随 sidebar 100% 伸缩，但用 overflow: hidden + 子元素固定宽度
   * 把中间帧的水平挤压裁掉。这样 0→124px 展开过程中，body/footer 始终按 124px
   * 排版，只是从右侧逐步揭开，避免文案被压成竖排。
   */
  &-inner {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /**
   * 收起 / 展开按钮：左缘与侧栏**右缘对齐**（`left: 100%`），整体仍在侧栏外，不与图元预览重叠；
   * 旧写法 `right: -22px` + `width: 28` 会让按钮左缘落在侧栏内约 6px 压到卡片。
   * 收起态下容器宽度为 0，100% 仍锚在右缘，按钮仍能完整露出（z-index 高于地图区遮罩）。
   */
  &-collapse-handle {
    position: absolute;
    top: 50%;
    left: 100%;
    right: auto;
    transform: translateY(-50%);
    width: 28px;
    height: 72px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #595959;
    border: 1px solid #e8e8e8;
    border-left: none;
    border-radius: 0 12px 12px 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    z-index: 11;
    transition: color 0.15s, background 0.15s, border-color 0.15s,
      box-shadow 0.15s;

    /** 与顶栏撤销/重做一致：不因 hover 变色，避免编辑画布时视觉干扰 */
    &:hover {
      color: #595959;
      background: #fff;
      border-color: #e8e8e8;
      box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    }

    &:focus-visible {
      outline: 2px solid var(--fmap-primary, #1677ff);
      outline-offset: 2px;
    }

    .anticon {
      font-size: 16px;
      line-height: 1;
    }
  }

  &-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    /** 124px 抽屉下，左右各留 8px 给 preview-card 的标准 padding 兜住 92px cell */
    padding: 12px 8px;
    /**
     * 写死 124px 防止展开动画过程中跟随父容器 0→124px 同步缩放，避免文案被挤成竖排。
     * 父容器 overflow: hidden 会裁掉超出的部分，视觉上就是抽屉从右侧划出。
     */
    width: 124px;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  &-section {
    margin-bottom: 16px;

    &:last-of-type {
      margin-bottom: 0;
    }
  }

  &-section-title {
    margin: 0 0 8px 0;
    padding: 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: #262626;
    line-height: 20px;
  }

  &-preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  &-preview-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  &-preview-group-label {
    padding: 0 4px;
    font-size: 12px;
    color: #8c8c8c;
    line-height: 18px;
  }

  &-preview-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
  }

  &-preview-card {
    display: block;
    width: 100%;
    /** 标准 padding 适配 124px 抽屉 + 92px cell 的尺寸预算 */
    padding: 8px;
    text-align: center;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    cursor: grab;
    transition: border-color 0.2s, background 0.2s;

    &:hover {
      background: #f0f7ff;
      border-color: #91caff;
    }

    &.pisell-floor-map-layout-toolbar-preview-card-active {
      background: color-mix(in srgb,
      var(--fmap-primary, #1677ff) 12%,
      #fff);
      border-color: var(--fmap-primary, #1677ff);
      box-shadow: 0 0 0 1px var(--fmap-primary, #1677ff);
    }

    &.pisell-floor-map-layout-toolbar-preview-card-deco {
      .pisell-floor-map-layout-toolbar-preview-cell {
        margin: 0 auto;
      }
    }
  }

  &-preview-card-label {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #262626;
    line-height: 18px;
  }

  &-preview-cell {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 4px;
    box-sizing: border-box;
  }

  &-preview-content {
    pointer-events: none;
  }

  &-preview-cell {
    .pisell-floor-map-layout-toolbar-preview-content {
      overflow: hidden;
    }
  }

  &-preview-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 40px;
    font-size: 12px;
    color: #8c8c8c;
  }

  &-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 10px 16px;
    font-size: 15px;
    min-height: 40px;
    color: #333;
    background: #f5f5f5;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    cursor: pointer;

    &:hover {
      color: var(--fmap-primary, #1677ff);
      border-color: var(--fmap-primary, #1677ff);
      background: color-mix(in srgb,
      var(--fmap-primary, #1677ff) 12%,
      #fff);
    }

    &.cancel {
      color: #8c8c8c;
      margin-top: 12px;
    }

    &.cancel-inline {
      margin-top: 0;
      padding: 8px 12px;
      font-size: 14px;
      min-height: 40px;
      color: #8c8c8c;
    }

    &.primary {
      color: #fff;
      background: var(--fmap-primary, #1677ff);
      border-color: var(--fmap-primary, #1677ff);

      &:hover:not(:disabled) {
        background: color-mix(in srgb,
        var(--fmap-primary, #1677ff) 88%,
        #fff);
        border-color: color-mix(in srgb,
        var(--fmap-primary, #1677ff) 88%,
        #fff);
      }

      &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
      }
    }
  }

  &-footer {
    flex-shrink: 0;
    /** 与 body 同步水平 padding，124px 抽屉下按钮宽度足够呈现 */
    padding: 12px 8px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /** 同 body：固定 124px 防止展开动画期间被父容器宽度挤压换行 */
    width: 124px;
    box-sizing: border-box;
  }

  &-dirty-hint {
    font-size: 12px;
    line-height: 1.45;
    color: #d48806;
    padding: 6px 8px;
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 6px;
  }

  &-save-dirty {
    box-shadow: 0 0 0 2px rgba(250, 173, 20, 0.35);
  }

  &-error {
    font-size: 12px;
    color: #ff4d4f;
  }

  &-record-pick {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    margin-top: 4px;
    background: #f5f5f5;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
  }

  &-record-pick-label {
    font-size: 12px;
    font-weight: 600;
    color: #434343;
  }

  &-record-pick-hint {
    font-size: 11px;
    color: #8c8c8c;
    line-height: 1.45;
  }

  &-record-hint {
    font-size: 11px;
    color: #8c8c8c;
    padding: 6px 8px;
    margin-top: 4px;
    line-height: 1.45;
    background: #fafafa;
    border-radius: 4px;
  }
}

/**
 * 手机图元栏：antd Drawer 挂在 body，需与 .pisell-floor-map-layout-toolbar 并列书写。
 * z-index 与 PisellFloorMapLayout 约定一致，略低于右侧属性抽屉(2002)。
 */
.pisell-floor-map-layout-toolbar-phone-drawer-root {
  /** 折叠柄贴在面板右缘外侧，antd 多层 wrapper 默认 overflow:hidden 会裁切，需一并放开 */
  .pisell-floor-map-layout-toolbar-phone-drawer-body,
  .ant-drawer-content-wrapper,
  .ant-drawer-content {
    overflow: visible !important;
  }

  /** ConfigProvider 修改 prefixCls 时常为 pisell-lowcode */
  .pisell-lowcode-drawer-content-wrapper,
  .pisell-lowcode-drawer-content {
    overflow: visible !important;
  }

  .pisell-floor-map-layout-toolbar-phone-drawer-inner {
    position: relative;
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

  .pisell-floor-map-layout-toolbar-inner {
    flex: 1 1 auto;
    min-height: 0;
    width: min(320px, 88vw);
  }

  .pisell-floor-map-layout-toolbar-body {
    width: min(320px, 88vw);
    max-width: none;
  }

  .pisell-floor-map-layout-toolbar-footer {
    width: min(320px, 88vw);
    max-width: none;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/** 左侧抽屉收起后：贴左缘的展开触发条（与折叠柄视觉一致） */
.pisell-floor-map-layout-toolbar-phone-peek-trigger {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2001;
  width: 28px;
  height: 72px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #595959;
  border: 1px solid #e8e8e8;
  border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;

  &:hover {
    color: #595959;
    background: #fff;
    border-color: #e8e8e8;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
  }

  .anticon {
    font-size: 16px;
    line-height: 1;
  }
}
