/* 编辑态单行顶栏：画布 Tab + 保存 / 扩展操作 */
.pisell-floor-map-layout-edit-top-bar {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex-shrink: 0;
  min-height: 48px;
  background: #fff;
  border-bottom: 1px solid #f0f0f0;
  z-index: 3;

  /** 单画布：无 Tab 区时操作区靠右，去掉左侧竖线 */

  &--tabs-hidden {
    justify-content: flex-end;

    .pisell-floor-map-layout-edit-top-bar-actions {
      border-left: none;
    }
  }

  &-tabs {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: stretch;
    overflow: hidden;
  }

  /* 嵌入顶栏时去掉 CanvasTabs 自身底边，避免双线 */

  &-canvas-tabs.pisell-floor-map-layout-canvas-tabs {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    border-bottom: none;
    flex-wrap: nowrap;
    align-items: center;
  }

  &-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-left: 1px solid #f0f0f0;
  }

  /**
   * 编辑态 compact / full：画布切换条上下收紧；操作区（含 undo/redo）左右收紧。
   */
  &--compact.pisell-floor-map-layout-read-canvas-tabs-bar,
  &--full-chrome.pisell-floor-map-layout-read-canvas-tabs-bar {
    min-height: 40px;

    .pisell-floor-map-layout-edit-top-bar-canvas-tabs.pisell-floor-map-layout-canvas-tabs {
      padding: 3px 6px;
      gap: 6px;
    }
  }

  &--compact > .pisell-floor-map-layout-edit-top-bar-actions,
  &--full-chrome > .pisell-floor-map-layout-edit-top-bar-actions {
    padding: 0 6px;
    gap: 6px;
  }

  &-error {
    max-width: 160px;
    font-size: 12px;
    color: #ff4d4f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 全屏顶栏右侧：取消 / 完成按钮组（未保存徽章已外提到 history 左侧，不再属于本组） */

  &-save-group {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  /* 撤销 / 重做按钮组：作为 actions 区第一组元素显示 */
  &-history {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;

    /** 关闭 antd text 按钮的 hover / active 视觉反馈，避免顶栏闪动 */
    .pisell-floor-map-layout-edit-top-bar-history-btn {
      &.ant-btn-text:not(:disabled),
      &.pisell-lowcode-btn-text:not(:disabled) {
        &:hover,
        &:focus-visible,
        &:active {
          color: rgba(0, 0, 0, 0.88);
          background: transparent;
          box-shadow: none;
        }
      }
    }
  }

  &-dirty-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    color: #ad6800;
    white-space: nowrap;
    background: linear-gradient(180deg, #fffef7 0%, #fff7e6 100%);
    border: 1px solid #ffe7a3;
    border-radius: 999px;
    box-shadow: 0 1px 2px rgba(173, 104, 0, 0.06);

    &::before {
      content: '';
      width: 6px;
      height: 6px;
      flex-shrink: 0;
      border-radius: 50%;
      background: #faad14;
      box-shadow: 0 0 0 2px rgba(250, 173, 20, 0.25);
    }
  }

  &-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 32px;
    padding: 0 14px;
    font-size: 14px;
    line-height: 1;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #d9d9d9;
    background: #fff;
    color: rgba(0, 0, 0, 0.88);
    transition: border-color 0.2s, background 0.2s;

    &:hover:not(:disabled) {
      border-color: var(--fmap-primary, #1677ff);
      color: var(--fmap-primary, #1677ff);
    }

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

    &.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);
        color: #fff;
      }
    }
  }

  &-btn-ghost {
    min-width: 32px;
    padding: 0 8px;
    font-size: 16px;
  }

  /**
   * 只读顶栏（`edit-top-bar` + `read-canvas-tabs-bar` 并列）、编辑态 compact、
   * 以及全屏/locked 时的 full 顶栏：与左侧 Tab 同一浅灰底，去掉右侧大块白底与竖线分割。
   */

  &.pisell-floor-map-layout-read-canvas-tabs-bar,
  &--compact,
  &--full-chrome {
    background: rgba(0, 0, 0, 0.04);

    .pisell-floor-map-layout-edit-top-bar-actions {
      background: transparent;
      border-left: none;
    }

    .pisell-floor-map-layout-edit-top-bar-canvas-tabs.pisell-floor-map-layout-canvas-tabs {
      background: transparent;
    }
  }

  /**
   * 与阅读态同一行的画布 Tab：多画布时不压缩胶囊，整行横向滑动（触摸友好）。
   */
  &.pisell-floor-map-layout-read-canvas-tabs-bar {
    .pisell-floor-map-layout-edit-top-bar-tabs {
      flex: 1;
      min-width: 0;
      /** 覆盖根级 &-tabs 的 overflow:hidden */
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
    }

    .pisell-floor-map-layout-edit-top-bar-canvas-tabs.pisell-floor-map-layout-canvas-tabs {
      flex: 0 0 auto;
      width: max-content;
      max-width: none;
    }
  }

  /**
   * 手机编辑：首行与阅读态 `read-canvas-tabs-bar` 一致（仅多 canEdit 能力）；
   * 第二行放撤销/业务尾区/保存等，**左对齐**（不居中、不整行右对齐）。
   */
  &--phone-edit-canvas-row {
    flex-direction: row;
    align-items: center;
    min-height: 0;
    border-bottom: 1px solid #f0f0f0;
  }

  &--phone-actions-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    min-height: 44px;
    background: rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid #f0f0f0;
    z-index: 3;

    .pisell-floor-map-layout-edit-top-bar-actions {
      flex: 1;
      min-width: 0;
      padding: 0 4px;
      border-left: none;
      flex-wrap: wrap;
      justify-content: flex-start;
      row-gap: 4px;
      column-gap: 6px;
    }
  }
}
