.saas-app-device-planning {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #f5f6f8;

  &__global-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 12px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;

    &-left {
      display: flex;
      align-items: center;
      gap: 12px;
    }
  }

  &__global-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  &__switch-model-button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    padding: 0 4px;
    font-size: 12px;
  }

  &__global-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    color: rgba(0, 0, 0, 0.88);
  }

  &__global-subtitle {
    margin-top: 2px;
    font-size: 12px;
    line-height: 18px;
    color: rgba(0, 0, 0, 0.45);
  }

  &__body {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  &__content {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 16px 24px 24px;
    overflow: hidden;
    background: #ffffff;

    &--model-selecting {
      padding: 24px;
    }
  }

  &__page-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  &__title {
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
    color: rgba(0, 0, 0, 0.88);
  }

  &__subtitle {
    margin-top: 2px;
    font-size: 13px;
    color: rgba(0, 0, 0, 0.45);
  }

  &__empty-workarea {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 0;
    background: #fff;
    border-radius: 8px;
  }

  &__model-step {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  &__model-group {
    margin-bottom: 28px;

    &:last-child {
      margin-bottom: 0;
    }
  }

  &__model-group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    color: rgba(0, 0, 0, 0.88);

    .anticon {
      font-size: 20px;
      color: rgba(0, 0, 0, 0.88);
    }
  }

  &__model-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
  }

  &__model-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 104px;
    padding: 24px;
    border: none;
    border-radius: 8px;
    background: #f5f6f8;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition:
      background 0.2s ease,
      box-shadow 0.2s ease;

    &:hover {
      background: #eef3ff;
      box-shadow: 0 2px 8px rgba(22, 119, 255, 0.12);
    }
  }

  &__model-card-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 26px;
    color: rgba(0, 0, 0, 0.88);
  }

  &__model-card-desc {
    margin-top: 8px;
    font-size: 14px;
    line-height: 22px;
    color: rgba(0, 0, 0, 0.45);
  }

  :global(.ant-tabs-nav) {
    margin-bottom: 0;
  }

  &--phone {
    height: 100dvh;

    .saas-app-device-planning__global-header {
      flex-wrap: wrap;
      gap: 8px;
      padding: 12px 16px;
    }

    .saas-app-device-planning__global-header-left {
      min-width: 0;
    }

    .saas-app-device-planning__global-title {
      font-size: 17px;
      line-height: 24px;
    }

    .saas-app-device-planning__global-actions {
      flex: 0 0 auto;
      max-width: calc(100% - 40px);
      margin-left: 40px;
      padding: 4px;
      gap: 6px;
      flex-wrap: nowrap;
      justify-content: flex-start;
    }

    .saas-app-device-planning__global-header:not(
        .saas-app-device-planning__global-header--with-back
      )
      .saas-app-device-planning__global-actions {
      max-width: 100%;
      margin-left: 0;
    }

    .saas-app-device-planning__global-actions .ant-tag,
    .saas-app-device-planning__global-actions .pisell-lowcode-tag {
      display: inline-flex;
      align-items: center;
      height: 28px;
      margin: 0;
      padding: 0 10px;
      border-radius: 8px;
      font-size: 13px;
      line-height: 28px;
    }

    .saas-app-device-planning__switch-model-button {
      height: 28px;
      padding: 0 10px;
      border-radius: 8px;
      font-size: 13px;
    }

    .saas-app-device-planning__body {
      flex-direction: column;
      overflow: hidden;
    }

    .saas-app-device-planning__content {
      padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
    }

    .saas-app-device-planning__content--model-selecting {
      padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    }

    .saas-app-device-planning__page-header {
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 10px;
    }

    .saas-app-device-planning__page-header > div {
      min-width: 0;
    }

    .saas-app-device-planning__title {
      font-size: 15px;
      line-height: 22px;
    }

    .saas-app-device-planning__subtitle {
      display: -webkit-box;
      overflow: hidden;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
    }

    .saas-app-device-planning__workarea-trigger {
      display: flex;
      flex: 0 0 auto;
      align-items: center;
      width: 100%;
      min-height: 44px;
      margin-bottom: 12px;
      padding: 10px 12px;
      border: 1px solid #e5e6eb;
      border-radius: 10px;
      background: #f7f8fa;
      color: inherit;
      text-align: left;
    }

    .saas-app-device-planning__workarea-trigger-label {
      flex: 0 0 auto;
      margin-right: 10px;
      font-size: 12px;
      color: rgba(0, 0, 0, 0.45);
    }

    .saas-app-device-planning__workarea-trigger-value {
      flex: 1;
      min-width: 0;
      overflow: hidden;
      font-size: 14px;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.88);
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .saas-app-device-planning__model-group {
      margin-bottom: 20px;
    }

    .saas-app-device-planning__model-group-title {
      margin-bottom: 10px;
      font-size: 16px;
      line-height: 24px;
    }

    .saas-app-device-planning__model-grid {
      grid-template-columns: 1fr;
      gap: 12px;
    }

    .saas-app-device-planning__model-card {
      min-height: auto;
      padding: 16px;
    }

    .saas-app-device-planning__model-card-title {
      font-size: 16px;
      line-height: 24px;
    }
  }
}

.saas-app-device-planning-workarea-drawer {
  .ant-drawer-body {
    display: flex;
    padding: 0;
    overflow: hidden;
  }

  &--phone {
    .saas-app-device-planning-sider.saas-app-device-planning-sider--drawer {
      flex: 1 1 100%;
      flex-basis: 100%;
      width: 100%;
      min-width: 0;
      max-width: none;
      border-right: none;
    }
  }
}

.saas-app-device-planning-takeover-modal {
  &__title {
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 600;
    line-height: 32px;
    color: rgba(0, 0, 0, 0.88);
  }

  &__warning {
    display: flex;
    gap: 16px;
    padding: 24px;
    border: 1px solid #ffd666;
    border-radius: 8px;
    background: #fffbe6;
    color: #ad6800;

    > .anticon {
      flex: 0 0 auto;
      margin-top: 2px;
      font-size: 24px;
    }
  }

  &__message {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
  }

  &__detail {
    margin-top: 8px;
    font-size: 16px;
    line-height: 24px;

    strong {
      margin-right: 4px;
    }
  }

  &__desc {
    margin-top: 24px;
    font-size: 16px;
    line-height: 24px;
  }

  &__footer {
    display: flex;
    width: 100%;
    justify-content: flex-end;
    gap: 16px;
  }
}

.add-device-modal--phone,
.edit-device-modal--phone,
.saas-app-device-planning-workarea-modal--phone,
.saas-app-device-planning-delete-modal--phone,
.saas-app-device-planning-delete-device-modal--phone,
.saas-app-device-planning-takeover-modal--phone {
  width: 100%;
  max-width: 100%;

  .ant-modal-body,
  .pisell-lowcode-modal-body {
    max-height: calc(100dvh - 172px);
    overflow: auto;
  }

  .pisell-lowcode-modal-content {
    max-height: 90dvh;
  }

  .ant-modal-footer,
  .pisell-lowcode-modal-footer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

.saas-app-device-planning-takeover-modal--phone {
  .pisell-lowcode-modal-body {
    padding: 0 24px;
  }

  .saas-app-device-planning-takeover-modal__title {
    margin-bottom: 16px;
    font-size: 20px;
    line-height: 28px;
  }

  .saas-app-device-planning-takeover-modal__warning {
    gap: 12px;
    padding: 16px;
  }

  .saas-app-device-planning-takeover-modal__message {
    font-size: 16px;
  }

  .saas-app-device-planning-takeover-modal__detail,
  .saas-app-device-planning-takeover-modal__desc {
    font-size: 14px;
    line-height: 22px;
  }

  .saas-app-device-planning-takeover-modal__footer {
    gap: 12px;

    button {
      flex: 1;
      min-height: 40px;
    }
  }
}
